From c15e883427369797a8a2432f120c035c2cfbb784 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 26 Mar 2021 12:29:55 +0100 Subject: [PATCH] tests: update systemf() test to detect improper return code on error Non-existing programs should return 127, and killing ourselves with -9 should return -1 For details, see system(3). Signed-off-by: Joachim Wiberg --- tests/systemf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/systemf.c b/tests/systemf.c index 17bd768..61e178c 100644 --- a/tests/systemf.c +++ b/tests/systemf.c @@ -4,9 +4,10 @@ int main(void) { struct { char *cmd; int rc; } list[] = { + { "/app/enoent", 127 }, { "false", 1 }, { "true", 0 }, - { "kill -9 $$", 1 }, + { "kill -9 $$", -1 }, { "kill -QUIT $$", -1 }, { "kill -INT $$", -1 } }; @@ -15,8 +16,12 @@ int main(void) int rc; rc = systemf("%s", list[i].cmd); - if (rc != list[i].rc) - err(rc, "Failed command %s", list[i].cmd); + if (rc != list[i].rc) { + if (rc == -1) + err(rc, "Failed %s", list[i].cmd); + else + errx(rc, "Failed %s, rc %d vs %d", list[i].cmd, rc, list[i].rc); + } } return 0;