stardis-test

Test Stardis behaviors
git clone git://git.meso-star.fr/stardis-test.git
Log | Files | Refs | README | LICENSE

commit 720d31e1242cceb174f04a212cff4935b642e942
parent 9f5090a765ab73559563745f66316970f0e5e9a6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sun, 14 Apr 2024 12:13:26 +0200

Updating error handling when closing the test process

The return state of pclose is checked for errors returned by the process
and assumes that other errors originate from the pclose function. But
the process may be stopped or terminated following the reception of an
uncaptured signal (e.g. SIGABRT), both of which, if they are unexpected
results, are not pclose errors. Assuming the opposite, we would return
an errno which in fact notified that pclose had succeeded. As a result,
the test continued without reporting an error as expected.

This commit now handles the above states returned by pclose and reports
and error code corresponding to the error.

Diffstat:
Msrc/sadist_conducto_radiative.c | 6+++++-
Msrc/sadist_external_flux.c | 6+++++-
Msrc/sadist_probe_boundary.c | 12++++++++++--
Msrc/sadist_unsteady.c | 6+++++-
4 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/sadist_conducto_radiative.c b/src/sadist_conducto_radiative.c @@ -185,7 +185,11 @@ run(const char* command) /* Check command exit status */ if((status=pclose(output)), output=NULL, status) { - err = WIFEXITED(status) ? WEXITSTATUS(status) : errno; + if(status == -1) err = errno; + else if(WIFEXITED(status)) err = WEXITSTATUS(status); + else if(WIFSIGNALED(status)) err = WTERMSIG(status); + else if(WIFSTOPPED(status)) err = WSTOPSIG(status); + else FATAL("Unreachable code.\n"); goto error; } diff --git a/src/sadist_external_flux.c b/src/sadist_external_flux.c @@ -233,7 +233,11 @@ run(const char* command, const double ref) /* Check command exit status */ if((status=pclose(output)), output=NULL, status) { - err = WIFEXITED(status) ? WEXITSTATUS(status) : errno; + if(status == -1) err = errno; + else if(WIFEXITED(status)) err = WEXITSTATUS(status); + else if(WIFSIGNALED(status)) err = WTERMSIG(status); + else if(WIFSTOPPED(status)) err = WSTOPSIG(status); + else FATAL("Unreachable code.\n"); goto error; } diff --git a/src/sadist_probe_boundary.c b/src/sadist_probe_boundary.c @@ -360,7 +360,11 @@ run1(const struct sadist_trilinear_profile* profile) /* Check command exit status */ if((status=pclose(output), output=NULL, status)) { - err = WIFEXITED(status) ? WEXITSTATUS(status) : errno; + if(status == -1) err = errno; + else if(WIFEXITED(status)) err = WEXITSTATUS(status); + else if(WIFSIGNALED(status)) err = WTERMSIG(status); + else if(WIFSTOPPED(status)) err = WSTOPSIG(status); + else FATAL("Unreachable code.\n"); goto error; } @@ -433,7 +437,11 @@ runN(const struct sadist_trilinear_profile* profile, const size_t nprobes) /* Check command exit status */ if((status=pclose(output)), output = NULL, status) { - err = WIFEXITED(status) ? WEXITSTATUS(status) : errno; + if(status == -1) err = errno; + else if(WIFEXITED(status)) err = WEXITSTATUS(status); + else if(WIFSIGNALED(status)) err = WTERMSIG(status); + else if(WIFSTOPPED(status)) err = WSTOPSIG(status); + else FATAL("Unreachable code.\n"); goto error; } output = NULL; diff --git a/src/sadist_unsteady.c b/src/sadist_unsteady.c @@ -185,7 +185,11 @@ run(struct sadist_unsteady_profile* profile, const char* command) /* Check command exit status */ if((status=pclose(output), output=NULL, status)) { - err = WIFEXITED(status) ? WEXITSTATUS(status) : errno; + if(status == -1) err = errno; + else if(WIFEXITED(status)) err = WEXITSTATUS(status); + else if(WIFSIGNALED(status)) err = WTERMSIG(status); + else if(WIFSTOPPED(status)) err = WSTOPSIG(status); + else FATAL("Unreachable code.\n"); goto error; }