mirror of
https://github.com/troglobit/libite.git
synced 2026-11-09 16:21:18 +00:00
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 <troglobit@gmail.com>
This commit is contained in:
1 parent
63d82da62d
commit
c15e883427
1 file changed
+8
-3
+8
-3
@@ -4,9 +4,10 @@
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
struct { char *cmd; int rc; } list[] = {
|
struct { char *cmd; int rc; } list[] = {
|
||||||
|
{ "/app/enoent", 127 },
|
||||||
{ "false", 1 },
|
{ "false", 1 },
|
||||||
{ "true", 0 },
|
{ "true", 0 },
|
||||||
{ "kill -9 $$", 1 },
|
{ "kill -9 $$", -1 },
|
||||||
{ "kill -QUIT $$", -1 },
|
{ "kill -QUIT $$", -1 },
|
||||||
{ "kill -INT $$", -1 }
|
{ "kill -INT $$", -1 }
|
||||||
};
|
};
|
||||||
@@ -15,8 +16,12 @@ int main(void)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = systemf("%s", list[i].cmd);
|
rc = systemf("%s", list[i].cmd);
|
||||||
if (rc != list[i].rc)
|
if (rc != list[i].rc) {
|
||||||
err(rc, "Failed command %s", list[i].cmd);
|
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;
|
return 0;
|
||||||
|
|||||||
Reference in new issue
Block a user