Improve error message output from the fork() utest (#4753)
* Add perror to report the reason for a fork failure * reword the malloc failure message
This commit is contained in:
parent
f13403b6b6
commit
33bb4b98a4
|
@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <cblas.h>
|
#include <cblas.h>
|
||||||
#include "openblas_utest.h"
|
#include "openblas_utest.h"
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ static void* xmalloc(size_t n)
|
||||||
void* tmp;
|
void* tmp;
|
||||||
tmp = malloc(n);
|
tmp = malloc(n);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
fprintf(stderr, "You are about to die\n");
|
fprintf(stderr, "Failed to allocate memory for the testcase.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
return tmp;
|
return tmp;
|
||||||
|
@ -103,6 +104,7 @@ exit(0);
|
||||||
|
|
||||||
fork_pid = fork();
|
fork_pid = fork();
|
||||||
if (fork_pid == -1) {
|
if (fork_pid == -1) {
|
||||||
|
perror("fork");
|
||||||
CTEST_ERR("Failed to fork process.");
|
CTEST_ERR("Failed to fork process.");
|
||||||
} else if (fork_pid == 0) {
|
} else if (fork_pid == 0) {
|
||||||
// Compute a DGEMM product in the child process to check that the
|
// Compute a DGEMM product in the child process to check that the
|
||||||
|
@ -113,7 +115,8 @@ exit(0);
|
||||||
// recursively
|
// recursively
|
||||||
fork_pid_nested = fork();
|
fork_pid_nested = fork();
|
||||||
if (fork_pid_nested == -1) {
|
if (fork_pid_nested == -1) {
|
||||||
CTEST_ERR("Failed to fork process.");
|
perror("fork");
|
||||||
|
CTEST_ERR("Failed to fork nested process.");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (fork_pid_nested == 0) {
|
} else if (fork_pid_nested == 0) {
|
||||||
check_dgemm(a, b, d, c, n);
|
check_dgemm(a, b, d, c, n);
|
||||||
|
|
|
@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <cblas.h>
|
#include <cblas.h>
|
||||||
#ifdef USE_OPENMP
|
#ifdef USE_OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
@ -44,7 +45,7 @@ static void* xmalloc(size_t n)
|
||||||
void* tmp;
|
void* tmp;
|
||||||
tmp = malloc(n);
|
tmp = malloc(n);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
fprintf(stderr, "You are about to die\n");
|
fprintf(stderr, "Failed to allocate memory for the test payload.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
return tmp;
|
return tmp;
|
||||||
|
@ -114,7 +115,11 @@ exit(0);
|
||||||
|
|
||||||
fork_pid = fork();
|
fork_pid = fork();
|
||||||
if (fork_pid == -1) {
|
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) {
|
} else if (fork_pid == 0) {
|
||||||
// Just pretend to do something, e.g. call `uname`, then exit
|
// Just pretend to do something, e.g. call `uname`, then exit
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
Loading…
Reference in New Issue