2004-01-15 03:07:17 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-15 03:07:17 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 05:03:09 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-15 03:07:17 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
2004-01-15 03:33:59 +03:00
|
|
|
#include <stdio.h>
|
2004-01-15 03:07:17 +03:00
|
|
|
|
|
|
|
#include "support.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A testing support library to provide uniform reporting output
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
static int ompi_n_tests;
|
|
|
|
static int ompi_n_success;
|
|
|
|
static int ompi_n_failures;
|
|
|
|
static char *ompi_description;
|
2004-01-15 03:07:17 +03:00
|
|
|
|
2005-04-08 21:56:16 +04:00
|
|
|
void test_init(const char *a)
|
2004-01-15 03:07:17 +03:00
|
|
|
{
|
|
|
|
/* local variables */
|
2004-01-15 03:33:59 +03:00
|
|
|
size_t len;
|
2004-01-15 03:07:17 +03:00
|
|
|
|
|
|
|
/* save the descriptive string */
|
2004-06-16 02:41:41 +04:00
|
|
|
len = strlen(a);
|
|
|
|
ompi_description = (char *) malloc(len + 1);
|
2004-06-07 19:33:53 +04:00
|
|
|
assert(ompi_description);
|
2004-01-15 03:07:17 +03:00
|
|
|
|
2004-06-16 02:41:41 +04:00
|
|
|
strcpy(ompi_description, a);
|
2004-01-15 03:07:17 +03:00
|
|
|
|
|
|
|
/* initialize counters */
|
2004-06-16 02:41:41 +04:00
|
|
|
ompi_n_tests = 0;
|
|
|
|
ompi_n_success = 0;
|
|
|
|
ompi_n_failures = 0;
|
2004-01-15 03:07:17 +03:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-01-15 03:33:59 +03:00
|
|
|
|
2004-06-16 02:41:41 +04:00
|
|
|
void test_success(void)
|
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_n_tests++;
|
|
|
|
ompi_n_success++;
|
2004-01-15 03:33:59 +03:00
|
|
|
}
|
|
|
|
|
2004-06-16 02:41:41 +04:00
|
|
|
|
2005-04-08 21:56:16 +04:00
|
|
|
void test_failure(const char *a)
|
2004-06-16 02:41:41 +04:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_n_tests++;
|
|
|
|
ompi_n_failures++;
|
2004-01-15 03:33:59 +03:00
|
|
|
|
2004-08-13 19:15:14 +04:00
|
|
|
fprintf(stderr, " Failure : ");
|
|
|
|
fprintf(stderr, a);
|
|
|
|
fprintf(stderr, "\n");
|
2004-01-15 03:33:59 +03:00
|
|
|
fflush(stderr);
|
|
|
|
}
|
|
|
|
|
2004-02-11 01:15:55 +03:00
|
|
|
|
2004-06-16 02:41:41 +04:00
|
|
|
int test_verify_str(const char *expected_result, const char *test_result)
|
|
|
|
{
|
|
|
|
size_t len_expect, len_result;
|
2004-01-15 03:33:59 +03:00
|
|
|
int return_value;
|
|
|
|
|
2004-01-27 23:11:48 +03:00
|
|
|
return_value = 1;
|
2004-02-11 01:15:55 +03:00
|
|
|
len_expect = expected_result ? strlen(expected_result) : 0;
|
|
|
|
len_result = test_result ? strlen(test_result) : 0;
|
2004-01-15 03:33:59 +03:00
|
|
|
|
2004-06-16 02:41:41 +04:00
|
|
|
if ((!(len_expect == len_result)) ||
|
|
|
|
(0 != strcmp(expected_result, test_result))) {
|
2004-01-27 23:11:48 +03:00
|
|
|
test_failure("Comparison failure");
|
2004-06-16 02:41:41 +04:00
|
|
|
fprintf(stderr, " Expected result: %s\n", expected_result);
|
|
|
|
fprintf(stderr, " Test result: %s\n", test_result);
|
2004-01-15 03:33:59 +03:00
|
|
|
fflush(stderr);
|
2004-01-27 23:11:48 +03:00
|
|
|
return_value = 0;
|
2004-06-16 02:41:41 +04:00
|
|
|
} else {
|
2004-01-27 23:11:48 +03:00
|
|
|
test_success();
|
2004-01-15 03:33:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2004-06-16 02:41:41 +04:00
|
|
|
|
2004-01-27 23:11:48 +03:00
|
|
|
int test_verify_int(int expected_result, int test_result)
|
|
|
|
{
|
|
|
|
int return_value;
|
2004-06-16 02:41:41 +04:00
|
|
|
|
2004-01-27 23:11:48 +03:00
|
|
|
return_value = 1;
|
2004-06-16 02:41:41 +04:00
|
|
|
if (expected_result != test_result) {
|
2004-01-27 23:11:48 +03:00
|
|
|
test_failure("Comparison failure");
|
2004-06-16 02:41:41 +04:00
|
|
|
fprintf(stderr, " Expected result: %d\n", expected_result);
|
|
|
|
fprintf(stderr, " Test result: %d\n", test_result);
|
2004-01-27 23:11:48 +03:00
|
|
|
fflush(stderr);
|
|
|
|
return_value = 0;
|
2004-06-16 02:41:41 +04:00
|
|
|
} else {
|
2004-01-27 23:11:48 +03:00
|
|
|
test_success();
|
|
|
|
}
|
2004-06-16 02:41:41 +04:00
|
|
|
|
|
|
|
return return_value;
|
2004-01-27 23:11:48 +03:00
|
|
|
}
|
|
|
|
|
2004-06-16 02:41:41 +04:00
|
|
|
|
2004-01-15 03:59:26 +03:00
|
|
|
int test_finalize(void)
|
2004-01-15 03:33:59 +03:00
|
|
|
{
|
2004-01-15 03:59:26 +03:00
|
|
|
int return_value;
|
|
|
|
|
2005-03-22 07:25:01 +03:00
|
|
|
return_value = 0;
|
2004-01-15 03:59:26 +03:00
|
|
|
|
2004-06-16 02:41:41 +04:00
|
|
|
if (ompi_n_tests == ompi_n_success) {
|
|
|
|
fprintf(stderr, "SUPPORT: OMPI Test Passed: %s: (%d tests)\n",
|
|
|
|
ompi_description, ompi_n_tests);
|
2004-01-15 03:33:59 +03:00
|
|
|
fflush(stderr);
|
|
|
|
} else {
|
2004-06-16 02:41:41 +04:00
|
|
|
fprintf(stderr,
|
|
|
|
"SUPPORT: OMPI Test failed: %s (%d of %d failed)\n",
|
|
|
|
ompi_description, ompi_n_failures, ompi_n_tests);
|
2004-01-15 03:33:59 +03:00
|
|
|
fflush(stderr);
|
2005-03-22 07:25:01 +03:00
|
|
|
return_value = 1;
|
2004-01-15 03:33:59 +03:00
|
|
|
}
|
2004-01-15 03:59:26 +03:00
|
|
|
|
2005-03-22 03:31:17 +03:00
|
|
|
if (NULL != ompi_description)
|
|
|
|
free(ompi_description);
|
|
|
|
|
2004-01-15 03:59:26 +03:00
|
|
|
return return_value;
|
2004-01-15 03:33:59 +03:00
|
|
|
}
|
2004-08-13 03:03:39 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* note this is for additional output that does NOT go to STDERR but STDOUT */
|
2005-04-08 21:56:16 +04:00
|
|
|
void test_comment (const char* userstr)
|
2004-08-13 03:03:39 +04:00
|
|
|
{
|
|
|
|
fprintf(stdout, "%s:%s\n", ompi_description, userstr);
|
|
|
|
}
|
2005-04-08 21:56:16 +04:00
|
|
|
|
|
|
|
|
|
|
|
void test_fail_stop(const char *msg, int status)
|
|
|
|
{
|
|
|
|
test_failure(msg);
|
|
|
|
test_finalize();
|
|
|
|
exit(status);
|
|
|
|
}
|