Skip to contentSkip to conversation

Added error coverage to support when launching child process fails.

PATCH New Edwin Plauchu 1 participant 1 message Sep 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 Added error coverage to support when launching child process fails.

From: Edwin Plauchu <[email protected]>

An error message is required when detecting one or more ptest are not launched.

[YOCTO #9752]

---
 tests/data/fail/ptest/run-ptest |   0
 tests/utils.c                   | 149 +++++++++++++++++++++++++++++++---------
 utils.c                         |   8 ++-
 3 files changed, 121 insertions(+), 36 deletions(-)
 create mode 100644 tests/data/fail/ptest/run-ptest
tests/data/fail/ptest/run-ptest new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/utils.c +116 -33

187 lines not on this page · raw message

utils.c +5 -3
index 6991af1..402e6fb 100644
@@ -249,7 +249,7 @@ run_child(char *run_ptest, int fd_stdout, int fd_stderr)
 	dup2(fd_stderr, STDERR_FILENO);
 	execv(run_ptest, argv);
 
-	exit(0);
+	exit(1);
 }
 
 static inline int
@@ -336,6 +336,7 @@ run_ptests(struct ptest_list *head, int timeout, const char *progname,
 
 			child = fork();
 			if (child == -1) {
+				fprintf(fp, "ERROR: Fork fatal\n");
 				rc = -1;
 				break;
 			} else if (child == 0) {
@@ -350,9 +351,10 @@ run_ptests(struct ptest_list *head, int timeout, const char *progname,
 
 				status = wait_child(ptest_dir, p->run_ptest, child,
 						timeout, fds, fps);
-				if (status)
+				if (status) {
+					fprintf(fp, "ERROR: Program child error\n");
 					rc += 1;
-
+				}
 				fprintf(fp, "END: %s\n", ptest_dir);
 				fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE));
 			}
Signature · 1 line
2.9.3