Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message output from the fork() utest #4753

Merged
merged 4 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions utest/test_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <cblas.h>
#include "openblas_utest.h"

Expand All @@ -41,7 +42,7 @@ static void* xmalloc(size_t n)
void* tmp;
tmp = malloc(n);
if (tmp == NULL) {
fprintf(stderr, "You are about to die\n");
fprintf(stderr, "Failed to allocate memory for the testcase.\n");
exit(1);
} else {
return tmp;
Expand Down Expand Up @@ -103,6 +104,7 @@ exit(0);

fork_pid = fork();
if (fork_pid == -1) {
perror("fork");
CTEST_ERR("Failed to fork process.");
} else if (fork_pid == 0) {
// Compute a DGEMM product in the child process to check that the
Expand All @@ -113,7 +115,8 @@ exit(0);
// recursively
fork_pid_nested = fork();
if (fork_pid_nested == -1) {
CTEST_ERR("Failed to fork process.");
perror("fork");
CTEST_ERR("Failed to fork nested process.");
exit(1);
} else if (fork_pid_nested == 0) {
check_dgemm(a, b, d, c, n);
Expand Down
9 changes: 7 additions & 2 deletions utest/test_post_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <cblas.h>
#ifdef USE_OPENMP
#include <omp.h>
Expand All @@ -44,7 +45,7 @@ static void* xmalloc(size_t n)
void* tmp;
tmp = malloc(n);
if (tmp == NULL) {
fprintf(stderr, "You are about to die\n");
fprintf(stderr, "Failed to allocate memory for the test payload.\n");
exit(1);
} else {
return tmp;
Expand Down Expand Up @@ -114,7 +115,11 @@ exit(0);

fork_pid = fork();
if (fork_pid == -1) {
CTEST_ERR("Failed to fork process.");
perror("fork");
CTEST_ERR("Failed to fork subprocesses in a loop.");
#ifdef USE_OPENMP
CTEST_ERR("Number of OpenMP threads was %d in this attempt.",i);
#endif
} else if (fork_pid == 0) {
// Just pretend to do something, e.g. call `uname`, then exit
exit(0);
Expand Down
Loading