Enable reuse of eglib native test framework and test driver source.
authorlateralusX <lateralusx.github@gmail.com>
Wed, 28 Sep 2016 10:01:08 +0000 (12:01 +0200)
committerlateralusX <lateralusx.github@gmail.com>
Wed, 28 Sep 2016 10:01:08 +0000 (12:01 +0200)
In current eglib test framework there is no mechanism to specify where
the include file describing all tests is located. Current implementation also assumes it is the main
entry point of the process since it defines the main symbol. There are several scenarios
where it could make sense to reuse eglib test framework and its driver in other native unit test projects
unit testing native code. In those scenarios it would be nice to include existing driver.c
from eglib/test (no copy) and use toolchain capabilities to include needed header with test descriptions
and change main symbol name, since main will most likely be defined elsewhere.

This can be achieved by two simple defines that can be set when embedding eglib test framwork in other
native binaries. By default these defines will not be set and current behavior will be preserved.

eglib/test/driver.c

index 23e7638bdbdbe9929fe7eccd6096a0faf7498596..806e8b66d3f2387f45078ae70af458bf19fca5a1 100644 (file)
 
 #include <config.h>
 #include "test.h"
+
+#ifndef DRIVER_EXTERNAL_TESTS
 #include "tests.h"
+#endif
 
 #include <stdio.h>
 #ifdef HAVE_GETOPT_H
@@ -102,7 +105,11 @@ static void print_help(char *s)
        printf("\n");
 }
 
+#ifdef DRIVER_EXTERNAL_MAIN
+gint run_tests_main(gint argc, gchar **argv)
+#else
 gint main(gint argc, gchar **argv)
+#endif
 {
        gint i, j, c, iterations = 1;
        StringArray *tests_to_run = NULL;