Browse Source

testc: Enchance view

Serj Kalichev 4 years ago
parent
commit
1046799b78
5 changed files with 49 additions and 40 deletions
  1. 2 28
      faux/ini/testc_ini.c
  2. 2 2
      faux/testc_module/Makefile.am
  3. 28 0
      faux/testc_module/demo.c
  4. 10 4
      faux/testc_module/testc_module.c
  5. 7 6
      testc/testc.c

+ 2 - 28
faux/ini/testc_ini.c

@@ -5,34 +5,8 @@
 #include "faux/ini.h"
 #include "faux/testc_helpers.h"
 
-int testc_faux_ini_good(void) {
 
-	char *path = NULL;
-
-	path = getenv("TESTC_TMPDIR");
-	if (path)
-		printf("Env var is [%s]\n", path);
-	return 0;
-}
-
-
-int testc_faux_ini_bad(void) {
-
-	printf("Some debug information here\n");
-	return -1;
-}
-
-
-int testc_faux_ini_signal(void) {
-
-	char *p = NULL;
-
-	printf("%s\n", p);
-	return -1;
-}
-
-
-int testc_faux_ini_parse(void) {
+int testc_faux_ini_parse_file(void) {
 
 	// Source INI file
 	const char *src_file =
@@ -55,7 +29,7 @@ int testc_faux_ini_parse(void) {
 		"VAR_WITHOUT_EOL=zxcvbnm"
 	;
 
-// Etalon file
+	// Etalon file
 	const char *etalon_file =
 		"ANOTHER_VAR6=\"Normal var\"\n"
 		"COMPLEX_VAR=\"  Ubuntu\t\t1818 \"\n"

+ 2 - 2
faux/testc_module/Makefile.am

@@ -1,3 +1,3 @@
 libfaux_la_SOURCES += \
-	faux/testc_module/testc_module.c
-
+	faux/testc_module/testc_module.c \
+	faux/testc_module/demo.c

+ 28 - 0
faux/testc_module/demo.c

@@ -0,0 +1,28 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int testc_faux_ini_good(void) {
+
+	char *path = NULL;
+
+	path = getenv("TESTC_TMPDIR");
+	if (path)
+		printf("Env var is [%s]\n", path);
+	return 0;
+}
+
+
+int testc_faux_ini_bad(void) {
+
+	printf("Some debug information here\n");
+	return -1;
+}
+
+
+int testc_faux_ini_signal(void) {
+
+	char *p = NULL;
+
+	printf("%s\n", p);
+	return -1;
+}

+ 10 - 4
faux/testc_module/testc_module.c

@@ -4,9 +4,15 @@ const unsigned char testc_version_major = 1;
 const unsigned char testc_version_minor = 0;
 
 const char *testc_module[][2] = {
-//	{"testc_faux_ini_bad", "INI bad"}, // demo
-//	{"testc_faux_ini_signal", "Interrupted by signal"}, // demo
-//	{"testc_faux_ini_good", "INI subsystem good"}, // demo
-	{"testc_faux_ini_parse", "Complex test of INI file parsing"},
+
+	// Demo
+	{"testc_faux_ini_bad", "INI bad"}, // demo
+	{"testc_faux_ini_signal", "Interrupted by signal"}, // demo
+	{"testc_faux_ini_good", "INI subsystem good"}, // demo
+
+	// INI
+	{"testc_faux_ini_parse_file", "Complex test of INI file parsing"},
+
+	// End of list
 	{NULL, NULL}
 	};

+ 7 - 6
testc/testc.c

@@ -242,13 +242,13 @@ int main(int argc, char *argv[]) {
 
 				// Success
 				if (WEXITSTATUS(wstatus) == 0) {
-					result_str = faux_str_dup("success");
+					result_str = faux_str_dup("OK");
 					attention_str = faux_str_dup("");
 
 				// Failed
 				} else {
 					result_str = faux_str_sprintf(
-						"failed (%d)",
+						"FAIL (%d)",
 						(int)((signed char)((unsigned char)WEXITSTATUS(wstatus))));
 					attention_str = faux_str_dup("(!) ");
 					module_failed_tests++; // Statistics
@@ -256,14 +256,14 @@ int main(int argc, char *argv[]) {
 
 			// Terminated by signal
 			} else if (WIFSIGNALED(wstatus)) {
-				result_str = faux_str_sprintf("terminated (%d)",
+				result_str = faux_str_sprintf("SIGNAL (%d)",
 					WTERMSIG(wstatus));
 				attention_str = faux_str_dup("[!] ");
 				module_interrupted_tests++; // Statistics
 
 			// Stopped by unknown conditions
 			} else {
-				result_str = faux_str_dup("unknown");
+				result_str = faux_str_dup("UNKNOWN");
 				attention_str = faux_str_dup("[!] ");
 				module_broken_tests++; // Statistics
 			}
@@ -285,10 +285,10 @@ int main(int argc, char *argv[]) {
 						tmpdir);
 				}
 				if (faux_list_len(buf_list) > 0)
-					printf("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \n");
+					printf(">>>\n");
 				print_test_output(buf_list);
 				if (faux_list_len(buf_list) > 0)
-					printf("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \n");
+					printf("<<<\n");
 			}
 			faux_list_free(buf_list);
 
@@ -306,6 +306,7 @@ int main(int argc, char *argv[]) {
 			faux_rm(testc_tmpdir);
 
 		// Report module statistics
+		printf("\n");
 		printf("Module tests: %u\n", module_tests);
 		printf("Module broken tests: %u\n", module_broken_tests);
 		printf("Module failed tests: %u\n", module_failed_tests);