Merge ~sylvain-pineau/plainbox-provider-checkbox:fix_bin_shellcheck_errors_2 into plainbox-provider-checkbox:master
- Git
- lp:~sylvain-pineau/plainbox-provider-checkbox
- fix_bin_shellcheck_errors_2
- Merge into master
Proposed by
Sylvain Pineau
Status: | Merged |
---|---|
Approved by: | Sylvain Pineau |
Approved revision: | 91f6c7ea3cb7c1c9c3b8434ab1db311821bfe44d |
Merged at revision: | b28bcb03c4188156f85c1cf61baea6000d992876 |
Proposed branch: | ~sylvain-pineau/plainbox-provider-checkbox:fix_bin_shellcheck_errors_2 |
Merge into: | plainbox-provider-checkbox:master |
Diff against target: |
766 lines (+125/-129) 19 files modified
bin/alsa_record_playback.sh (+4/-4) bin/audio_bluetooth_loopback_test.sh (+7/-6) bin/bluetooth_transfer_stress.sh (+6/-6) bin/broadband_info.sh (+1/-1) bin/check_is_laptop.sh (+4/-4) bin/connect_wireless.sh (+17/-19) bin/cycle_vts.sh (+2/-2) bin/disk_cpu_load.sh (+10/-12) bin/disk_read_performance_test.sh (+12/-12) bin/disk_stats_test.sh (+10/-10) bin/graphics_env.sh (+6/-6) bin/led_hdd_test.sh (+5/-3) bin/light_sensor_test.sh (+4/-4) bin/maas-version-check.sh (+4/-4) bin/network_configs.sh (+4/-4) bin/network_printer_test.sh (+7/-7) bin/network_wait.sh (+4/-5) bin/optical_write_test.sh (+17/-17) requirements/container-tests-provider-checkbox (+1/-3) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Checkbox Developers | Pending | ||
Review via email: mp+387969@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/bin/alsa_record_playback.sh b/bin/alsa_record_playback.sh |
2 | index e86d7d1..30b2fbd 100755 |
3 | --- a/bin/alsa_record_playback.sh |
4 | +++ b/bin/alsa_record_playback.sh |
5 | @@ -1,7 +1,7 @@ |
6 | #!/bin/sh |
7 | |
8 | -OUTPUT=`mktemp -d` |
9 | +OUTPUT=$(mktemp -d) |
10 | gst_pipeline_test.py -t 5 "autoaudiosrc ! audioconvert ! level name=recordlevel interval=10000000 ! audioconvert ! wavenc ! filesink location=$OUTPUT/test.wav" |
11 | -aplay $OUTPUT/test.wav |
12 | -rm $OUTPUT/test.wav |
13 | -rmdir $OUTPUT |
14 | +aplay "$OUTPUT"/test.wav |
15 | +rm "$OUTPUT"/test.wav |
16 | +rmdir "$OUTPUT" |
17 | diff --git a/bin/audio_bluetooth_loopback_test.sh b/bin/audio_bluetooth_loopback_test.sh |
18 | index 9661ec4..dac3699 100755 |
19 | --- a/bin/audio_bluetooth_loopback_test.sh |
20 | +++ b/bin/audio_bluetooth_loopback_test.sh |
21 | @@ -23,8 +23,8 @@ |
22 | # human validate that record/playback is working, human can speak into |
23 | # microphone and just ensure the speech can be heard instantly in the headset. |
24 | |
25 | -[ -x "`which pactl`" ] || exit 1 |
26 | -[ -x "`which pacat`" ] || exit 1 |
27 | +[ -x "$(command -v pactl)" ] || exit 1 |
28 | +[ -x "$(command -v pacat)" ] || exit 1 |
29 | |
30 | SINK=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_sink\.\)/\1/p') |
31 | SOURCE=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_source\.\)/\1/p') |
32 | @@ -33,6 +33,7 @@ SOURCE=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_source\.\)/\1/p') |
33 | if [ -n "$SINK" ] && [ -n "$SOURCE" ]; then |
34 | PLAYBACK_LOG=$(mktemp --tmpdir audio_bluetooth_loopback.XXXXX) |
35 | RECORD_LOG=$(mktemp --tmpdir audio_bluetooth_loopback.XXXXX) |
36 | + # shellcheck disable=SC2064 |
37 | trap "rm $PLAYBACK_LOG $RECORD_LOG" EXIT |
38 | # ensure we exit with failure if parec fails, and not with pacat |
39 | # --playback's error code |
40 | @@ -43,14 +44,14 @@ if [ -n "$SINK" ] && [ -n "$SOURCE" ]; then |
41 | # time out after 6 seconds, forcibly kill after 8 seconds if pacat didn't |
42 | # respond |
43 | echo "Recording and playing back, please speak into bluetooth microphone" |
44 | - timeout -k 8 6 pacat $LATENCY --record -v -d $SOURCE 2>$RECORD_LOG | \ |
45 | - pacat $LATENCY --playback -v -d $SINK 2>$PLAYBACK_LOG |
46 | + timeout -k 8 6 pacat $LATENCY --record -v -d "$SOURCE" 2>"$RECORD_LOG" | \ |
47 | + pacat $LATENCY --playback -v -d "$SINK" 2>"$PLAYBACK_LOG" |
48 | |
49 | echo "RECORD LOG" |
50 | - cat $RECORD_LOG |
51 | + cat "$RECORD_LOG" |
52 | echo "" |
53 | echo "PLAYBACK LOG" |
54 | - cat $PLAYBACK_LOG |
55 | + cat "$PLAYBACK_LOG" |
56 | else |
57 | echo "No bluetooth audio device found" |
58 | exit 1 |
59 | diff --git a/bin/bluetooth_transfer_stress.sh b/bin/bluetooth_transfer_stress.sh |
60 | index 36e4de7..1b86dd1 100755 |
61 | --- a/bin/bluetooth_transfer_stress.sh |
62 | +++ b/bin/bluetooth_transfer_stress.sh |
63 | @@ -31,18 +31,18 @@ DESTINATION=$(mktemp --tmpdir bluetooth-stress.XXXXXX) |
64 | REMOTE=$RANDOM |
65 | SIZEKB=10240 |
66 | echo "Creating ${SIZEKB}KB file to test transfer" |
67 | -dd if=/dev/urandom of=$ORIGIN count=$SIZEKB bs=1024 |
68 | -ORIGIN_SUM=$(sha256sum $ORIGIN | cut -f 1 -d ' ') |
69 | +dd if=/dev/urandom of="$ORIGIN" count=$SIZEKB bs=1024 |
70 | +ORIGIN_SUM=$(sha256sum "$ORIGIN" | cut -f 1 -d ' ') |
71 | set -o pipefail |
72 | echo "Sending file using Bluetooth" |
73 | -time obexftp -v -b $BTDEVADDR -o $REMOTE --put $ORIGIN 2>&1 | ansi_parser.py |
74 | +time obexftp -v -b "$BTDEVADDR" -o $REMOTE --put "$ORIGIN" 2>&1 | ansi_parser.py |
75 | sleep 5 |
76 | echo "Receiving file using Bluetooth" |
77 | -time obexftp -v -b $BTDEVADDR -o $DESTINATION --get $REMOTE 2>&1 | ansi_parser.py |
78 | +time obexftp -v -b "$BTDEVADDR" -o "$DESTINATION" --get $REMOTE 2>&1 | ansi_parser.py |
79 | # Now checksum destination and compare |
80 | -DESTINATION_SUM=$(sha256sum $DESTINATION | cut -f 1 -d ' ') |
81 | +DESTINATION_SUM=$(sha256sum "$DESTINATION" | cut -f 1 -d ' ') |
82 | # Clean up before reporting |
83 | -rm $ORIGIN $DESTINATION |
84 | +rm "$ORIGIN" "$DESTINATION" |
85 | if [ "$ORIGIN_SUM" = "$DESTINATION_SUM" ]; then |
86 | echo "Checksums match, file transfer succeeded" |
87 | exit 0 |
88 | diff --git a/bin/broadband_info.sh b/bin/broadband_info.sh |
89 | index aec2ccb..01ec7dc 100755 |
90 | --- a/bin/broadband_info.sh |
91 | +++ b/bin/broadband_info.sh |
92 | @@ -2,5 +2,5 @@ |
93 | |
94 | for i in $(mmcli --simple-status -L | \ |
95 | awk '/freedesktop\/ModemManager1\/Modem/ {print $1;}'); do |
96 | - mmcli -m $i |
97 | + mmcli -m "$i" |
98 | done |
99 | diff --git a/bin/check_is_laptop.sh b/bin/check_is_laptop.sh |
100 | index 5820a37..b197441 100755 |
101 | --- a/bin/check_is_laptop.sh |
102 | +++ b/bin/check_is_laptop.sh |
103 | @@ -2,15 +2,15 @@ |
104 | |
105 | # Establish the system type based on DMI info |
106 | TYPE=$(dmidecode -t 3 | awk '/Type:/ { print $2 }') |
107 | -echo "Type: " $TYPE |
108 | +echo "Type: " "$TYPE" |
109 | |
110 | BATTERY="NO" |
111 | -for device in `find /sys -name "type"` |
112 | +while IFS= read -r -d '' device |
113 | do |
114 | - if [ "$(cat $device)" == "Battery" ]; then |
115 | + if [ "$(cat "$device")" == "Battery" ]; then |
116 | BATTERY="YES" |
117 | fi |
118 | -done |
119 | +done < <(find /sys -name "type" -print0) |
120 | |
121 | echo "Battery: " $BATTERY |
122 | |
123 | diff --git a/bin/connect_wireless.sh b/bin/connect_wireless.sh |
124 | index e39f52c..fc696b2 100755 |
125 | --- a/bin/connect_wireless.sh |
126 | +++ b/bin/connect_wireless.sh |
127 | @@ -2,8 +2,7 @@ |
128 | |
129 | # Check nmcli version |
130 | NMCLI_GTE_0_9_10=0 |
131 | -nmcli general 2>&1 >/dev/null |
132 | -if [ $? -eq 0 ]; then |
133 | +if nmcli general > /dev/null 2>&1; then |
134 | NMCLI_GTE_0_9_10=1 |
135 | fi |
136 | |
137 | @@ -11,25 +10,23 @@ fi |
138 | conn='' |
139 | |
140 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then |
141 | - active_connection=$(nmcli -f SSID,ACTIVE dev wifi list | grep yes) |
142 | - if [ $? -eq 0 ]; then |
143 | - ap=$(echo $active_connection | awk -F\' '{print $2}') |
144 | - conn=$(nmcli -t -f UUID,TYPE,NAME con list | grep wireless | grep -e "$ap$" | head -n 1 | awk -F\: '{print $1}') |
145 | + if active_connection=$(nmcli -f SSID,ACTIVE dev wifi list | grep yes); then |
146 | + ap=$(echo "$active_connection" | awk -F\' '{print $2}') |
147 | + conn=$(nmcli -t -f UUID,TYPE,NAME con list | grep wireless | grep -e "$ap$" | head -n 1 | awk -F: '{print $1}') |
148 | else |
149 | - conn=$(nmcli -t -f UUID,TYPE con list | grep wireless | head -n 1 | awk -F\: '{print $1}') |
150 | + conn=$(nmcli -t -f UUID,TYPE con list | grep wireless | head -n 1 | awk -F: '{print $1}') |
151 | fi |
152 | else |
153 | - active_connection=$(nmcli -f SSID,ACTIVE dev wifi | grep yes) |
154 | - if [ $? -eq 0 ]; then |
155 | - ap=$(echo $active_connection | awk '{print $1}') |
156 | - conn=$(nmcli -t -f UUID,TYPE,NAME con show | grep wireless | grep -e "$ap$" | head -n 1 | awk -F\: '{print $1}') |
157 | + if active_connection=$(nmcli -f SSID,ACTIVE dev wifi | grep yes); then |
158 | + ap=$(echo "$active_connection" | awk '{print $1}') |
159 | + conn=$(nmcli -t -f UUID,TYPE,NAME con show | grep wireless | grep -e "$ap$" | head -n 1 | awk -F: '{print $1}') |
160 | else |
161 | - conn=$(nmcli -t -f UUID,TYPE con show | grep wireless | head -n 1 | awk -F\: '{print $1}') |
162 | + conn=$(nmcli -t -f UUID,TYPE con show | grep wireless | head -n 1 | awk -F: '{print $1}') |
163 | fi |
164 | fi |
165 | |
166 | #Strip trailing/leading whitespace |
167 | -conn=$(echo $conn |sed 's/^[ \t]*//;s/[ \t]*$//') |
168 | +conn=$(echo "$conn" |sed 's/^[ \t]*//;s/[ \t]*$//') |
169 | |
170 | # Find out if wireless is enabled |
171 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then |
172 | @@ -37,6 +34,7 @@ if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then |
173 | else |
174 | nmcli radio wifi | grep -q 'enabled' |
175 | fi |
176 | +# shellcheck disable=SC2181 |
177 | if [ $? -ne 0 ] |
178 | then |
179 | # Find out why |
180 | @@ -45,21 +43,21 @@ then |
181 | then |
182 | blkmessage='Your wireless may be hardware blocked. You may need |
183 | to use your wireless key/switch to re-enable it.' |
184 | - echo $blkmessage |
185 | + echo "$blkmessage" |
186 | fi |
187 | fi |
188 | |
189 | # Check if there's a connection already (wireless or otherwise) |
190 | -nmcli dev status | grep -q '\<connected\>' |
191 | -if [ $? -eq 0 ] |
192 | + |
193 | +if nmcli dev status | grep -q '\<connected\>'; |
194 | then |
195 | # Disconnect, pause for a short time |
196 | - for iface in `(nmcli -f GENERAL dev list 2>/dev/null || nmcli -f GENERAL dev show) | grep 'GENERAL.DEVICE' | awk '{print $2}'` |
197 | + for iface in $( (nmcli -f GENERAL dev list 2>/dev/null || nmcli -f GENERAL dev show) | grep 'GENERAL.DEVICE' | awk '{print $2}') |
198 | do |
199 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then |
200 | - nmcli dev disconnect iface $iface |
201 | + nmcli dev disconnect iface "$iface" |
202 | else |
203 | - nmcli dev disconnect $iface |
204 | + nmcli dev disconnect "$iface" |
205 | fi |
206 | done |
207 | sleep 2 |
208 | diff --git a/bin/cycle_vts.sh b/bin/cycle_vts.sh |
209 | index c5e1677..a42f8c1 100755 |
210 | --- a/bin/cycle_vts.sh |
211 | +++ b/bin/cycle_vts.sh |
212 | @@ -4,7 +4,7 @@ set -o errexit |
213 | |
214 | # NB: This script must be run with root privileges in order to have any effect! |
215 | |
216 | -CURRENT_VT=`/bin/fgconsole` |
217 | +CURRENT_VT=$(/bin/fgconsole) |
218 | |
219 | if [ "$CURRENT_VT" == "" ] |
220 | then |
221 | @@ -24,7 +24,7 @@ chvt "$CURRENT_VT" |
222 | sleep 2 |
223 | |
224 | # make sure we switched back |
225 | -END_VT=`/bin/fgconsole` |
226 | +END_VT=$(/bin/fgconsole) |
227 | if [ "$END_VT" -ne "$CURRENT_VT" ] |
228 | then |
229 | echo "didn't get back to the original VT" >&2 |
230 | diff --git a/bin/disk_cpu_load.sh b/bin/disk_cpu_load.sh |
231 | index adad55f..a4c45cb 100755 |
232 | --- a/bin/disk_cpu_load.sh |
233 | +++ b/bin/disk_cpu_load.sh |
234 | @@ -44,7 +44,6 @@ set -e |
235 | |
236 | get_params() { |
237 | disk_device="/dev/sda" |
238 | - short_device="sda" |
239 | verbose=0 |
240 | max_load=30 |
241 | xfer=4096 |
242 | @@ -59,9 +58,8 @@ get_params() { |
243 | --verbose) verbose=1 |
244 | ;; |
245 | *) disk_device="/dev/$1" |
246 | - disk_device=`echo $disk_device | sed "s/\/dev\/\/dev/\/dev/g"` |
247 | - short_device=$(echo $disk_device | sed "s/\/dev//g") |
248 | - if [ ! -b $disk_device ] ; then |
249 | + disk_device=$(echo "$disk_device" | sed "s/\/dev\/\/dev/\/dev/g") |
250 | + if [ ! -b "$disk_device" ] ; then |
251 | echo "Unknown block device \"$disk_device\"" |
252 | echo "Usage: $0 [ --max-load <load> ] [ --xfer <mebibytes> ]" |
253 | echo " [ device-file ]" |
254 | @@ -82,8 +80,8 @@ get_params() { |
255 | sum_array() { |
256 | local array=("${@}") |
257 | total=0 |
258 | - for i in ${array[@]}; do |
259 | - let total+=$i |
260 | + for i in "${array[@]}"; do |
261 | + (( total+=i )) |
262 | done |
263 | } # sum_array() |
264 | |
265 | @@ -98,10 +96,10 @@ sum_array() { |
266 | compute_cpu_load() { |
267 | local start_use |
268 | local end_use |
269 | - IFS=' ' read -r -a start_use <<< $1 |
270 | - IFS=' ' read -r -a end_use <<< $2 |
271 | + IFS=' ' read -r -a start_use <<< "$1" |
272 | + IFS=' ' read -r -a end_use <<< "$2" |
273 | local diff_idle |
274 | - let diff_idle=${end_use[3]}-${start_use[3]} |
275 | + (( diff_idle=end_use[3]-start_use[3] )) |
276 | |
277 | sum_array "${start_use[@]}" |
278 | local start_total=$total |
279 | @@ -110,8 +108,8 @@ compute_cpu_load() { |
280 | |
281 | local diff_total |
282 | local diff_used |
283 | - let diff_total=${end_total}-${start_total} |
284 | - let diff_used=$diff_total-$diff_idle |
285 | + (( diff_total=end_total-start_total )) |
286 | + (( diff_used=diff_total-diff_idle )) |
287 | |
288 | if [ "$verbose" == "1" ] ; then |
289 | echo "Start CPU time = $start_total" |
290 | @@ -136,7 +134,7 @@ get_params "$@" |
291 | retval=0 |
292 | echo "Testing CPU load when reading $xfer MiB from $disk_device" |
293 | echo "Maximum acceptable CPU load is $max_load" |
294 | -blockdev --flushbufs $disk_device |
295 | +blockdev --flushbufs "$disk_device" |
296 | start_load="$(grep "cpu " /proc/stat | tr -s " " | cut -d " " -f 2-)" |
297 | if [ "$verbose" == "1" ] ; then |
298 | echo "Beginning disk read...." |
299 | diff --git a/bin/disk_read_performance_test.sh b/bin/disk_read_performance_test.sh |
300 | index 7734543..28d0860 100755 |
301 | --- a/bin/disk_read_performance_test.sh |
302 | +++ b/bin/disk_read_performance_test.sh |
303 | @@ -6,17 +6,17 @@ |
304 | #Default to a lower bound of 15 MB/s |
305 | DEFAULT_BUF_READ=${DISK_READ_PERF:-15} |
306 | |
307 | -for disk in $@; do |
308 | +for disk in "$@"; do |
309 | |
310 | echo "Beginning $0 test for $disk" |
311 | echo "---------------------------------------------------" |
312 | |
313 | - disk_type=`udevadm info --name /dev/$disk --query property | grep "ID_BUS" | awk '{gsub(/ID_BUS=/," ")}{printf $1}'` |
314 | - dev_path=`udevadm info --name /dev/$disk --query property | grep "DEVPATH" | awk '{gsub(/DEVPATH=/," ")}{printf $1}'` |
315 | + disk_type=$(udevadm info --name /dev/"$disk" --query property | grep "ID_BUS" | awk '{gsub(/ID_BUS=/," ")}{printf $1}') |
316 | + dev_path=$(udevadm info --name /dev/"$disk" --query property | grep "DEVPATH" | awk '{gsub(/DEVPATH=/," ")}{printf $1}') |
317 | # /sys/block/$disk/queue/rotational was added with Linux 2.6.29. If file is |
318 | # not present, test below will fail & disk will be considered an HDD, not |
319 | # an SSD. |
320 | - rotational=`cat /sys/block/$disk/queue/rotational` |
321 | + rotational=$(cat /sys/block/"$disk"/queue/rotational) |
322 | if [[ $dev_path =~ dm ]]; then |
323 | disk_type="devmapper" |
324 | fi |
325 | @@ -47,10 +47,10 @@ for disk in $@; do |
326 | MIN_BUF_READ=7 |
327 | |
328 | # Increase MIN_BUF_READ if a USB3 device is plugged in a USB3 hub port |
329 | - if [[ $dev_path =~ ((.*usb[0-9]+).*\/)[0-9]-[0-9\.:\-]+\/.* ]]; then |
330 | - device_version=`cat '/sys/'${BASH_REMATCH[1]}'/version'` |
331 | - hub_port_version=`cat '/sys/'${BASH_REMATCH[2]}'/version'` |
332 | - if [ $(echo "$device_version >= 3.00"|bc -l) -eq 1 -a $(echo "$hub_port_version >= 3.00"|bc -l) -eq 1 ]; then |
333 | + if [[ $dev_path =~ ((.*usb[0-9]+).*\/)[0-9]-[0-9\.:-]+/.* ]]; then |
334 | + device_version=$(cat '/sys/'"${BASH_REMATCH[1]}"'/version') |
335 | + hub_port_version=$(cat '/sys/'"${BASH_REMATCH[2]}"'/version') |
336 | + if [ "$(echo "$device_version >= 3.00"|bc -l)" -eq 1 ] && [ "$(echo "$hub_port_version >= 3.00"|bc -l)" -eq 1 ]; then |
337 | MIN_BUF_READ=80 |
338 | fi |
339 | fi |
340 | @@ -73,8 +73,8 @@ for disk in $@; do |
341 | echo "Beginning hdparm timing runs" |
342 | echo "---------------------------------------------------" |
343 | |
344 | - for iteration in `seq 1 10`; do |
345 | - speed=`hdparm -t /dev/$disk 2>/dev/null | grep "Timing buffered disk reads" | awk -F"=" '{print $2}' | awk '{print $1}'` |
346 | + for iteration in $(seq 1 10); do |
347 | + speed=$(hdparm -t /dev/"$disk" 2>/dev/null | grep "Timing buffered disk reads" | awk -F"=" '{print $2}' | awk '{print $1}') |
348 | echo "INFO: Iteration $iteration: Detected speed is $speed MB/sec" |
349 | |
350 | if [ -z "$speed" ]; then |
351 | @@ -83,7 +83,7 @@ for disk in $@; do |
352 | fi |
353 | |
354 | speed=${speed/.*} |
355 | - if [ $speed -gt $max_speed ]; then |
356 | + if [ "$speed" -gt $max_speed ]; then |
357 | max_speed=$speed |
358 | fi |
359 | done |
360 | @@ -91,7 +91,7 @@ for disk in $@; do |
361 | echo "---------------------------------------------------" |
362 | echo "" |
363 | result=0 |
364 | - if [ $max_speed -gt $MIN_BUF_READ ]; then |
365 | + if [ "$max_speed" -gt "$MIN_BUF_READ" ]; then |
366 | echo "PASS: $disk Max Speed of $max_speed MB/sec is faster than Minimum Buffer Read Speed of $MIN_BUF_READ MB/sec" |
367 | else |
368 | echo "FAIL: $disk Max Speed of $max_speed MB/sec is slower than Minimum Buffer Read Speed of $MIN_BUF_READ MB/sec" |
369 | diff --git a/bin/disk_stats_test.sh b/bin/disk_stats_test.sh |
370 | index 60b48f5..41ef626 100755 |
371 | --- a/bin/disk_stats_test.sh |
372 | +++ b/bin/disk_stats_test.sh |
373 | @@ -16,7 +16,7 @@ check_return_code() { |
374 | shift |
375 | shift |
376 | for item in "$@"; do |
377 | - echo "output: "$item |
378 | + echo "output: ""$item" |
379 | done |
380 | fi |
381 | fi |
382 | @@ -29,19 +29,19 @@ fi |
383 | nvdimm="pmem" |
384 | if [ -z "${DISK##*$nvdimm*}" ];then |
385 | echo "Disk $DISK appears to be an NVDIMM, skipping" |
386 | - exit $STATUS |
387 | + exit "$STATUS" |
388 | fi |
389 | |
390 | #Check /proc/partitions, exit with fail if disk isn't found |
391 | -grep -w -q $DISK /proc/partitions |
392 | +grep -w -q "$DISK" /proc/partitions |
393 | check_return_code $? "Disk $DISK not found in /proc/partitions" |
394 | |
395 | #Next, check /proc/diskstats |
396 | -grep -w -q -m 1 $DISK /proc/diskstats |
397 | +grep -w -q -m 1 "$DISK" /proc/diskstats |
398 | check_return_code $? "Disk $DISK not found in /proc/diskstats" |
399 | |
400 | #Verify the disk shows up in /sys/block/ |
401 | -ls /sys/block | grep -w -q $DISK |
402 | +ls /sys/block/*"$DISK"* > /dev/null 2>&1 |
403 | check_return_code $? "Disk $DISK not found in /sys/block" |
404 | |
405 | #Verify there are stats in /sys/block/$DISK/stat |
406 | @@ -49,8 +49,8 @@ check_return_code $? "Disk $DISK not found in /sys/block" |
407 | check_return_code $? "stat is either empty or nonexistant in /sys/block/$DISK/" |
408 | |
409 | #Get some baseline stats for use later |
410 | -PROC_STAT_BEGIN=`grep -w -m 1 $DISK /proc/diskstats` |
411 | -SYS_STAT_BEGIN=`cat /sys/block/$DISK/stat` |
412 | +PROC_STAT_BEGIN=$(grep -w -m 1 "$DISK" /proc/diskstats) |
413 | +SYS_STAT_BEGIN=$(cat /sys/block/"$DISK"/stat) |
414 | |
415 | #Generate some disk activity using hdparm -t |
416 | hdparm -t "/dev/$DISK" 2&> /dev/null |
417 | @@ -59,8 +59,8 @@ hdparm -t "/dev/$DISK" 2&> /dev/null |
418 | sleep 5 |
419 | |
420 | #Make sure the stats have changed: |
421 | -PROC_STAT_END=`grep -w -m 1 $DISK /proc/diskstats` |
422 | -SYS_STAT_END=`cat /sys/block/$DISK/stat` |
423 | +PROC_STAT_END=$(grep -w -m 1 "$DISK" /proc/diskstats) |
424 | +SYS_STAT_END=$(cat /sys/block/"$DISK"/stat) |
425 | |
426 | [[ "$PROC_STAT_BEGIN" != "$PROC_STAT_END" ]] |
427 | check_return_code $? "Stats in /proc/diskstats did not change" \ |
428 | @@ -73,4 +73,4 @@ if [[ $STATUS -eq 0 ]]; then |
429 | echo "PASS: Finished testing stats for $DISK" |
430 | fi |
431 | |
432 | -exit $STATUS |
433 | +exit "$STATUS" |
434 | diff --git a/bin/graphics_env.sh b/bin/graphics_env.sh |
435 | index 5160ae6..b3ee60b 100755 |
436 | --- a/bin/graphics_env.sh |
437 | +++ b/bin/graphics_env.sh |
438 | @@ -12,15 +12,15 @@ INDEX=$2 |
439 | # We only want to set the DRI_PRIME env variable on systems with more than |
440 | # 1 GPU running the amdgpu/radeon drivers. |
441 | if [[ $DRIVER == "amdgpu" || $DRIVER == "radeon" ]]; then |
442 | - NB_GPU=`udev_resource.py -l VIDEO | grep -oP -m1 '\d+'` |
443 | - if [ $NB_GPU -gt 1 ]; then |
444 | - if [ $INDEX -gt 1 ]; then |
445 | + NB_GPU=$(udev_resource.py -l VIDEO | grep -oP -m1 '\d+') |
446 | + if [[ $NB_GPU -gt 1 ]]; then |
447 | + if [[ $INDEX -gt 1 ]]; then |
448 | # See https://wiki.archlinux.org/index.php/PRIME |
449 | echo "Setting up PRIME GPU offloading for AMD discrete GPU" |
450 | if ! cat /var/log/Xorg.0.log ~/.local/share/xorg/Xorg.0.log 2>&1 | grep -q DRI3; then |
451 | - PROVIDER_ID=`xrandr --listproviders | grep "Sink Output" | awk {'print $4'} | tail -1` |
452 | - SINK_ID=`xrandr --listproviders | grep "Source Output" | awk {'print $4'} | tail -1` |
453 | - xrandr --setprovideroffloadsink ${PROVIDER_ID} ${SINK_ID} |
454 | + PROVIDER_ID=$(xrandr --listproviders | grep "Sink Output" | awk '{print $4}' | tail -1) |
455 | + SINK_ID=$(xrandr --listproviders | grep "Source Output" | awk '{print $4}' | tail -1) |
456 | + xrandr --setprovideroffloadsink "${PROVIDER_ID}" "${SINK_ID}" |
457 | fi |
458 | export DRI_PRIME=1 |
459 | else |
460 | diff --git a/bin/led_hdd_test.sh b/bin/led_hdd_test.sh |
461 | index eac6ae2..f3f9808 100755 |
462 | --- a/bin/led_hdd_test.sh |
463 | +++ b/bin/led_hdd_test.sh |
464 | @@ -1,20 +1,22 @@ |
465 | #!/bin/bash |
466 | |
467 | TIMEOUT=3 |
468 | -TEMPFILE=`mktemp` |
469 | +TEMPFILE=$(mktemp) |
470 | |
471 | +# shellcheck disable=SC2064 |
472 | trap "rm $TEMPFILE" EXIT |
473 | |
474 | +# shellcheck disable=SC2034 |
475 | for i in $(seq $TIMEOUT); do |
476 | #launch background writer |
477 | - dd if=/dev/urandom of=$TEMPFILE bs=1024 oflag=direct & |
478 | + dd if=/dev/urandom of="$TEMPFILE" bs=1024 oflag=direct & |
479 | WRITE_PID=$! |
480 | echo "Writing..." |
481 | sleep 1 |
482 | kill $WRITE_PID |
483 | sync |
484 | echo "Reading..." |
485 | - dd if=$TEMPFILE of=/dev/null bs=1024 iflag=direct |
486 | + dd if="$TEMPFILE" of=/dev/null bs=1024 iflag=direct |
487 | done |
488 | |
489 | echo "OK, now exiting" |
490 | diff --git a/bin/light_sensor_test.sh b/bin/light_sensor_test.sh |
491 | index f413396..cb8fbe9 100755 |
492 | --- a/bin/light_sensor_test.sh |
493 | +++ b/bin/light_sensor_test.sh |
494 | @@ -20,18 +20,18 @@ echo -e "\e[92mwaiting for sensor to be covered......\e[0m" |
495 | sleep 3 |
496 | |
497 | #Output and print light sensor events 5 sec to light_sensor_test.log |
498 | -timeout 5 monitor-sensor | tee $PLAINBOX_SESSION_SHARE/light_sensor_test.log & |
499 | +timeout 5 monitor-sensor | tee "$PLAINBOX_SESSION_SHARE"/light_sensor_test.log & |
500 | |
501 | |
502 | #Print backlight value for 5 sec on the screen |
503 | for i in {1..10} |
504 | do |
505 | - echo "Current Backlight Percentage is:" $(gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.freedesktop.DBus.Properties.Get org.gnome.SettingsDaemon.Power.Screen Brightness)| tr -d '()<>,' |
506 | + echo "Current Backlight Percentage is:" "$(gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.freedesktop.DBus.Properties.Get org.gnome.SettingsDaemon.Power.Screen Brightness)"| tr -d '()<>,' |
507 | sleep 0.5 |
508 | done |
509 | |
510 | # Fail when the user didn't wave their hand and no events have been collected. |
511 | -if [[ $(cat $PLAINBOX_SESSION_SHARE/light_sensor_test.log | grep "Light changed" | wc -l) -lt 5 ]]; then |
512 | +if [[ $(grep -c "Light changed" "$PLAINBOX_SESSION_SHARE"/light_sensor_test.log) -lt 5 ]]; then |
513 | echo -e "\e[91mFAIL: Not enough data to be collect, Please rerun the test case and wave your hand around Light Sensor.\e[0m" |
514 | exit 1 |
515 | fi |
516 | @@ -40,7 +40,7 @@ fi |
517 | #Print 5 values of the Light sensor value form log file |
518 | for i in {1..5} |
519 | do |
520 | - echo "Ambient light sensor value " $i: `grep 'Light' $PLAINBOX_SESSION_SHARE/light_sensor_test.log | awk '{print $3}' | sed -n "$i"p` |
521 | + echo "Ambient light sensor value " $i: "$(grep 'Light' "$PLAINBOX_SESSION_SHARE"/light_sensor_test.log | awk '{print $3}' | sed -n "$i"p)" |
522 | done |
523 | exit 0 |
524 | |
525 | diff --git a/bin/maas-version-check.sh b/bin/maas-version-check.sh |
526 | index 678088a..6856354 100755 |
527 | --- a/bin/maas-version-check.sh |
528 | +++ b/bin/maas-version-check.sh |
529 | @@ -22,13 +22,13 @@ MIN_VERSION="2.0" |
530 | |
531 | # Is the file there? |
532 | if [ -s $MAAS_FILE ]; then |
533 | - maas_version=`cat $MAAS_FILE` |
534 | - echo $maas_version |
535 | + maas_version=$(cat $MAAS_FILE) |
536 | + echo "$maas_version" |
537 | else |
538 | echo "ERROR: This system does not appear to have been installed by MAAS" |
539 | - echo "ERROR: " $(ls -l $MAAS_FILE 2>&1) |
540 | + echo "ERROR: " "$(ls -l $MAAS_FILE 2>&1)" |
541 | exit 1 |
542 | fi |
543 | |
544 | #is the version appropriate |
545 | -exit `dpkg --compare-versions $maas_version "ge" $MIN_VERSION` |
546 | +exit "$(dpkg --compare-versions "$maas_version" "ge" $MIN_VERSION)" |
547 | diff --git a/bin/network_configs.sh b/bin/network_configs.sh |
548 | index b2fcc99..4fd354b 100755 |
549 | --- a/bin/network_configs.sh |
550 | +++ b/bin/network_configs.sh |
551 | @@ -1,13 +1,13 @@ |
552 | #!/bin/bash |
553 | |
554 | -if `grep -q "replaced by netplan" /etc/network/interfaces`; then |
555 | +if grep -q "replaced by netplan" /etc/network/interfaces; then |
556 | # Get our configs from netplan |
557 | for directory in "etc" "run" "lib"; do |
558 | - for configfile in `find /$directory/netplan -type f -name *.yaml`; do |
559 | + while IFS= read -r -d '' configfile; do |
560 | echo "Config File $configfile:" |
561 | - cat $configfile |
562 | + cat "$configfile" |
563 | echo "" |
564 | - done |
565 | + done < <(find /$directory/netplan -type f -name "*.yaml" -print0) |
566 | done |
567 | else |
568 | # get configs from Network Manager instead |
569 | diff --git a/bin/network_printer_test.sh b/bin/network_printer_test.sh |
570 | index 19d98d2..2633b6c 100755 |
571 | --- a/bin/network_printer_test.sh |
572 | +++ b/bin/network_printer_test.sh |
573 | @@ -19,7 +19,7 @@ while [ $# -gt 0 ] |
574 | do |
575 | case "$1" in |
576 | -p) |
577 | - if echo ${2} | grep -q -c '^-'; then |
578 | + if echo "${2}" | grep -q -c '^-'; then |
579 | usage |
580 | exit 1 |
581 | fi |
582 | @@ -27,7 +27,7 @@ do |
583 | shift |
584 | ;; |
585 | -s) |
586 | - if echo ${2} | grep -q -c '^-'; then |
587 | + if echo "${2}" | grep -q -c '^-'; then |
588 | usage |
589 | exit 1 |
590 | fi |
591 | @@ -42,16 +42,16 @@ do |
592 | shift |
593 | done |
594 | |
595 | -if [ -z $server ]; then |
596 | +if [ -z "$server" ]; then |
597 | echo "Nothing to do with no server defined. (See $0 --usage)" |
598 | exit 0 |
599 | fi |
600 | |
601 | printer=${printer:-PDF} |
602 | |
603 | -lpadmin -E -v ipp://${server}/printers/${printer} |
604 | -cupsenable ${printer} |
605 | -cupsaccept ${printer} |
606 | +lpadmin -E -v ipp://"${server}"/printers/"${printer}" |
607 | +cupsenable "${printer}" |
608 | +cupsaccept "${printer}" |
609 | |
610 | -lsb_release -a | lp -t "lsb_release" -d ${printer} |
611 | +lsb_release -a | lp -t "lsb_release" -d "${printer}" |
612 | |
613 | diff --git a/bin/network_wait.sh b/bin/network_wait.sh |
614 | index f0637d0..16d474c 100755 |
615 | --- a/bin/network_wait.sh |
616 | +++ b/bin/network_wait.sh |
617 | @@ -2,8 +2,7 @@ |
618 | |
619 | x=1 |
620 | while true; do |
621 | - state=$(/usr/bin/nmcli -t -f STATE nm 2>/dev/null) |
622 | - if [[ $? != 0 ]]; then |
623 | + if ! state=$(/usr/bin/nmcli -t -f STATE nm 2>/dev/null); then |
624 | state=$(/usr/bin/nmcli -t -f STATE general 2>/dev/null) |
625 | rc=$? |
626 | if [[ $rc != 0 ]]; then |
627 | @@ -11,13 +10,13 @@ while true; do |
628 | fi |
629 | fi |
630 | if [ "$state" = "connected" ]; then |
631 | - echo $state |
632 | + echo "$state" |
633 | exit 0 |
634 | fi |
635 | |
636 | - x=$(($x + 1)) |
637 | + x=$((x + 1)) |
638 | if [ $x -gt 12 ]; then |
639 | - echo $state |
640 | + echo "$state" |
641 | exit 1 |
642 | fi |
643 | |
644 | diff --git a/bin/optical_write_test.sh b/bin/optical_write_test.sh |
645 | index b127667..ca1dc79 100755 |
646 | --- a/bin/optical_write_test.sh |
647 | +++ b/bin/optical_write_test.sh |
648 | @@ -11,7 +11,7 @@ create_working_dirs(){ |
649 | # First, create the temp dir and cd there |
650 | echo "Creating Temp directory and moving there ..." |
651 | mkdir -p $TEMP_DIR || return 1 |
652 | - cd $TEMP_DIR |
653 | + cd $TEMP_DIR || return 1 |
654 | echo "Now working in $PWD ..." |
655 | } |
656 | |
657 | @@ -26,18 +26,18 @@ generate_md5(){ |
658 | # Generate the md5sum |
659 | echo "Generating md5sums of sample files ..." |
660 | CUR_DIR=$PWD |
661 | - cd $SAMPLE_FILE |
662 | - md5sum * > $TEMP_DIR/$MD5SUM_FILE |
663 | + cd $SAMPLE_FILE || return 1 |
664 | + md5sum -- * > $TEMP_DIR/$MD5SUM_FILE |
665 | # Check the sums for paranoia sake |
666 | check_md5 $TEMP_DIR/$MD5SUM_FILE |
667 | rt=$? |
668 | - cd $CUR_DIR |
669 | + cd "$CUR_DIR" || exit 1 |
670 | return $rt |
671 | } |
672 | |
673 | check_md5(){ |
674 | echo "Checking md5sums ..." |
675 | - md5sum -c $1 |
676 | + md5sum -c "$1" |
677 | return $? |
678 | } |
679 | |
680 | @@ -55,10 +55,10 @@ burn_iso(){ |
681 | echo "Beginning image burn ..." |
682 | if [ "$OPTICAL_TYPE" == 'cd' ] |
683 | then |
684 | - wodim -eject dev=$OPTICAL_DRIVE $ISO_NAME |
685 | + wodim -eject dev="$OPTICAL_DRIVE" $ISO_NAME |
686 | elif [ "$OPTICAL_TYPE" == 'dvd' ] || [ "$OPTICAL_TYPE" == 'bd' ] |
687 | then |
688 | - growisofs -dvd-compat -Z $OPTICAL_DRIVE=$ISO_NAME |
689 | + growisofs -dvd-compat -Z "$OPTICAL_DRIVE=$ISO_NAME" |
690 | else |
691 | echo "Invalid type specified '$OPTICAL_TYPE'" |
692 | exit 1 |
693 | @@ -76,9 +76,9 @@ check_disk(){ |
694 | echo "Waiting up to 5 minutes for drive to be mounted ..." |
695 | while true; do |
696 | sleep $INTERVAL |
697 | - SLEEP_COUNT=`expr $SLEEP_COUNT + $INTERVAL` |
698 | + SLEEP_COUNT=$((SLEEP_COUNT + INTERVAL)) |
699 | |
700 | - mount $OPTICAL_DRIVE 2>&1 |egrep -q "already mounted" |
701 | + mount "$OPTICAL_DRIVE" 2>&1 | grep -E -q "already mounted" |
702 | rt=$? |
703 | if [ $rt -eq 0 ]; then |
704 | echo "Drive appears to be mounted now" |
705 | @@ -96,8 +96,8 @@ check_disk(){ |
706 | |
707 | echo "Deleting original data files ..." |
708 | rm -rf $SAMPLE_FILE |
709 | - if [ -n "$(mount | grep $OPTICAL_DRIVE)" ]; then |
710 | - MOUNT_PT=$(mount | grep $OPTICAL_DRIVE | awk '{print $3}') |
711 | + if mount | grep -q "$OPTICAL_DRIVE"; then |
712 | + MOUNT_PT=$(mount | grep "$OPTICAL_DRIVE" | awk '{print $3}') |
713 | echo "Disk is mounted to $MOUNT_PT" |
714 | else |
715 | echo "Attempting best effort to mount $OPTICAL_DRIVE on my own" |
716 | @@ -105,7 +105,7 @@ check_disk(){ |
717 | echo "Creating temp mount point: $MOUNT_PT ..." |
718 | mkdir $MOUNT_PT |
719 | echo "Mounting disk to mount point ..." |
720 | - mount $OPTICAL_DRIVE $MOUNT_PT |
721 | + mount "$OPTICAL_DRIVE" $MOUNT_PT |
722 | rt=$? |
723 | if [ $rt -ne 0 ]; then |
724 | echo "ERROR: Unable to re-mount $OPTICAL_DRIVE!" >&2 |
725 | @@ -120,24 +120,24 @@ check_disk(){ |
726 | |
727 | cleanup(){ |
728 | echo "Moving back to original location" |
729 | - cd $START_DIR |
730 | + cd "$START_DIR" || exit 1 |
731 | echo "Now residing in $PWD" |
732 | echo "Cleaning up ..." |
733 | umount "$MOUNT_PT" |
734 | rm -fr $TEMP_DIR |
735 | echo "Ejecting spent media ..." |
736 | - eject $OPTICAL_DRIVE |
737 | + eject "$OPTICAL_DRIVE" |
738 | } |
739 | |
740 | failed(){ |
741 | - echo $1 |
742 | + echo "$1" |
743 | echo "Attempting to clean up ..." |
744 | cleanup |
745 | exit 1 |
746 | } |
747 | |
748 | -if [ -e $1 ]; then |
749 | - OPTICAL_DRIVE=$(readlink -f $1) |
750 | +if [ -e "$1" ]; then |
751 | + OPTICAL_DRIVE=$(readlink -f "$1") |
752 | else |
753 | OPTICAL_DRIVE='/dev/sr0' |
754 | fi |
755 | diff --git a/requirements/container-tests-provider-checkbox b/requirements/container-tests-provider-checkbox |
756 | index 7aca1bc..7f8a0ba 100755 |
757 | --- a/requirements/container-tests-provider-checkbox |
758 | +++ b/requirements/container-tests-provider-checkbox |
759 | @@ -17,6 +17,4 @@ git clone git://git.launchpad.net/plainbox-provider-resource $TMPDIR/plainbox-pr |
760 | python3 $TMPDIR/plainbox-provider-resource/manage.py develop --force |
761 | |
762 | ./manage.py validate |
763 | -./manage.py test -u |
764 | -./manage.py test -f |
765 | -./manage.py test -i |
766 | +./manage.py test |