Report missing binary if test suite is run w/o prior install master origin/HEAD origin/master 1.0
authorSofian Brabez <sbz@FreeBSD.org>
Sat, 9 Apr 2022 07:32:57 +0000 (07:32 +0000)
committerSofian Brabez <sbz@FreeBSD.org>
Sat, 9 Apr 2022 07:32:57 +0000 (07:32 +0000)
If the elfdbg binary is missing in $PATH it makes the tests executions to fail,
instead report the missing binary. `make test` will only succeed if the binary
is present and installed using `make install`

tests/elfdbg_test.sh
tests/test_helper.sh

index c1784949cc1c04485fda5cc54a6439ba16718bba..1916935f70c48201c6b0d8eb49d666ecbcc1fdf7 100755 (executable)
@@ -1,6 +1,7 @@
 #! /usr/bin/env atf-sh
 
 . $(atf_get_srcdir)/test_helper.sh
+elfdbg_path=$(which elfdbg)
 
 atf_test_case stripped
 
@@ -14,7 +15,9 @@ stripped_body()
 {
     generate_bin_nodbg
 
-    out=$(elfdbg bin)
+    [ ! -f "${elfdbg_path}" ] && atf_fail "No elfdbg binary found in '$PATH'"
+
+    out=$(${elfdbg_path} bin)
     expected="NO DEBUG"
     if [ "$out" == "$expected" ]; then
         atf_pass
@@ -38,7 +41,9 @@ not_stripped_body()
 {
     generate_bin_dbg
 
-    out=$(elfdbg bin)
+    [ ! -f "${elfdbg_path}" ] && atf_fail "No elfdbg binary found in '$PATH'"
+
+    out=$(${elfdbg_path} bin)
     expected="HAS DEBUG"
     if [ "$out" == "$expected" ]; then
         atf_pass
index 9eab858f5f0f66662b04003a8dfab1f34d0d9af7..421355d9aba95e087eba7f51c5fca96104f877af 100644 (file)
@@ -1,18 +1,18 @@
 generate_bin_nodbg()
 {
-       cat > bin.c << EOF
+       cat > bin.c <<EOF
 int
 main(void) {
     return (0);
 }
 EOF
        /usr/bin/cc -o bin bin.c
-    /usr/bin/strip bin
+       /usr/bin/strip bin
 }
 
 generate_bin_dbg()
 {
-       cat > bin.c << EOF
+       cat > bin.c <<EOF
 int
 main(void) {
     return (0);