From 3f8ed0e91a721e1d3a6dac95dd0bd26ffa9dc5d3 Mon Sep 17 00:00:00 2001 From: ferbraher Date: Mon, 18 Mar 2024 17:44:32 +0100 Subject: [PATCH] fixed shellcheck issues --- contrib/genio/bin/set_as_performance_mode.sh | 2 +- contrib/genio/bin/test_1.sh | 11 ++++ contrib/genio/bin/verify-mt8188-ccf.sh | 2 +- contrib/genio/bin/verify-mt8195-ccf.sh | 2 +- contrib/genio/units/device/jobs.pxu | 4 +- contrib/genio/units/graphic/jobs.pxu | 2 +- contrib/genio/units/hdmi-rx/jobs.pxu | 59 ++++++++++---------- contrib/genio/units/thermal/jobs.pxu | 2 +- 8 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 contrib/genio/bin/test_1.sh diff --git a/contrib/genio/bin/set_as_performance_mode.sh b/contrib/genio/bin/set_as_performance_mode.sh index a081d7896..ba97b5cbb 100755 --- a/contrib/genio/bin/set_as_performance_mode.sh +++ b/contrib/genio/bin/set_as_performance_mode.sh @@ -31,7 +31,7 @@ get_current_setting() { for i in {0..2} do # shellcheck disable=SC2027 - echo "- /sys/class/thermal/thermal_zone0/trip_point_"$i"_temp" + echo "- /sys/class/thermal/thermal_zone0/trip_point_""$i""_temp" cat /sys/class/thermal/thermal_zone0/trip_point_"$i"_temp done elif [ "${1}" == "G350" ]; then diff --git a/contrib/genio/bin/test_1.sh b/contrib/genio/bin/test_1.sh new file mode 100644 index 000000000..c9bbc6b2e --- /dev/null +++ b/contrib/genio/bin/test_1.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +output=$(tr -d '\0' < /proc/device-tree/compatible) +# Set comma as delimiter +IFS=',' +read -ra output_arr <<< "$output" +# Set dash as delimiter +IFS='-' +read -ra s <<< "${output_arr[1]}" +echo "SoC: ${s[0]}" +echo diff --git a/contrib/genio/bin/verify-mt8188-ccf.sh b/contrib/genio/bin/verify-mt8188-ccf.sh index 7518660f6..34c6c8220 100755 --- a/contrib/genio/bin/verify-mt8188-ccf.sh +++ b/contrib/genio/bin/verify-mt8188-ccf.sh @@ -98,7 +98,7 @@ if [ "${NR_MISSING_CLKS}" -ne "0" ]; then printf "[-] Missing clocks: \n" cat missing-clocks.txt - printf "\n[-] Count missing clocks: "${NR_MISSING_CLKS}"\n" + printf "\n[-] Count missing clocks: %s\n" "${NR_MISSING_CLKS}" else printf "[-] Success, all clocks are mapped !\n" fi diff --git a/contrib/genio/bin/verify-mt8195-ccf.sh b/contrib/genio/bin/verify-mt8195-ccf.sh index 40ef510b7..4f8bc42ce 100755 --- a/contrib/genio/bin/verify-mt8195-ccf.sh +++ b/contrib/genio/bin/verify-mt8195-ccf.sh @@ -71,7 +71,7 @@ if [ "${NR_MISSING_CLKS}" -ne "0" ]; then printf "[-] Missing clocks: \n" cat missing-clocks.txt - printf "\n[-] Count missing clocks: "${NR_MISSING_CLKS}"\n" + printf "\n[-] Count missing clocks: %s\n" "${NR_MISSING_CLKS}" else printf "[-] Success, all clocks are mapped !\n" fi diff --git a/contrib/genio/units/device/jobs.pxu b/contrib/genio/units/device/jobs.pxu index d775927ba..1f299d0dc 100644 --- a/contrib/genio/units/device/jobs.pxu +++ b/contrib/genio/units/device/jobs.pxu @@ -6,9 +6,9 @@ command: output=$(tr -d '\0' < /proc/device-tree/compatible) # Set comma as delimiter IFS=',' - read -a output_arr <<< "$output" + read -ra output_arr <<< "$output" # Set dash as delimiter IFS='-' - read -a s <<< "${output_arr[1]}" + read -ra s <<< "${output_arr[1]}" echo "SoC: ${s[0]}" echo diff --git a/contrib/genio/units/graphic/jobs.pxu b/contrib/genio/units/graphic/jobs.pxu index 0a035bf41..6a0847fa2 100644 --- a/contrib/genio/units/graphic/jobs.pxu +++ b/contrib/genio/units/graphic/jobs.pxu @@ -97,7 +97,7 @@ _purpose: The resolution of glmark2-es2-wayland is 1920x1080 command: set -e - output=$(glmark2-es2-wayland -s 1920x1080 --data-path $SNAP/usr/share/glmark2) + output=$(glmark2-es2-wayland -s 1920x1080 --data-path "$SNAP"/usr/share/glmark2) echo "$output" if ! echo "$output" | grep "GL_VENDOR" | grep -q "ARM"; then echo "FAIL: Wrong vendor!" diff --git a/contrib/genio/units/hdmi-rx/jobs.pxu b/contrib/genio/units/hdmi-rx/jobs.pxu index 200bd6647..8462381be 100644 --- a/contrib/genio/units/hdmi-rx/jobs.pxu +++ b/contrib/genio/units/hdmi-rx/jobs.pxu @@ -8,8 +8,7 @@ user: root _summary: Check the mtk_hdmirx module has been loaded command: echo "Check the mtk_hdmirx module has been loaded..." - lsmod | grep -w mtk_hdmirx - if [[ "$?" -ne 0 ]]; then + if ! lsmod | grep -w mtk_hdmirx; then echo "Failed: The 'mtk_hdmirx' module isn't loaded!" exit 1 fi @@ -32,13 +31,13 @@ user: root command: EXIT=0 temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log start_observing + hdmirx_tool_runner.sh "$temp_log" start_observing echo expected_events='HDMI_RX_PWR_5V_CHANGE HDMI_RX_PLUG_IN HDMI_RX_TIMING_LOCK HDMI_RX_AUD_LOCK' for event in $expected_events do echo "Checking event: $event..." - if [ "$(grep -w $event $temp_log)" == "" ]; then + if [ "$(grep -w "$event" "$temp_log")" == "" ]; then echo "- FAIL: Unable to find the '$event' event" EXIT=1 else @@ -74,9 +73,9 @@ flags: also-after-suspend user: root command: temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log check_cable + hdmirx_tool_runner.sh "$temp_log" check_cable echo - hdmirx_output_checker.sh $temp_log verify_check_cable_output "hdmi connected" + hdmirx_output_checker.sh "$temp_log" verify_check_cable_output "hdmi connected" _summary: Check the HDMI connection by using hdmi_rx tool _description: This test checks the hdmi_rx tool should shows the "hdmi connected" information after @@ -99,14 +98,14 @@ flags: also-after-suspend user: root command: temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log check_video_locked + hdmirx_tool_runner.sh "$temp_log" check_video_locked echo - hdmirx_output_checker.sh $temp_log verify_check_video_locked_output "video locked" + hdmirx_output_checker.sh "$temp_log" verify_check_video_locked_output "video locked" temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log get_video_info + hdmirx_tool_runner.sh "$temp_log" get_video_info echo expected_values="1920 1080 60" - hdmirx_output_checker.sh $temp_log verify_get_video_info_output "${expected_values}" + hdmirx_output_checker.sh "$temp_log" verify_get_video_info_output "${expected_values}" _summary: Check the event by hdmi_rx tool while plugging the HDMI cable to HDMI RX port _description: This test checks some video information from hdmi_rx tool should match the expectation. @@ -130,14 +129,14 @@ flags: also-after-suspend user: root command: temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log check_audio_locked + hdmirx_tool_runner.sh "$temp_log" check_audio_locked echo - hdmirx_output_checker.sh $temp_log verify_check_audio_locked_output "video locked" + hdmirx_output_checker.sh "$temp_log" verify_check_audio_locked_output "video locked" temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log get_audio_info + hdmirx_tool_runner.sh "$temp_log" get_audio_info echo expected_values="24 bits, Channel Number [2], 48.0 kHz" - hdmirx_output_checker.sh $temp_log verify_get_audio_info_output "${expected_values}" + hdmirx_output_checker.sh "$temp_log" verify_get_audio_info_output "${expected_values}" _summary: Check the event by hdmi_rx tool while plugging the HDMI cable to HDMI RX port _description: This test checks some audio information from hdmi_rx tool should match the expectation. @@ -161,10 +160,10 @@ flags: also-after-suspend user: root command: temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log disable_hdmi - hdmirx_tool_runner.sh $temp_log check_cable + hdmirx_tool_runner.sh "$temp_log" disable_hdmi + hdmirx_tool_runner.sh "$temp_log" check_cable echo - hdmirx_output_checker.sh $temp_log verify_check_cable_output "hdmi disconnected" + hdmirx_output_checker.sh "$temp_log" verify_check_cable_output "hdmi disconnected" _summary: Disable the HDMI RX functionaliy by hdmi_rx tool _description: This test will disable the functionaliy of HDMI RX by using hdmi_rx tool and the HDMI RX port still be connected. @@ -186,30 +185,30 @@ flags: also-after-suspend user: root command: temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log enable_hdmi - hdmirx_tool_runner.sh $temp_log check_cable + hdmirx_tool_runner.sh "$temp_log" enable_hdmi + hdmirx_tool_runner.sh "$temp_log" check_cable echo - hdmirx_output_checker.sh $temp_log verify_check_cable_output "hdmi connected" + hdmirx_output_checker.sh "$temp_log" verify_check_cable_output "hdmi connected" # Verify Video info temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log check_video_locked + hdmirx_tool_runner.sh "$temp_log" check_video_locked echo - hdmirx_output_checker.sh $temp_log verify_check_video_locked_output "video locked" + hdmirx_output_checker.sh "$temp_log" verify_check_video_locked_output "video locked" temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log get_video_info + hdmirx_tool_runner.sh "$temp_log" get_video_info echo expected_values="1920 1080 60" - hdmirx_output_checker.sh $temp_log verify_get_video_info_output "${expected_values}" + hdmirx_output_checker.sh "$temp_log" verify_get_video_info_output "${expected_values}" # Verify Audio info temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log check_audio_locked + hdmirx_tool_runner.sh "$temp_log" check_audio_locked echo - hdmirx_output_checker.sh $temp_log verify_check_audio_locked_output "video locked" + hdmirx_output_checker.sh "$temp_log" verify_check_audio_locked_output "video locked" temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log get_audio_info + hdmirx_tool_runner.sh "$temp_log" get_audio_info echo expected_values="24 bits, Channel Number [2], 48.0 kHz" - hdmirx_output_checker.sh $temp_log verify_get_audio_info_output "${expected_values}" + hdmirx_output_checker.sh "$temp_log" verify_get_audio_info_output "${expected_values}" _summary: Enable the HDMI RX functionaliy by hdmi_rx tool _description: This test will enable the functionaliy of HDMI RX by using hdmi_rx tool and the HDMI RX port still be connected. @@ -230,13 +229,13 @@ user: root command: EXIT=0 temp_log=$( mktemp ) - hdmirx_tool_runner.sh $temp_log start_observing + hdmirx_tool_runner.sh "$temp_log" start_observing echo expected_events='HDMI_RX_AUD_UNLOCK HDMI_RX_TIMING_UNLOCK HDMI_RX_PWR_5V_CHANGE HDMI_RX_PLUG_OUT' for event in $expected_events do echo "Checking event: $event ..." - if [ "$(grep -w $event $temp_log)" == "" ]; then + if [ "$(grep -w "$event" "$temp_log")" == "" ]; then echo "- FAIL: Unable to find the '$event' event" EXIT=1 else diff --git a/contrib/genio/units/thermal/jobs.pxu b/contrib/genio/units/thermal/jobs.pxu index 8fa3ebdb4..1e71a7d97 100644 --- a/contrib/genio/units/thermal/jobs.pxu +++ b/contrib/genio/units/thermal/jobs.pxu @@ -40,7 +40,7 @@ command: fi # Thermal is functional, dump the journal of previous boot temp_log=$( mktemp ) - journalctl -b -1 | tee $temp_log + journalctl -b -1 | tee "$temp_log" golden_message="reboot: HARDWARE PROTECTION shutdown (Temperature too high)" if ! grep -qw "$golden_message" "$temp_log" ; then echo "FAIL: no '$golden_message' message be found in journal"