Test framework enhancements, fix the check_exports test
authorPetri Lehtinen <petri@digip.org>
Sun, 27 Mar 2011 10:34:43 +0000 (13:34 +0300)
committerPetri Lehtinen <petri@digip.org>
Sun, 27 Mar 2011 10:34:43 +0000 (13:34 +0300)
* Use "printf" instead of "echo -n" as it's more portable
* Treat a test as skipped if it exits with exit status of 77
* Skip the check_exports test if "nm -D" doesn't work

test/scripts/run-tests.sh
test/suites/api/check-exports

index 48dfae8..adf34d4 100644 (file)
@@ -30,31 +30,46 @@ for test_path in $suite_srcdir/*; do
     rm -rf $test_log
     mkdir -p $test_log
     if [ $VERBOSE -eq 1 ]; then
-        echo -n "$test_name... "
+        printf '%s... ' "$test_name"
     fi
 
-    if run_test; then
-        # Success
-        if [ $VERBOSE -eq 1 ]; then
-            echo "ok"
-        else
-            echo -n "."
-        fi
-        rm -rf $test_log
-    else
-        # Failure
-        if [ $VERBOSE -eq 1 ]; then
-            echo "FAILED"
-        else
-            echo -n "F"
-        fi
+    run_test
+    case $? in
+        0)
+            # Success
+            if [ $VERBOSE -eq 1 ]; then
+                printf 'ok\n'
+            else
+                printf '.'
+            fi
+            rm -rf $test_log
+            ;;
 
-        [ $STOP -eq 1 ] && break
-    fi
+        77)
+            # Skip
+            if [ $VERBOSE -eq 1 ]; then
+                printf 'skipped\n'
+            else
+                printf 'S'
+            fi
+            rm -rf $test_log
+            ;;
+
+        *)
+            # Failure
+            if [ $VERBOSE -eq 1 ]; then
+                printf 'FAILED\n'
+            else
+                printf 'F'
+            fi
+
+            [ $STOP -eq 1 ] && break
+            ;;
+    esac
 done
 
 if [ $VERBOSE -eq 0 ]; then
-    echo
+    printf '\n'
 fi
 
 if [ -n "$(ls -A $suite_log)" ]; then
index d18c529..3dc4a9e 100755 (executable)
@@ -89,7 +89,10 @@ EOF
 
 SOFILE="../src/.libs/libjansson.so"
 
-nm -D $SOFILE | grep ' T ' | cut -d' ' -f3 | sort >$test_log/output
+nm -D $SOFILE >/dev/null >$test_log/symbols 2>/dev/null \
+    || exit 77  # Skip if "nm -D" doesn't seem to work
+
+grep ' T ' $test_log/symbols | cut -d' ' -f3 | sort >$test_log/output
 
 if ! cmp -s $test_log/exports $test_log/output; then
     diff -u $test_log/exports $test_log/output >&2