[gnome-keyring] [testing] External tests now return proper result codes.



commit 3034c5c1c22947dd430df14329b36b12a3451f38
Author: Stef Walter <stef memberwebs com>
Date:   Tue Jun 29 00:02:36 2010 +0000

    [testing] External tests now return proper result codes.

 testing/testing-build.sh |    7 ++++---
 testing/testing.c        |    7 +++++--
 testing/testing.h        |    3 ++-
 3 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/testing/testing-build.sh b/testing/testing-build.sh
index b84a6b6..60fc24a 100755
--- a/testing/testing-build.sh
+++ b/testing/testing-build.sh
@@ -86,10 +86,10 @@ build_source()
 	echo
 
 	# External function
-	echo "static void run_externals (void) {"
+	echo "static void run_externals (int *ret) {"
 	for file in $@; do
 		name=`file_to_name ${file}`
-		sed -ne "s/.*DEFINE_EXTERNAL[ 	]*(\([^)]\+\)).*/	testing_external_run (\"\1\", external_\1);/p" ${file}
+		sed -ne "s/.*DEFINE_EXTERNAL[ 	]*(\([^)]\+\)).*/	testing_external_run (\"\1\", external_\1, ret);/p" ${file}
 	done
 	echo "}"
 	echo
@@ -99,7 +99,8 @@ build_source()
 	echo "	initialize_tests ();"
 	echo "	start_tests ();"
 	echo "	ret = g_test_run ();"
-	echo "	run_externals ();"
+	echo "	if (ret == 0)"
+	echo "		run_externals (&ret);"
 	echo "	stop_tests();"
 	echo "	return ret;"
 	echo "}"
diff --git a/testing/testing.c b/testing/testing.c
index 5c26c5f..6812a20 100644
--- a/testing/testing.c
+++ b/testing/testing.c
@@ -188,14 +188,17 @@ static const gchar *external_name = NULL;
 static gint external_fails = 0;
 
 void
-testing_external_run (const gchar *name, TestingExternalFunc func)
+testing_external_run (const gchar *name, TestingExternalFunc func, int *result)
 {
+	if (result != 0)
+		return;
+
 	external_fails = 0;
 	external_name = name;
 	func ();
 	if (external_fails) {
 		g_printerr ("/%s: FAIL: %d failures", name, external_fails);
-		abort();
+		*result = external_fails;
 	}
 }
 
diff --git a/testing/testing.h b/testing/testing.h
index eaa7287..6d1a204 100644
--- a/testing/testing.h
+++ b/testing/testing.h
@@ -60,7 +60,8 @@ void             testing_test_p11_module          (CK_FUNCTION_LIST_PTR module,
 typedef void     (*TestingExternalFunc)           (void);
 
 void             testing_external_run             (const gchar *name,
-                                                   TestingExternalFunc func);
+                                                   TestingExternalFunc func,
+                                                   int *result);
 
 const gchar*     testing_external_name            (void);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]