tests: factor portable signal check out of t0005
[gitweb.git] / t / test-lib-functions.sh
index 48884d520813998a735d89d406b45c63b0bf748d..15ef3f816c64521628157a5a1d96d42fa5ca8720 100644 (file)
@@ -961,3 +961,18 @@ test_env () {
                done
        )
 }
+
+# Returns true if the numeric exit code in "$2" represents the expected signal
+# in "$1". Signals should be given numerically.
+test_match_signal () {
+       if test "$2" = "$((128 + $1))"
+       then
+               # POSIX
+               return 0
+       elif test "$2" = "$((256 + $1))"
+       then
+               # ksh
+               return 0
+       fi
+       return 1
+}