Browse Source

testc: Change 'testc_module' type

Serj Kalichev 4 years ago
parent
commit
e24fe97f54
2 changed files with 17 additions and 14 deletions
  1. 4 4
      faux/testc_module/testc_module.c
  2. 13 10
      testc/testc.c

+ 4 - 4
faux/testc_module/testc_module.c

@@ -1,7 +1,7 @@
 #include "faux/ini.h"
 
-const char *testc_module[] = {
-	"testc_faux_ini_good", "INI subsystem good",
-	"testc_faux_ini_bad", "INI bad",
-	NULL
+const char *testc_module[][2] = {
+	{"testc_faux_ini_good", "INI subsystem good"},
+	{"testc_faux_ini_bad", "INI bad"},
+	{NULL, NULL}
 	};

+ 13 - 10
testc/testc.c

@@ -77,9 +77,7 @@ int main(int argc, char *argv[]) {
 	iter = faux_list_head(opts->so_list);
 	while ((so = faux_list_each(&iter))) {
 		void *so_handle = NULL;
-		const char **test_list = NULL;
-		const char *test_name = NULL;
-		const char *test_desc = NULL;
+		const char *(*test_list)[2] = NULL;
 		unsigned int module_tests = 0;
 		unsigned int module_errors = 0;
 
@@ -98,17 +96,22 @@ int main(int argc, char *argv[]) {
 			continue;
 		}
 
-		test_list = (const char **)dlsym(so_handle, TESTC_LIST_SYM);
-		while (*test_list) {
+		test_list = dlsym(so_handle, TESTC_LIST_SYM);
+		if (!test_list) {
+			fprintf(stderr, "Error: Can't get test list for module \"%s\"... Skipped\n", so);
+			total_errors++;
+			continue;
+		}
+
+		while ((*test_list)[0]) {
+			const char *test_name = NULL;
+			const char *test_desc = NULL;
 			int (*test_sym)(void);
 			int retval = 0;
 			char *result = NULL;
 
-			test_name = *test_list;
-			test_list++;
-			if (!*test_list) // Broken test list structure
-				break;
-			test_desc = *test_list;
+			test_name = (*test_list)[0];
+			test_desc = (*test_list)[1];
 			test_list++;
 			module_tests++;