[ptest-runner,2/4] utils.c: Fix exit status of a child

Submitted by Aníbal Limón on March 23, 2021, 2:10 a.m. | Patch ID: 179394

Details

Message ID 20210323021038.1049654-2-anibal.limon@linaro.org
State New
Headers show

Commit Message

Aníbal Limón March 23, 2021, 2:10 a.m.
Modify testcase to validate the actual exit status.

[YOCTO #14217]

Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
---
 tests/data/fail/ptest/run-ptest | 3 +++
 tests/utils.c                   | 2 +-
 utils.c                         | 3 +++
 3 files changed, 7 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 tests/data/fail/ptest/run-ptest

Patch hide | download patch | download mbox

diff --git a/tests/data/fail/ptest/run-ptest b/tests/data/fail/ptest/run-ptest
old mode 100644
new mode 100755
index e69de29..f4e5d0b
--- a/tests/data/fail/ptest/run-ptest
+++ b/tests/data/fail/ptest/run-ptest
@@ -0,0 +1,3 @@ 
+#!/bin/bash
+
+exit 10
diff --git a/tests/utils.c b/tests/utils.c
index 132d98f..105e0c8 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -234,7 +234,7 @@  END_TEST
 static void
 search_for_fail(const int rp, FILE *fp_stdout)
 {
-        const char *fail_str = "ERROR: Exit status is";
+        const char *fail_str = "ERROR: Exit status is 10";
         char line_buf[PRINT_PTEST_BUF_SIZE];
         int found_fail = 0;
         char *line = NULL;
diff --git a/utils.c b/utils.c
index 43ab03b..d784736 100644
--- a/utils.c
+++ b/utils.c
@@ -352,6 +352,9 @@  wait_child(pid_t pid, int timeout, int *fds, FILE **fps, int *timeouted)
 
 			clock_gettime(clock, &sentinel);
 		}
+
+		if (WIFEXITED(status))
+			status = WEXITSTATUS(status);
 	}
 
 	fflush(fps[0]);