diff --git a/host_applications/linux/apps/gencmd/vcgencmd-completion-test.bats b/host_applications/linux/apps/gencmd/vcgencmd-completion-test.bats index b32922a48..9cfa095ef 100755 --- a/host_applications/linux/apps/gencmd/vcgencmd-completion-test.bats +++ b/host_applications/linux/apps/gencmd/vcgencmd-completion-test.bats @@ -40,6 +40,10 @@ complete_command() { fi } +is_pi4() { + grep -qE '^Model.* Raspberry Pi 4' /proc/cpuinfo +} + @test "vcgencmd - -> -t -h --help" { complete_command "vcgencmd -" [[ "${COMPREPLY[*]}" == "-t -h --help" ]] @@ -108,11 +112,31 @@ complete_command() { [[ "${COMPREPLY[*]}" == "0 1" ]] } +# Pi 4B has two hdmi pixel freq limits 0 and 1, Pi 2 and 3 just have one @test "get_config hdmi_pixel_freq_li -> hdmi_pixel_freq_limit:0" { + if is_pi4; then + skip "test only valid with 1 hdmi (earlier pi models)" + fi complete_command "vcgencmd get_config hdmi_pixel_freq_li" [[ "${COMPREPLY[*]}" == "hdmi_pixel_freq_limit:0" ]] } +@test "get_config hdmi_pixel_freq_li -> hdmi_pixel_freq_limit:" { + if ! is_pi4; then + skip "test requires Pi 4 with 2 hdmi outputs" + fi + complete_command "vcgencmd get_config hdmi_pixel_freq_li" + [[ "${COMPREPLY[*]}" == "hdmi_pixel_freq_limit:0 hdmi_pixel_freq_limit:1" ]] +} + +@test "get_config hdmi_pixel_freq_limit: -> 0 1" { + if ! is_pi4; then + skip "test requires Pi 4 with 2 hdmi outputs" + fi + complete_command "vcgencmd get_config hdmi_pixel_freq_limit:" + [[ "${COMPREPLY[*]}" == "0 1" ]] +} + @test "vcos -> version log" { complete_command "vcgencmd vcos " echo "${COMPREPLY[*]}" | grep -Ewo "(version|log)" @@ -168,3 +192,8 @@ complete_command() { complete_command "vcgencmd -t vcos log " [[ "${COMPREPLY[*]}" == "status" ]] } + +@test "vcos 0 -> (nothing)" { + complete_command "vcgencmd vcos 0 " + [[ "${#COMPREPLY[@]}" -eq 0 ]] +} diff --git a/host_applications/linux/apps/gencmd/vcgencmd-completion.bash b/host_applications/linux/apps/gencmd/vcgencmd-completion.bash index b97573357..dd30e296b 100644 --- a/host_applications/linux/apps/gencmd/vcgencmd-completion.bash +++ b/host_applications/linux/apps/gencmd/vcgencmd-completion.bash @@ -96,14 +96,20 @@ _vcgencmd() { fi if [[ $args -eq 3 ]]; then - case "$prev" in - 0|1|-1) - opts='0 1 2 3 7' + case "${words[cword - 2]}" in + display_power) + case "$prev" in + 0|1|-1) + opts='0 1 2 3 7' + ;; + esac ;; - esac - case "$prev" in - log) - opts='status' + vcos) + case "$prev" in + log) + opts='status' + ;; + esac ;; esac fi