]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: provide an option to relax the need for gdb
authorPádraig Brady <P@draigBrady.com>
Thu, 21 Jun 2018 03:48:36 +0000 (20:48 -0700)
committerPádraig Brady <P@draigBrady.com>
Thu, 21 Jun 2018 04:18:32 +0000 (21:18 -0700)
* tests/rm/r-root.sh: gdb provides extra protection,
but is not strictly necessary.  So provide an option
for maintainers to relax the requirements.

tests/rm/r-root.sh

index c8a57afda22084bbba71fcd91776c164b3d977ce..14bd0d93ed05087a6d8ce6c096133fec5849a9bb 100755 (executable)
@@ -36,12 +36,18 @@ require_gcc_shared_
 # used later in the unlinkat() wrapper.
 unset CU_TEST_SKIP_EXIT
 
-# Use gdb to provide further protection by limiting calls to unlinkat().
-( timeout 10s gdb --version ) > gdb.out 2>&1
-case $(cat gdb.out) in
+# Set this to 0 if you don't have a working gdb but would
+# still like to run the test
+USE_GDB=1
+
+if test $USE_GDB = 1; then
+  # Use gdb to provide further protection by limiting calls to unlinkat().
+  ( timeout 10s gdb --version ) > gdb.out 2>&1
+  case $(cat gdb.out) in
     *'GNU gdb'*) ;;
     *) skip_ "can't run gdb";;
-esac
+  esac
+fi
 
 # Break on a line rather than a symbol, to cater for inline functions
 break_src="$abs_top_srcdir/src/remove.c"
@@ -131,14 +137,20 @@ exercise_rm_r_root ()
     skip_exit='CU_TEST_SKIP_EXIT=1'
   fi
 
-  gdb -nx --batch-silent -return-child-result                          \
-    --eval-command="set exec-wrapper                                   \
-                     env 'LD_PRELOAD=$LD_PRELOAD:./k.so' $skip_exit"   \
-    --eval-command="break '$break_line'"                               \
-    --eval-command='source bp.py'                                      \
-    --eval-command="run -rv --one-file-system $*"                      \
-    --eval-command='quit'                                              \
-    rm < /dev/null > out 2> err.t
+  if test $USE_GDB = 1; then
+    gdb -nx --batch-silent -return-child-result                                \
+      --eval-command="set exec-wrapper                                 \
+                       env 'LD_PRELOAD=$LD_PRELOAD:./k.so' $skip_exit" \
+      --eval-command="break '$break_line'"                             \
+      --eval-command='source bp.py'                                    \
+      --eval-command="run -rv --one-file-system $*"                    \
+      --eval-command='quit'                                            \
+      rm < /dev/null > out 2> err.t
+  else
+    touch excise.break
+    env LD_PRELOAD=$LD_PRELOAD:./k.so $skip_exit \
+      rm -rv --one-file-system $* < /dev/null > out 2> err.t
+  fi
 
   ret=$?