From 94e496c77e5750981d943446be8bfc94eb0a2423 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sun, 1 Dec 2024 14:01:10 +0000 Subject: [PATCH] Raise an error if variables are not defined. --- ...splay_length_at_magnitude_boundary_-_Bytes.test | 4 ++-- ...isplay_length_at_magnitude_boundary_-_Rate.test | 3 ++- tests/Bug_-_Install_all_files.test | 4 ++-- tests/Display_-_--average-rate.test | 4 ++-- tests/Display_-_--bits.test | 4 ++-- tests/Display_-_--buffer-percent.test | 4 ++-- tests/Display_-_--bytes.test | 4 ++-- tests/Display_-_--eta_-_plausible_values.test | 4 ++-- tests/Display_-_--fineta_-_plausible_values.test | 4 ++-- tests/Display_-_--last-written.test | 4 ++-- tests/Display_-_--numeric.test | 4 ++-- tests/Display_-_--numeric_--bytes.test | 4 ++-- tests/Display_-_--numeric_--bytes_--line-mode.test | 5 +++-- tests/Display_-_--numeric_--timer.test | 4 ++-- tests/Display_-_--progress_-_basic_movement.test | 4 ++-- tests/Display_-_--progress_-_increasing.test | 4 ++-- tests/Display_-_--quiet.test | 4 ++-- ...Display_-_--rate_-_displayed_value_changes.test | 4 ++-- ...isplay_-_--timer_-_displayed_value_changes.test | 4 ++-- tests/General_-_--pidfile.test | 4 ++-- tests/General_-_--size_argument_handling.test | 3 +-- tests/Integrity_-_Basic.test | 3 +-- tests/Integrity_-_Binary_data.test | 5 +++-- tests/Integrity_-_From_bursty_source.test | 5 +++-- tests/Integrity_-_Large_file_support.test | 5 +++-- tests/Integrity_-_On_output_pipe_close.test | 3 +-- tests/Integrity_-_When_adjusted_remotely.test | 7 +++++-- tests/Memory_safety_-_Basic.test | 8 ++++++-- tests/Memory_safety_-_Remote_control_receiver.test | 8 ++++++-- tests/Memory_safety_-_Remote_control_sender.test | 8 ++++++-- tests/Memory_safety_-_Watchfd.test | 14 ++++++++++---- tests/Modifiers_-_--direct-io.test | 5 +++-- tests/Modifiers_-_--force.test | 4 ++-- tests/Modifiers_-_--interval.test | 4 ++-- tests/Modifiers_-_--line-mode.test | 4 ++-- tests/Modifiers_-_--size.test | 4 ++-- tests/Modifiers_-_--size_from_file_size.test | 5 +++-- tests/Modifiers_-_--sync.test | 5 +++-- tests/Terminal_-_Detect_width.test | 5 +++-- tests/Transfer_-_--rate-limit.test | 3 +-- tests/Transfer_-_--remote.test | 7 +++++-- tests/Transfer_-_--stop-at-size.test | 5 +++-- tests/Watchfd_-_Multiple_descriptors.test | 6 ++++-- tests/Watchfd_-_Single_descriptor.test | 5 +++-- tests/run-valgrind.sh | 4 ++-- tests/test-env.sh | 2 ++ 46 files changed, 126 insertions(+), 91 deletions(-) diff --git a/tests/Bug_-_Display_length_at_magnitude_boundary_-_Bytes.test b/tests/Bug_-_Display_length_at_magnitude_boundary_-_Bytes.test index 05cbe85..46a8fcb 100755 --- a/tests/Bug_-_Display_length_at_magnitude_boundary_-_Bytes.test +++ b/tests/Bug_-_Display_length_at_magnitude_boundary_-_Bytes.test @@ -4,8 +4,8 @@ # 1MiB, described here: # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586763 -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Transfer 1500kB of data in a bursty fashion. # diff --git a/tests/Bug_-_Display_length_at_magnitude_boundary_-_Rate.test b/tests/Bug_-_Display_length_at_magnitude_boundary_-_Rate.test index 373c0c1..096fc5c 100755 --- a/tests/Bug_-_Display_length_at_magnitude_boundary_-_Rate.test +++ b/tests/Bug_-_Display_length_at_magnitude_boundary_-_Rate.test @@ -4,7 +4,8 @@ # but for rate, not bytes transferred. # Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Transfer 1500kB of data in a bursty fashion. # diff --git a/tests/Bug_-_Install_all_files.test b/tests/Bug_-_Install_all_files.test index 1d34adb..5158254 100755 --- a/tests/Bug_-_Install_all_files.test +++ b/tests/Bug_-_Install_all_files.test @@ -2,8 +2,8 @@ # # Test that "make install" installs the expected minimum set of files. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" makeDir="${testSubject%/*}" if ! test -d "${makeDir}"; then diff --git a/tests/Display_-_--average-rate.test b/tests/Display_-_--average-rate.test index a920473..bd9bb6c 100755 --- a/tests/Display_-_--average-rate.test +++ b/tests/Display_-_--average-rate.test @@ -3,8 +3,8 @@ # Check that the average transfer rate counter changes, but not more than it # should. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Transfer 210 bytes as 100 bytes, a 1 second gap, 110 bytes, and another 1 # second gap. diff --git a/tests/Display_-_--bits.test b/tests/Display_-_--bits.test index 0011d78..7a3c8ec 100755 --- a/tests/Display_-_--bits.test +++ b/tests/Display_-_--bits.test @@ -2,8 +2,8 @@ # # Check that the byte counter counts in bits when --bits is selected. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" dd if=/dev/zero bs=100 count=1 2>/dev/null \ | "${testSubject}" -f -b -8 >/dev/null 2>"${workFile1}" diff --git a/tests/Display_-_--buffer-percent.test b/tests/Display_-_--buffer-percent.test index 0d5741b..d318770 100755 --- a/tests/Display_-_--buffer-percent.test +++ b/tests/Display_-_--buffer-percent.test @@ -2,8 +2,8 @@ # # Check that "--buffer-percent" displays correctly. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # The output should show 100% and 0% as the buffer initially fills up due to # there being nowhere to write it to, and then empties. diff --git a/tests/Display_-_--bytes.test b/tests/Display_-_--bytes.test index fde7428..5581e5f 100755 --- a/tests/Display_-_--bytes.test +++ b/tests/Display_-_--bytes.test @@ -2,8 +2,8 @@ # # Check that the byte counter counts. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" dd if=/dev/zero bs=100 count=1 2>/dev/null \ | "${testSubject}" -f -b >/dev/null 2>"${workFile1}" diff --git a/tests/Display_-_--eta_-_plausible_values.test b/tests/Display_-_--eta_-_plausible_values.test index df69cf0..a04c87a 100755 --- a/tests/Display_-_--eta_-_plausible_values.test +++ b/tests/Display_-_--eta_-_plausible_values.test @@ -2,8 +2,8 @@ # # Check that the estimated time counter counts. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" dd if=/dev/zero bs=100 count=1 2>/dev/null \ | "${testSubject}" -f -e -s 100 -i 0.1 -L 25 >/dev/null 2>"${workFile1}" diff --git a/tests/Display_-_--fineta_-_plausible_values.test b/tests/Display_-_--fineta_-_plausible_values.test index 9d7ba84..90bab87 100755 --- a/tests/Display_-_--fineta_-_plausible_values.test +++ b/tests/Display_-_--fineta_-_plausible_values.test @@ -2,8 +2,8 @@ # # Check that the estimated time counter can show the end time of day. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" dd if=/dev/zero bs=100 count=1 2>/dev/null \ | "${testSubject}" -f -I -s 100 -i 0.1 -L 25 >/dev/null 2>"${workFile1}" diff --git a/tests/Display_-_--last-written.test b/tests/Display_-_--last-written.test index c73324e..83d8073 100755 --- a/tests/Display_-_--last-written.test +++ b/tests/Display_-_--last-written.test @@ -2,8 +2,8 @@ # # Check that "--last-written" works. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Slowly write a sequence of numbers (rate-limited by another `pv' instance) # and watch the "--last-written" output of a second `pv' instance to make diff --git a/tests/Display_-_--numeric.test b/tests/Display_-_--numeric.test index 2177c8a..d77b326 100755 --- a/tests/Display_-_--numeric.test +++ b/tests/Display_-_--numeric.test @@ -2,8 +2,8 @@ # # Check that numeric output outputs some percentages. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for # around 10 output lines. diff --git a/tests/Display_-_--numeric_--bytes.test b/tests/Display_-_--numeric_--bytes.test index a3b5983..89795c3 100755 --- a/tests/Display_-_--numeric_--bytes.test +++ b/tests/Display_-_--numeric_--bytes.test @@ -3,8 +3,8 @@ # Check that numeric output gives a byte count instead of a percentage when # used with -b. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Process 500 bytes at 500 bytes per second, updating every 0.1 seconds for # around 10 output lines. diff --git a/tests/Display_-_--numeric_--bytes_--line-mode.test b/tests/Display_-_--numeric_--bytes_--line-mode.test index 4690bcf..4911d7f 100755 --- a/tests/Display_-_--numeric_--bytes_--line-mode.test +++ b/tests/Display_-_--numeric_--bytes_--line-mode.test @@ -3,8 +3,9 @@ # Check that numeric output shows line counts instead of percentages, when # used in line mode together with bytes mode. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # Pass through 100 lines. # diff --git a/tests/Display_-_--numeric_--timer.test b/tests/Display_-_--numeric_--timer.test index 6f6638e..d425c55 100755 --- a/tests/Display_-_--numeric_--timer.test +++ b/tests/Display_-_--numeric_--timer.test @@ -2,8 +2,8 @@ # # Check that numeric output gives a timer when used with -t. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for # around 10 output lines. diff --git a/tests/Display_-_--progress_-_basic_movement.test b/tests/Display_-_--progress_-_basic_movement.test index 154a2bb..e4a4a03 100755 --- a/tests/Display_-_--progress_-_basic_movement.test +++ b/tests/Display_-_--progress_-_basic_movement.test @@ -2,8 +2,8 @@ # # Check that the progress bar moves when data is coming in. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" dd if=/dev/zero bs=100 count=1 2>/dev/null \ | "${testSubject}" -f -p -i 0.1 -L 500 >/dev/null 2>"${workFile1}" diff --git a/tests/Display_-_--progress_-_increasing.test b/tests/Display_-_--progress_-_increasing.test index 7bcb343..ab54e1a 100755 --- a/tests/Display_-_--progress_-_increasing.test +++ b/tests/Display_-_--progress_-_increasing.test @@ -2,8 +2,8 @@ # # Check that the progress bar increases in size when data is coming in. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" dd if=/dev/zero bs=100 count=1 2>/dev/null \ | "${testSubject}" -f -p -i 0.1 -L 50 -s 100 >/dev/null 2>"${workFile1}" diff --git a/tests/Display_-_--quiet.test b/tests/Display_-_--quiet.test index 245fd84..6981bb1 100755 --- a/tests/Display_-_--quiet.test +++ b/tests/Display_-_--quiet.test @@ -2,8 +2,8 @@ # # Check that the -q option shuts everything up. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" dd if=/dev/zero bs=1000 count=5 2>/dev/null \ | "${testSubject}" -f -q -i 0.1 -L 5000 >/dev/null 2>"${workFile1}" diff --git a/tests/Display_-_--rate_-_displayed_value_changes.test b/tests/Display_-_--rate_-_displayed_value_changes.test index b1c84cc..178e341 100755 --- a/tests/Display_-_--rate_-_displayed_value_changes.test +++ b/tests/Display_-_--rate_-_displayed_value_changes.test @@ -2,8 +2,8 @@ # # Check that the transfer rate counter changes. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Transfer 200 bytes as two 100-byte blocks with a 2-second gap between. # diff --git a/tests/Display_-_--timer_-_displayed_value_changes.test b/tests/Display_-_--timer_-_displayed_value_changes.test index b7f89cb..d006601 100755 --- a/tests/Display_-_--timer_-_displayed_value_changes.test +++ b/tests/Display_-_--timer_-_displayed_value_changes.test @@ -2,8 +2,8 @@ # # Check that the elapsed time counter does count up. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Transfer a zero amount of data, but take 3 seconds to do it. # diff --git a/tests/General_-_--pidfile.test b/tests/General_-_--pidfile.test index 7c6effb..e19e6ce 100755 --- a/tests/General_-_--pidfile.test +++ b/tests/General_-_--pidfile.test @@ -3,8 +3,8 @@ # Check that the process ID can be written to a file as described in the # manual. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Check we can run "kill -s 0". if ! kill -s 0 $$ >/dev/null 2>&1; then diff --git a/tests/General_-_--size_argument_handling.test b/tests/General_-_--size_argument_handling.test index 2bf227f..8fbe42b 100755 --- a/tests/General_-_--size_argument_handling.test +++ b/tests/General_-_--size_argument_handling.test @@ -2,8 +2,7 @@ # # Check that size arguments are processed correctly. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}" +true "${testSubject:?not set - call this from 'make check'}" # Pass size argument $1 and check that the last reported number is $2. checkSizeArgument () { diff --git a/tests/Integrity_-_Basic.test b/tests/Integrity_-_Basic.test index faec203..ba81d2f 100755 --- a/tests/Integrity_-_Basic.test +++ b/tests/Integrity_-_Basic.test @@ -2,8 +2,7 @@ # # Check that data can be just passed straight through. -# Dummy assignment for "shellcheck". -testSubject="${testSubject:-false}" +true "${testSubject:?not set - call this from 'make check'}" inputString="TESTING" outputString=$(printf "%s" "${inputString}" | "${testSubject}" 2>/dev/null) || { echo "unexpected failure code"; exit 1; } diff --git a/tests/Integrity_-_Binary_data.test b/tests/Integrity_-_Binary_data.test index 664e7f0..e89e2ff 100755 --- a/tests/Integrity_-_Binary_data.test +++ b/tests/Integrity_-_Binary_data.test @@ -3,8 +3,9 @@ # Transfer a large chunk of data through pv and check data correctness # afterwards. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # generate some data dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null diff --git a/tests/Integrity_-_From_bursty_source.test b/tests/Integrity_-_From_bursty_source.test index 03e1991..dd5aef3 100755 --- a/tests/Integrity_-_From_bursty_source.test +++ b/tests/Integrity_-_From_bursty_source.test @@ -3,8 +3,9 @@ # Transfer a large chunk of data through pv using pipes, sending it in a # bursty fashion, and check data correctness afterwards. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # generate some data dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null diff --git a/tests/Integrity_-_Large_file_support.test b/tests/Integrity_-_Large_file_support.test index cae495e..636b306 100755 --- a/tests/Integrity_-_Large_file_support.test +++ b/tests/Integrity_-_Large_file_support.test @@ -2,8 +2,9 @@ # # Make sure that files larger than 2GB are supported. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # Check there is enough free space for this test. workFile1Dir="${workFile1%/*}" diff --git a/tests/Integrity_-_On_output_pipe_close.test b/tests/Integrity_-_On_output_pipe_close.test index 206e24d..ba026ef 100755 --- a/tests/Integrity_-_On_output_pipe_close.test +++ b/tests/Integrity_-_On_output_pipe_close.test @@ -2,8 +2,7 @@ # # Check that there is no SIGPIPE or dropped data on bigger data transfers. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}" +true "${testSubject:?not set - call this from 'make check'}" # We nead GNU head. On some platforms it is named ghead instead of head. HEAD="head" diff --git a/tests/Integrity_-_When_adjusted_remotely.test b/tests/Integrity_-_When_adjusted_remotely.test index 4f0821f..bc76d9d 100755 --- a/tests/Integrity_-_When_adjusted_remotely.test +++ b/tests/Integrity_-_When_adjusted_remotely.test @@ -3,8 +3,11 @@ # Try repeatedly messaging a transfer process, and make sure the data stays # intact. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" +true "${workFile3:?not set - call this from 'make check'}" +true "${workFile4:?not set - call this from 'make check'}" # Do nothing if it is not supported. if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then diff --git a/tests/Memory_safety_-_Basic.test b/tests/Memory_safety_-_Basic.test index 35493e9..380606b 100755 --- a/tests/Memory_safety_-_Basic.test +++ b/tests/Memory_safety_-_Basic.test @@ -3,8 +3,12 @@ # Run valgrind's memory checker against a process using various different # transfer options. -# Dummy assignments for "shellcheck". -sourcePath="${sourcePath:-.}"; testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}" +true "${sourcePath:?not set - call this from 'make check'}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" +true "${workFile3:?not set - call this from 'make check'}" +true "${workFile4:?not set - call this from 'make check'}" # Load the valgrind function. . "${sourcePath}/tests/run-valgrind.sh" diff --git a/tests/Memory_safety_-_Remote_control_receiver.test b/tests/Memory_safety_-_Remote_control_receiver.test index 5be8eba..0b9e18c 100755 --- a/tests/Memory_safety_-_Remote_control_receiver.test +++ b/tests/Memory_safety_-_Remote_control_receiver.test @@ -2,8 +2,12 @@ # # Run valgrind's memory checker while receiving remote control commands. -# Dummy assignments for "shellcheck". -sourcePath="${sourcePath:-.}"; testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}" +true "${sourcePath:?not set - call this from 'make check'}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" +true "${workFile3:?not set - call this from 'make check'}" +true "${workFile4:?not set - call this from 'make check'}" # Do nothing if it is not supported. if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then diff --git a/tests/Memory_safety_-_Remote_control_sender.test b/tests/Memory_safety_-_Remote_control_sender.test index fadad84..2ab90eb 100755 --- a/tests/Memory_safety_-_Remote_control_sender.test +++ b/tests/Memory_safety_-_Remote_control_sender.test @@ -3,8 +3,12 @@ # Run valgrind's memory checker while using remote control to control # another process. -# Dummy assignments for "shellcheck". -sourcePath="${sourcePath:-.}"; testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}" +true "${sourcePath:?not set - call this from 'make check'}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" +true "${workFile3:?not set - call this from 'make check'}" +true "${workFile4:?not set - call this from 'make check'}" # Do nothing if it is not supported. if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then diff --git a/tests/Memory_safety_-_Watchfd.test b/tests/Memory_safety_-_Watchfd.test index bb52bde..6386628 100755 --- a/tests/Memory_safety_-_Watchfd.test +++ b/tests/Memory_safety_-_Watchfd.test @@ -3,8 +3,12 @@ # Run valgrind's memory checker against a process using the --watchfd # option. -# Dummy assignments for "shellcheck". -sourcePath="${sourcePath:-.}"; testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}" +true "${sourcePath:?not set - call this from 'make check'}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" +true "${workFile3:?not set - call this from 'make check'}" +true "${workFile4:?not set - call this from 'make check'}" # Load the valgrind function. . "${sourcePath}/tests/run-valgrind.sh" @@ -27,7 +31,8 @@ fi # Check "--watchfd PID:FD". # See the "Watchfd" tests for more detail. seq 1 100 > "${workFile1}" -(export line; sleep 1; read -r line; sleep 1; read -r line; sleep 1) <"${workFile1}" & +# shellcheck disable=SC2030 +(sleep 1; read -r line; sleep 1; read -r line; sleep 1) <"${workFile1}" & pid=$! sleep 0.1 { runWithValgrind -d "${pid}:0" -f -i 0.5 >/dev/null 2>&1; } 4>&1 || exit 1 @@ -35,8 +40,8 @@ sleep 0.1 # Check "--watchfd PID". seq 1 100 > "${workFile1}" seq 1 300 > "${workFile2}" +# shellcheck disable=SC2030 ( -export line sleep 1 read -r line exec 9<"${workFile2}" @@ -45,6 +50,7 @@ exec 8<"${workFile1}" exec 7/dev/null diff --git a/tests/Modifiers_-_--force.test b/tests/Modifiers_-_--force.test index 6cfafbe..50f5c39 100755 --- a/tests/Modifiers_-_--force.test +++ b/tests/Modifiers_-_--force.test @@ -3,8 +3,8 @@ # Check that the progress bar is produced when "--force" is used, and is not # when it is not, providing stderr is a file. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" dd if=/dev/zero bs=100 count=1 2>/dev/null \ | "${testSubject}" -f -p -i 0.1 -L 100 >/dev/null 2>"${workFile1}" diff --git a/tests/Modifiers_-_--interval.test b/tests/Modifiers_-_--interval.test index e94728e..a94e520 100755 --- a/tests/Modifiers_-_--interval.test +++ b/tests/Modifiers_-_--interval.test @@ -2,8 +2,8 @@ # # Check that the update interval can be set. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" sleep 1 | "${testSubject}" -f -i 0.1 >/dev/null 2>"${workFile1}" diff --git a/tests/Modifiers_-_--line-mode.test b/tests/Modifiers_-_--line-mode.test index 6cebd04..7c1ca2a 100755 --- a/tests/Modifiers_-_--line-mode.test +++ b/tests/Modifiers_-_--line-mode.test @@ -2,8 +2,8 @@ # # Check that line mode counts lines instead of bytes. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Pass through 100 lines. # diff --git a/tests/Modifiers_-_--size.test b/tests/Modifiers_-_--size.test index fefc995..ec82f02 100755 --- a/tests/Modifiers_-_--size.test +++ b/tests/Modifiers_-_--size.test @@ -2,8 +2,8 @@ # # Check that "--size" affects the percentage shown. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" # Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for # around 10 output lines, but set the size to 200. diff --git a/tests/Modifiers_-_--size_from_file_size.test b/tests/Modifiers_-_--size_from_file_size.test index 9b10d2d..a28dab6 100755 --- a/tests/Modifiers_-_--size_from_file_size.test +++ b/tests/Modifiers_-_--size_from_file_size.test @@ -3,8 +3,9 @@ # Similar to the "--size" check but, instead, using another file's size with # "--size @". -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # Process 100 bytes at 100 bytes per second, interval 0.1 seconds, with the # size set from a file of $1 bytes and expecting a percentage of $2 at the diff --git a/tests/Modifiers_-_--sync.test b/tests/Modifiers_-_--sync.test index c5334a7..9f586a4 100755 --- a/tests/Modifiers_-_--sync.test +++ b/tests/Modifiers_-_--sync.test @@ -5,8 +5,9 @@ # check that fdatasync() is actually being called, it just checks that data # is not being corrupted. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # generate some data dd if=/dev/urandom of="${workFile1}" bs=1024 count=2560 2>/dev/null diff --git a/tests/Terminal_-_Detect_width.test b/tests/Terminal_-_Detect_width.test index 1b20157..929aea4 100755 --- a/tests/Terminal_-_Detect_width.test +++ b/tests/Terminal_-_Detect_width.test @@ -2,8 +2,9 @@ # # Check that the terminal width is detected on startup. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # Skip the test if `tmux' is not available. if ! command -v tmux >/dev/null 2>&1; then diff --git a/tests/Transfer_-_--rate-limit.test b/tests/Transfer_-_--rate-limit.test index f45693a..3aedf0d 100755 --- a/tests/Transfer_-_--rate-limit.test +++ b/tests/Transfer_-_--rate-limit.test @@ -2,8 +2,7 @@ # # A simple test of rate limiting. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}" +true "${testSubject:?not set - call this from 'make check'}" # Transfer 102 bytes at 100 bytes/sec. It should take at least 1 second. # diff --git a/tests/Transfer_-_--remote.test b/tests/Transfer_-_--remote.test index 64639aa..6df9403 100755 --- a/tests/Transfer_-_--remote.test +++ b/tests/Transfer_-_--remote.test @@ -2,8 +2,11 @@ # # Try changing the format of a transfer remotely. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" +true "${workFile3:?not set - call this from 'make check'}" +true "${workFile4:?not set - call this from 'make check'}" # Do nothing if it is not supported. if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then diff --git a/tests/Transfer_-_--stop-at-size.test b/tests/Transfer_-_--stop-at-size.test index 7bd9840..da079c8 100755 --- a/tests/Transfer_-_--stop-at-size.test +++ b/tests/Transfer_-_--stop-at-size.test @@ -2,8 +2,9 @@ # # Make sure -S stops at the given size. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # generate some data dd if=/dev/urandom of="${workFile1}" bs=1024 count=10 2>/dev/null diff --git a/tests/Watchfd_-_Multiple_descriptors.test b/tests/Watchfd_-_Multiple_descriptors.test index 5894cf0..2de3f1c 100755 --- a/tests/Watchfd_-_Multiple_descriptors.test +++ b/tests/Watchfd_-_Multiple_descriptors.test @@ -2,8 +2,10 @@ # # Check that watching a process's file descriptors works as expected. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" +true "${workFile3:?not set - call this from 'make check'}" # Skip the test if "-d" is not available. if ! "${testSubject}" -h | grep -Fq ' -d'; then diff --git a/tests/Watchfd_-_Single_descriptor.test b/tests/Watchfd_-_Single_descriptor.test index 09909a4..df1ed9a 100755 --- a/tests/Watchfd_-_Single_descriptor.test +++ b/tests/Watchfd_-_Single_descriptor.test @@ -2,8 +2,9 @@ # # Check that watching a single file descriptor works as expected. -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" +true "${workFile2:?not set - call this from 'make check'}" # Skip the test if "-d" is not available. if ! "${testSubject}" -h | grep -Fq ' -d'; then diff --git a/tests/run-valgrind.sh b/tests/run-valgrind.sh index 4f1ba6b..859da73 100755 --- a/tests/run-valgrind.sh +++ b/tests/run-valgrind.sh @@ -21,8 +21,8 @@ # Output file for failures. valgrindOutputFile="valgrind.out" -# Dummy assignments for "shellcheck". -testSubject="${testSubject:-false}"; workFile4="${workFile4:-.tmp4}" +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile4:?not set - call this from 'make check'}" if ! command -v valgrind >/dev/null 2>&1; then echo "test requires \`valgrind'" diff --git a/tests/test-env.sh b/tests/test-env.sh index 9bc00de..6cd52aa 100644 --- a/tests/test-env.sh +++ b/tests/test-env.sh @@ -6,6 +6,8 @@ # Tests must exit with 0 for success, 1 for failure, 77 to skip the test, or # 99 for a fatal error with the test framework. +true "${srcdir:?not set - call this from 'make check'}" + # Parameters. testSubject="./pv" sourcePath="${srcdir}"