commit c2c86d47fedbdca6a7fd95b99db6e137e578ceb2
parent 3560f71c4f71ea9b2b5ce7765ef52a422264e872
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sun, 14 May 2023 19:43:37 +0200
Clean up the make.sh script
Replace the sed directives with basename, which is what those seds
actually did.
Removed an unnecessary check on the input arguments in the check
function since it is only called internally and should be called
correctly, apart from a bug.
Redirect the error messages of the for loop in the run_test function to
print only the defined error message. This was partially the case since
the error messages of the test were already redirected. But if the test
was interrupted due to an assertion, segmentation error, user interrupt,
etc., the for directive printed its own error message. Now we
redirect it to /dev/null.
Diffstat:
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/make.sh b/make.sh
@@ -34,7 +34,7 @@
config_test()
{
for i in "$@"; do
- test=$(echo "${i}" | sed 's/src\/\(.\{1,\}\).c$/\1/')
+ test=$(basename "${i}" ".c")
test_list="${test_list} ${test}"
printf "%s: %s\n" "${test}" "src/${test}.o"
done
@@ -43,18 +43,14 @@ config_test()
check()
{
- if [ $# -lt 1 ]; then
- echo "usage: check <name> <prog>" >&2
- exit 1
- fi
-
name="$1"
prog="$2"
shift 2
+
printf "%s " "${name}"
if ./"${prog}" "$@" > /dev/null 2>&1; then
printf "\e[1;32mOK\e[m\n"
- else
+ else
printf "\e[1;31mError\e[m\n"
fi
}
@@ -65,7 +61,7 @@ run_test()
shift 1
for i in "$@"; do
- test=$(echo "${i}" | sed 's/src\/\(.\{1,\}\).c$/\1/')
+ test=$(basename "${i}" ".c")
if ! [ "${test}" = "test_ssp_rng" ]; then
check "${test}" "${test}"
else
@@ -78,14 +74,13 @@ run_test()
check "${test}_random_device" "${test}" random_device
check "${test}_threefry" "${test}" threefry
fi
- done
+ done 2> /dev/null
}
clean_test()
{
for i in "$@"; do
- test=$(echo "${i}" | sed 's/src\/\(.\{1,\}\).c$/\1/')
- rm -f "${test}"
+ rm -f "$(basename "${i}" ".c")"
done
}