1
1

Cleanup up some of the util unit tests. Fix a detected problem in orte_os_path for relative path names.

This commit was SVN r5096.
Этот коммит содержится в:
Ralph Castain 2005-03-29 19:58:32 +00:00
родитель 72b3a823c3
Коммит 35b4fc02e2
7 изменённых файлов: 155 добавлений и 578 удалений

Просмотреть файл

@ -45,7 +45,7 @@ char *orte_os_path(bool relative, ...)
/* make sure system info is filled and separator is non-NULL */
orte_sys_info();
if (NULL == orte_system_info.path_sep) {
return(NULL);
return(NULL);
}
/* no way to protect ourselves from reading too far, so have to trust caller
@ -54,46 +54,40 @@ char *orte_os_path(bool relative, ...)
num_elements = 0;
total_length = 0;
while (NULL != (element=va_arg(ap, char*))) {
num_elements++;
total_length = total_length + strlen(element);
num_elements++;
total_length = total_length + strlen(element);
}
if (0 == num_elements) { /* must be looking for a simple answer */
path = (char *)malloc(2);
path[0] = 0;
if (relative) {
strcpy(path, ".");
strcat(path, orte_system_info.path_sep);
}
else {
path = (char *)malloc(2);
path[0] = 0;
if (relative) {
strcpy(path, ".");
strcat(path, orte_system_info.path_sep);
}
else {
#ifndef WIN32
strcpy(path, orte_system_info.path_sep);
strcpy(path, orte_system_info.path_sep);
#endif
}
return(path);
}
return(path);
}
/* setup path with enough room for the string terminator, the elements, and
the separator between each of the elements */
total_length = total_length + num_elements + 1;
if (total_length > MAXPATHLEN) { /* path length is too long - reject it */
return(NULL);
return(NULL);
}
path = (char *)malloc(2 + total_length + num_elements-1);
if (NULL == path) {
return(NULL);
return(NULL);
}
path[0] = 0;
if (relative) {
strcpy(path, ".");
}
/* get the first element here so that we don't have duplicate first
seperators */
if (NULL != (element = va_arg(ap1, char*))) {
strcat(path, element);
strcpy(path, ".");
}
while (NULL != (element=va_arg(ap1, char*))) {

Просмотреть файл

@ -20,11 +20,10 @@ AM_CPPFLAGS = -I$(top_srcdir)/test/support -DOMPI_ENABLE_DEBUG_OVERRIDE=1 -g
check_PROGRAMS = \
ompi_numtostr \
ompi_if \
ompi_pack \
ompi_os_path \
ompi_sys_info \
ompi_os_create_dirpath \
ompi_session_dir \
orte_os_path \
orte_sys_info \
orte_os_create_dirpath \
orte_session_dir \
ompi_argv
TESTS = \
@ -48,33 +47,28 @@ ompi_argv_LDADD = \
$(top_builddir)/test/support/libsupport.a
ompi_argv_DEPENDENCIES = $(ompi_argv_LDADD)
ompi_os_path_SOURCES = ompi_os_path.c
ompi_os_path_LDADD = \
orte_os_path_SOURCES = orte_os_path.c
orte_os_path_LDADD = \
$(top_builddir)/src/libmpi.la \
$(top_builddir)/test/support/libsupport.a
ompi_os_path_DEPENDENCIES = $(ompi_os_path_LDADD)
orte_os_path_DEPENDENCIES = $(orte_os_path_LDADD)
ompi_sys_info_SOURCES = ompi_sys_info.c
ompi_sys_info_LDADD = \
orte_sys_info_SOURCES = orte_sys_info.c
orte_sys_info_LDADD = \
$(top_builddir)/src/libmpi.la \
$(top_builddir)/test/support/libsupport.a
ompi_sys_info_DEPENDENCIES = $(ompi_sys_info_LDADD)
orte_sys_info_DEPENDENCIES = $(orte_sys_info_LDADD)
ompi_os_create_dirpath_SOURCES = ompi_os_create_dirpath.c
ompi_os_create_dirpath_LDADD = \
orte_os_create_dirpath_SOURCES = orte_os_create_dirpath.c
orte_os_create_dirpath_LDADD = \
$(top_builddir)/src/libmpi.la \
$(top_builddir)/test/support/libsupport.a
ompi_os_create_dirpath_DEPENDENCIES = $(ompi_os_create_dirpath_LDADD)
orte_os_create_dirpath_DEPENDENCIES = $(orte_os_create_dirpath_LDADD)
ompi_session_dir_SOURCES = ompi_session_dir.c
ompi_session_dir_LDADD = \
orte_session_dir_SOURCES = orte_session_dir.c
orte_session_dir_LDADD = \
$(top_builddir)/src/libmpi.la \
$(top_builddir)/test/support/libsupport.a
ompi_session_dir_DEPENDENCIES = $(ompi_session_dir_LDADD)
orte_session_dir_DEPENDENCIES = $(orte_session_dir_LDADD)
ompi_pack_SOURCES = ompi_pack.c
ompi_pack_LDADD = \
$(top_builddir)/src/libmpi.la \
$(top_builddir)/test/support/libsupport.a
ompi_pack_DEPENDENCIES = $(ompi_pack_LDADD)

Просмотреть файл

@ -1,376 +0,0 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
int main(int argc, char **argv)
{
printf("Test disabled - Does not compile.\n");
return 77;
}
#if 0
#include "util/sys_info.h"
#include "support.h"
#include "../src/util/bufpack.h"
#include "../src/include/constants.h"
/* used for debugging */
/* int dump_buf (ompi_buffer_t buf); */
ompi_buffer_t bufA;
ompi_buffer_t bufB;
ompi_buffer_t bufC;
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify we can pack ok */
static bool test3(void); /* verify we can pack expanding buf */
static bool test4(void); /* verify pack a packed buffer */
static bool test5(void); /* verify unpack */
static bool test6(void); /* verify free */
static bool test7(void); /* verify preallocated buffer init, pack and unpack */
static bool test8(void); /* verify string pack and unpack */
int main (int argc, char* argv[])
{
test_init("ompi_pack");
if (test1()) {
test_success();
}
else {
test_failure("ompi_pack test1 failed");
}
if (test2()) {
test_success();
}
else {
test_failure("ompi_pack test2 failed");
}
if (test3()) {
test_success();
}
else {
test_failure("ompi_pack test3 failed");
}
if (test4()) {
test_success();
}
else {
test_failure("ompi_pack test4 failed");
}
if (test5()) {
test_success();
}
else {
test_failure("ompi_pack test5 failed");
}
if (test6()) {
test_success();
}
else {
test_failure("ompi_pack test6 failed");
}
if (test7()) {
test_success();
}
else {
test_failure("ompi_pack test7 failed");
}
if (test8()) {
test_success();
}
else {
test_failure("ompi_pack test8 failed");
}
/* if (testN()) { */
/* test_success(); */
/* } */
/* else { */
/* test_failure("ompi_pack testN failed"); */
/* } */
test_finalize();
return (0);
}
static bool test1(void) /* verify different buffer inits */
{
int rc;
rc = ompi_buffer_init (&bufA, 0);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_init failed"); return(false);}
rc = ompi_buffer_init (&bufB, 16);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_init failed"); return(false);}
rc = ompi_buffer_init (&bufC, 1024);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_init failed"); return(false);}
return (true);
}
/* BufA should hold 1024 INT32s */
static bool test2(void) /* verify we can pack ok */
{
int rc;
int i;
for (i=0;i<1024;i++) {
rc = ompi_pack (bufA, &i, 1, OMPI_INT32);
if (OMPI_ERROR==rc) { test_comment ("ompi_pack failed"); return(false);}
}
return (true);
}
/* BufB was init with 16 bytes not 1024 sizeof(INT32)s */
/* so it should expand and keep packing */
static bool test3(void) /* verify we can pack expanding buf */
{
int rc;
int i;
int j;
for (i=0;i<1024;i++) {
j = i * 2; /* so we can verify */
rc = ompi_pack (bufB, &j, 1, OMPI_INT32);
if (OMPI_ERROR==rc) { test_comment ("ompi_pack failed"); return(false);}
}
return (true);
}
static bool test4(void) /* verify pack a packed buffer */
{
int rc;
rc = ompi_pack (bufC, bufA, 1, OMPI_PACKED);
if (OMPI_ERROR==rc) { test_comment ("ompi_pack failed"); return(false);}
rc = ompi_pack (bufC, bufB, 1, OMPI_PACKED);
if (OMPI_ERROR==rc) { test_comment ("ompi_pack failed"); return(false);}
return (true);
}
static bool test5(void) /* verify unpack */
{
int rc;
int i, j;
int out;
for (i=0;i<1024;i++) {
j = i; /* for bufA */
rc = ompi_unpack (bufA, &out, 1, OMPI_INT32);
if (OMPI_ERROR==rc) { test_comment ("ompi_unpack failed"); return(false);}
if (out!=j) { test_comment ("bufA packed != unpacked data"); return(false);}
}
for (i=0;i<1024;i++) {
j = i*2; /* for bufB */
rc = ompi_unpack (bufB, &out, 1, OMPI_INT32);
if (OMPI_ERROR==rc) { test_comment ("ompi_unpack failed"); return(false);}
if (out!=j) { test_comment ("bufB packed != unpacked data"); return(false);}
}
for (i=0;i<2048;i++) {
if (i<1024) { j = i; /* bufAs data 1st half */ }
else { j = (i-1024)*2; /* bufBs data 2nd half */ }
rc = ompi_unpack (bufC, &out, 1, OMPI_INT32);
if (OMPI_ERROR==rc) { test_comment ("ompi_unpack failed"); return(false);}
if (out!=j) {
test_comment ("bufC packed != unpacked data");
printf("iteration %d expected %d have %d\n", i, j, out);
return(false);
}
}
return (true);
}
static bool test6(void) /* verify free */
{
int rc;
rc = ompi_buffer_free (bufA);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_free failed"); return(false);}
rc = ompi_buffer_free (bufB);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_free failed"); return(false);}
rc = ompi_buffer_free (bufC);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_free failed"); return(false);}
return (true);
}
static bool test7(void) /* verify preallocated buffer init, pack and unpack */
{
int rc;
int i, j, out;
char *mybuf;
int *p;
/* we cannot use heap/static memory for a buffer as it cannot be realloced as needed for this test */
mybuf = (char*) malloc (sizeof(int)*5);
p = (int*) mybuf;
for(i=0;i<5;i++) {
*p++ = htonl (i); /* the data must be in network byte order for this test to be valid */
/* as the test is emulating prepacked data recvd from the network (OOB) */
}
rc = ompi_buffer_init_preallocated (&bufA, mybuf, sizeof(int)*5);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_init_preallocated failed"); return(false);}
i = 5;
rc = ompi_pack (bufA, &i, 1, OMPI_INT32);
if (OMPI_ERROR==rc) { test_comment ("ompi_pack failed"); return(false);}
/* ok, now check its contents */
for (i=0;i<6;i++) {
j = i; /* for bufA */
rc = ompi_unpack (bufA, &out, 1, OMPI_INT32);
if (OMPI_ERROR==rc) { test_comment ("ompi_unpack failed"); return(false);}
if (out!=j) {
test_comment ("bufA packed != unpacked data");
printf("iteration %d expected %d have %d\n", i, j, out);
return(false);
}
}
/* I do not free mybuf as ompi_buffer_free() will */
rc = ompi_buffer_free (bufA);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_free failed"); return(false);}
return (true);
}
static bool test8(void) /* verify string pack and unpack */
{
int rc;
char *str1;
char *str2;
rc = ompi_buffer_init (&bufA, 0);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_init failed"); return(false);}
rc = ompi_buffer_init (&bufB, 10);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_init failed"); return(false);}
rc = ompi_buffer_init (&bufC, 16);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_init failed"); return(false);}
rc = ompi_pack_string (bufA, "HELLO ");
if (OMPI_ERROR==rc) { test_comment ("ompi_pack_string failed"); return(false);}
rc = ompi_pack_string (bufB, "WORLD!");
if (OMPI_ERROR==rc) { test_comment ("ompi_pack_string failed"); return(false);}
rc = ompi_pack (bufC, bufA, 1, OMPI_PACKED);
if (OMPI_ERROR==rc) { test_comment ("ompi_pack failed"); return(false);}
rc = ompi_pack (bufC, bufB, 1, OMPI_PACKED);
if (OMPI_ERROR==rc) { test_comment ("ompi_pack failed"); return(false);}
/* we now have a buffer with two strings in it */
rc = ompi_unpack_string (bufC, &str1);
if (OMPI_ERROR==rc) { test_comment ("ompi_unpack_string failed"); return(false);}
rc = strcmp ("HELLO ", str1);
if (rc) { test_comment ("strcmp returns no zero value."); return (false); }
rc = ompi_unpack_string (bufC, &str2);
if (OMPI_ERROR==rc) { test_comment ("ompi_unpack_string failed"); return(false);}
rc = strcmp ("WORLD!", str2);
if (rc) { test_comment ("strcmp returns no zero value."); return (false); }
rc = ompi_buffer_free (bufA);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_free failed"); return(false);}
rc = ompi_buffer_free (bufB);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_free failed"); return(false);}
rc = ompi_buffer_free (bufC);
if (OMPI_ERROR==rc) { test_comment ("ompi_buffer_free failed"); return(false);}
if (str1) { free (str1); }
if (str2) { free (str2); }
return (true);
}
/* int dump_buf (ompi_buffer_t buf) */
/* { */
/* int rc, i, out; */
/* */
/* rc = 0; */
/* i = 0; */
/* while (1) { */
/* rc = ompi_unpack (buf, &out, 1, OMPI_INT32); */
/* if (rc==0) printf("%d[%d] ", i, out); */
/* else { */
/* printf("\n"); */
/* break; */
/* } */
/* i++; */
/* } */
/* */
/* return (i); */
/* } */
#endif

Просмотреть файл

@ -14,7 +14,7 @@
* $HEADER$
*/
#include "ompi_config.h"
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -26,14 +26,6 @@
#endif
#include <sys/stat.h>
int main(int argc, char **argv)
{
printf("Test disabled - Does not compile.\n");
return 77;
}
#if 0
#include "include/constants.h"
#include "util/sys_info.h"
#include "util/os_path.h"
@ -47,9 +39,9 @@ static bool test3(void); /* test making a directory tree */
int main(int argc, char* argv[])
{
test_init("ompi_os_create_dirpath_t");
test_init("orte_os_create_dirpath_t");
ompi_sys_info(); /* initialize system info */
orte_sys_info(); /* initialize system info */
/* All done */
@ -57,21 +49,21 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_os_create_dirpath test1 failed");
test_failure("orte_os_create_dirpath test1 failed");
}
if (test2()) {
test_success();
}
else {
test_failure("ompi_os_create_dirpath test2 failed");
test_failure("orte_os_create_dirpath test2 failed");
}
if (test3()) {
test_success();
}
else {
test_failure("ompi_os_create_dirpath test3 failed");
test_failure("orte_os_create_dirpath test3 failed");
}
test_finalize();
@ -85,7 +77,7 @@ static bool test1(void)
/* Test trivial functionality. Program should return OMPI_ERROR when called with NULL path. */
if (OMPI_ERROR != ompi_os_create_dirpath(NULL, S_IRWXU))
if (OMPI_ERROR != orte_os_create_dirpath(NULL, S_IRWXU))
return(false);
return true;
@ -97,24 +89,24 @@ static bool test2(void)
char *tmp;
struct stat buf;
if (NULL == ompi_system_info.path_sep) {
if (NULL == orte_system_info.path_sep) {
printf("test2 cannot be run\n");
return(false);
}
tmp = ompi_os_path(true, "tmp", NULL);
tmp = orte_os_path(true, "tmp", NULL);
if (0 != mkdir(tmp, S_IRWXU)) {
printf("test2 could not be run - directory could not be made\n");
return(false);
}
if (OMPI_ERROR == ompi_os_create_dirpath(tmp, S_IRWXU)) {
if (OMPI_ERROR == orte_os_create_dirpath(tmp, S_IRWXU)) {
rmdir(tmp);
return(false);
}
chmod(tmp, S_IRUSR);
if (OMPI_ERROR == ompi_os_create_dirpath(tmp, S_IRWXU)) {
if (OMPI_ERROR == orte_os_create_dirpath(tmp, S_IRWXU)) {
rmdir(tmp);
return(false);
}
@ -136,24 +128,23 @@ static bool test3(void)
struct stat buf;
char *a[] = { "aaa", "bbb", "ccc", NULL };
if (NULL == ompi_system_info.path_sep) {
if (NULL == orte_system_info.path_sep) {
printf("test3 cannot be run\n");
return(false);
}
out = ompi_os_path(true, a[0], a[1], a[2], NULL);
if (OMPI_ERROR == ompi_os_create_dirpath(out, S_IRWXU)) {
out = ompi_os_path(true, a[0], a[1], a[2], NULL);
out = orte_os_path(true, a[0], a[1], a[2], NULL);
if (OMPI_ERROR == orte_os_create_dirpath(out, S_IRWXU)) {
out = orte_os_path(true, a[0], a[1], a[2], NULL);
if (0 == stat(out, &buf))
rmdir(out);
out = ompi_os_path(true, a[0], a[1], NULL);
out = orte_os_path(true, a[0], a[1], NULL);
if (0 == stat(out, &buf))
rmdir(out);
out = ompi_os_path(true, a[0], NULL);
out = orte_os_path(true, a[0], NULL);
if (0 == stat(out, &buf))
rmdir(out);
return(false);
}
return(true);
}
#endif

Просмотреть файл

@ -14,7 +14,7 @@
* $HEADER$
*/
#include "ompi_config.h"
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -22,15 +22,6 @@
#include <sys/param.h>
#endif
int main(int argc, char **argv)
{
printf("Test disabled - Does not compile.\n");
return 77;
}
#if 0
#include "util/sys_info.h"
#include "util/os_path.h"
#include "support.h"
@ -45,41 +36,43 @@ static bool test5(void); /* very long path name test */
int main(int argc, char* argv[])
{
test_init("ompi_os_path_t");
test_init("orte_os_path_t");
/* setup the system info structure */
orte_sys_info();
if (test1()) {
test_success();
}
else {
test_failure("ompi_os_path_t test1 failed");
test_failure("orte_os_path_t test1 failed");
}
if (test2()) {
test_success();
}
else {
test_failure("ompi_os_path_t test2 failed");
test_failure("orte_os_path_t test2 failed");
}
if (test3()) {
test_success();
}
else {
test_failure("ompi_os_path_t test3 failed");
test_failure("orte_os_path_t test3 failed");
}
if (test4()) {
test_success();
}
else {
test_failure("ompi_os_path_t test4 failed");
test_failure("orte_os_path_t test4 failed");
}
if (test5()) {
test_success();
}
else {
test_failure("ompi_os_path_t test5 failed");
test_failure("orte_os_path_t test5 failed");
}
test_finalize();
@ -89,17 +82,18 @@ int main(int argc, char* argv[])
static bool test1(void)
{
char *out;
char *out, *answer;
/* Test trivial functionality. Program should return "." when called in relative
/* Test trivial functionality. Program should return ".[separator]" when called in relative
* mode, and the separator character when called in absolute mode. */
if (NULL != (out = ompi_os_path(true,NULL))) {
if (0 != strcmp(".", out))
if (NULL != (out = orte_os_path(true,NULL))) {
answer = strdup(".");
strcat(answer, orte_system_info.path_sep);
if (0 != strcmp(answer, out))
return(false);
}
if (NULL != (out = ompi_os_path(false,NULL))) {
if (0 != strcmp(ompi_system_info.path_sep, out))
if (NULL != (out = orte_os_path(false,NULL))) {
if (0 != strcmp(orte_system_info.path_sep, out))
return(false);
}
@ -112,26 +106,26 @@ static bool test2(void)
char *out;
char *a[] = { "aaa", "bbb", "ccc", NULL };
if (NULL == ompi_system_info.path_sep) {
if (NULL == orte_system_info.path_sep) {
printf("test2 cannot be run\n");
return(false);
}
/* Construct a relative path name and see if it comes back correctly. Check multiple depths. */
out = strdup(".");
out = strcat(out, ompi_system_info.path_sep);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[0]);
if (0 != strcmp(out, ompi_os_path(true, a[0], NULL)))
if (0 != strcmp(out, orte_os_path(true, a[0], NULL)))
return(false);
out = strcat(out, ompi_system_info.path_sep);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[1]);
if (0 != strcmp(out, ompi_os_path(true, a[0], a[1], NULL)))
if (0 != strcmp(out, orte_os_path(true, a[0], a[1], NULL)))
return(false);
out = strcat(out, ompi_system_info.path_sep);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[2]);
if (0 != strcmp(out, ompi_os_path(true, a[0], a[1], a[2], NULL)))
if (0 != strcmp(out, orte_os_path(true, a[0], a[1], a[2], NULL)))
return(false);
return true;
@ -143,25 +137,25 @@ static bool test3(void)
char *out;
char *a[] = { "aaa", "bbb", "ccc", NULL };
if (NULL == ompi_system_info.path_sep) {
if (NULL == orte_system_info.path_sep) {
printf("test3 cannot be run\n");
return(false);
}
/* Same as prior test, only with absolute path name */
out = strdup(ompi_system_info.path_sep);
out = strdup(orte_system_info.path_sep);
out = strcat(out, a[0]);
if (0 != strcmp(out, ompi_os_path(false, a[0], NULL)))
if (0 != strcmp(out, orte_os_path(false, a[0], NULL)))
return(false);
out = strcat(out, ompi_system_info.path_sep);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[1]);
if (0 != strcmp(out, ompi_os_path(false, a[0], a[1], NULL)))
if (0 != strcmp(out, orte_os_path(false, a[0], a[1], NULL)))
return(false);
out = strcat(out, ompi_system_info.path_sep);
out = strcat(out, orte_system_info.path_sep);
out = strcat(out, a[2]);
if (0 != strcmp(out, ompi_os_path(false, a[0], a[1], a[2], NULL)))
if (0 != strcmp(out, orte_os_path(false, a[0], a[1], a[2], NULL)))
return(false);
return true;
@ -172,7 +166,7 @@ static bool test4(void)
char a[MAXPATHLEN + 10];
int i;
if (NULL == ompi_system_info.path_sep) {
if (NULL == orte_system_info.path_sep) {
printf("test4 cannot be run\n");
return(false);
}
@ -180,7 +174,7 @@ static bool test4(void)
for (i=0; i< MAXPATHLEN+5; i++) {
a[i] = 'a';
}
if (NULL != ompi_os_path(false, a, NULL)) {
if (NULL != orte_os_path(false, a, NULL)) {
return(false);
}
return (true);
@ -191,12 +185,9 @@ static bool test5(void)
/* test to ensure the program doesn't bomb when no separator is found.
* Program should try to find one, then return NULL if it can't */
if (NULL != ompi_system_info.path_sep) {
free(ompi_system_info.path_sep);
ompi_system_info.path_sep = NULL;
if (NULL != orte_system_info.path_sep) {
free(orte_system_info.path_sep);
orte_system_info.path_sep = NULL;
}
return(test1());
}
#endif

Просмотреть файл

@ -14,7 +14,7 @@
* $HEADER$
*/
#include "ompi_config.h"
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -29,14 +29,6 @@
#endif
#include <sys/stat.h>
int main(int argc, char **argv)
{
printf("Test disabled - Does not compile.\n");
return 77;
}
#if 0
#include "include/constants.h"
#include "util/sys_info.h"
#include "util/os_path.h"
@ -61,9 +53,9 @@ static FILE *test_out=NULL;
int main(int argc, char* argv[])
{
ompi_sys_info(); /* initialize system */
orte_sys_info(); /* initialize system */
test_init("ompi_session_dir_t");
test_init("orte_session_dir_t");
test_out = fopen( "test_session_dir_out", "w+" );
if( test_out == NULL ) {
test_failure("test_session_dir couldn't open test file failed");
@ -77,7 +69,7 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_session_dir_t test1 failed");
test_failure("orte_session_dir_t test1 failed");
}
fprintf(test_out, "running test2\n");
@ -85,7 +77,7 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_session_dir_t test2 failed");
test_failure("orte_session_dir_t test2 failed");
}
fprintf(test_out, "running test3\n");
@ -93,7 +85,7 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_session_dir_t test3 failed");
test_failure("orte_session_dir_t test3 failed");
}
fprintf(test_out, "running test4\n");
@ -101,7 +93,7 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_session_dir_t test4 failed");
test_failure("orte_session_dir_t test4 failed");
}
fprintf(test_out, "running test5\n");
@ -109,7 +101,7 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_session_dir_t test5 failed");
test_failure("orte_session_dir_t test5 failed");
}
fprintf(test_out, "running test6\n");
@ -117,7 +109,7 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_session_dir_t test6 failed");
test_failure("orte_session_dir_t test6 failed");
}
fprintf(test_out, "running test7\n");
@ -125,7 +117,7 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_session_dir_t test7 failed");
test_failure("orte_session_dir_t test7 failed");
}
fprintf(test_out, "running test8\n");
@ -133,7 +125,7 @@ int main(int argc, char* argv[])
test_success();
}
else {
test_failure("ompi_session_dir_t test8 failed");
test_failure("orte_session_dir_t test8 failed");
}
fprintf(test_out, "completed all tests\n");
@ -154,24 +146,24 @@ static bool test1(void)
clear_proc_info();
prefix = ompi_os_path(false, "tmp", NULL);
if (OMPI_ERROR == ompi_session_dir(true, prefix, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
prefix = orte_os_path(false, "tmp", NULL);
if (OMPI_ERROR == orte_session_dir(true, prefix, orte_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
fprintf(test_out, "test1 - couldn't create specified path\n");
free(prefix);
return(false);
}
/* see if it can access an existing path */
if (OMPI_ERROR == ompi_session_dir(false, prefix, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
if (OMPI_ERROR == orte_session_dir(false, prefix, orte_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
fprintf(test_out, "test1 - couldn't access existing path\n");
free(prefix);
return(false);
}
rmdir(ompi_process_info.universe_session_dir);
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
rmdir(orte_process_info.universe_session_dir);
tmp = strdup(dirname(orte_process_info.universe_session_dir));
rmdir(tmp);
free(ompi_process_info.universe_session_dir);
free(orte_process_info.universe_session_dir);
free(prefix);
free(tmp);
@ -189,13 +181,13 @@ static bool test2(void)
setenv("OMPI_PREFIX_ENV", "/tmp/trythis", 1);
if (OMPI_ERROR == ompi_session_dir(true, NULL, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
if (OMPI_ERROR == orte_session_dir(true, NULL, orte_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
unsetenv("OMPI_PREFIX_ENV");
return(false);
}
rmdir(ompi_process_info.universe_session_dir);
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
rmdir(orte_process_info.universe_session_dir);
tmp = strdup(dirname(orte_process_info.universe_session_dir));
rmdir(tmp);
free(tmp);
@ -215,13 +207,13 @@ static bool test3(void)
setenv("TMPDIR", "/tmp/trythis", 1);
if (OMPI_ERROR == ompi_session_dir(true, NULL, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
if (OMPI_ERROR == orte_session_dir(true, NULL, orte_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
unsetenv("TMPDIR");
return(false);
}
rmdir(ompi_process_info.universe_session_dir);
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
rmdir(orte_process_info.universe_session_dir);
tmp = strdup(dirname(orte_process_info.universe_session_dir));
rmdir(tmp);
free(tmp);
@ -240,13 +232,13 @@ static bool test4(void)
setenv("TMP", "/tmp/trythis", 1);
if (OMPI_ERROR == ompi_session_dir(true, NULL, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
if (OMPI_ERROR == orte_session_dir(true, NULL, orte_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
unsetenv("TMP");
return(false);
}
rmdir(ompi_process_info.universe_session_dir);
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
rmdir(orte_process_info.universe_session_dir);
tmp = strdup(dirname(orte_process_info.universe_session_dir));
rmdir(tmp);
free(tmp);
@ -265,13 +257,13 @@ static bool test5(void)
setenv("HOME", "/tmp/trythis", 1);
if (OMPI_ERROR == ompi_session_dir(true, NULL, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
if (OMPI_ERROR == orte_session_dir(true, NULL, orte_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
unsetenv("HOME");
return(false);
}
rmdir(ompi_process_info.universe_session_dir);
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
rmdir(orte_process_info.universe_session_dir);
tmp = strdup(dirname(orte_process_info.universe_session_dir));
rmdir(tmp);
free(tmp);
@ -291,12 +283,12 @@ static bool test6(void)
* Program should turn to default of /tmp (where "/" is whatever
* top-level directory is appropriate for given system)
*/
if (OMPI_ERROR == ompi_session_dir(true, NULL, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
if (OMPI_ERROR == orte_session_dir(true, NULL, orte_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
return(false);
}
rmdir(ompi_process_info.universe_session_dir);
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
rmdir(orte_process_info.universe_session_dir);
tmp = strdup(dirname(orte_process_info.universe_session_dir));
rmdir(tmp);
return(true);
@ -310,33 +302,33 @@ static bool test7(void)
clear_proc_info();
/* create test proc session directory tree */
if (OMPI_ERROR == ompi_session_dir(true, NULL, ompi_system_info.user, "localhost", NULL, "test-universe", "test-job", "test-proc")) {
if (OMPI_ERROR == orte_session_dir(true, NULL, orte_system_info.user, "localhost", NULL, "test-universe", "test-job", "test-proc")) {
return(false);
}
fprintf(test_out, "removing directories: %s\n\t%s\n\t%s\n",
ompi_process_info.proc_session_dir,
ompi_process_info.job_session_dir,
ompi_process_info.universe_session_dir);
orte_process_info.proc_session_dir,
orte_process_info.job_session_dir,
orte_process_info.universe_session_dir);
/* create some files */
filenm = ompi_os_path(false, ompi_process_info.proc_session_dir, "dum1", NULL);
filenm = orte_os_path(false, orte_process_info.proc_session_dir, "dum1", NULL);
fp = fopen(filenm, "w");
fprintf(fp, "ss");
fclose(fp);
filenm = ompi_os_path(false, ompi_process_info.job_session_dir, "dum2", NULL);
filenm = orte_os_path(false, orte_process_info.job_session_dir, "dum2", NULL);
fp = fopen(filenm, "w");
fprintf(fp, "ss");
fclose(fp);
filenm = ompi_os_path(false, ompi_process_info.universe_session_dir, "dum3", NULL);
filenm = orte_os_path(false, orte_process_info.universe_session_dir, "dum3", NULL);
fp = fopen(filenm, "w");
fprintf(fp, "ss");
fclose(fp);
if (OMPI_ERROR == ompi_session_dir_finalize()) {
if (OMPI_ERROR == orte_session_dir_finalize()) {
return(false);
}
@ -351,37 +343,37 @@ static bool test8(void)
clear_proc_info();
/* create test proc session directory tree */
if (OMPI_ERROR == ompi_session_dir(true, NULL, ompi_system_info.user, "localhost", NULL, "test-universe2", "test-job", "test-proc")) {
if (OMPI_ERROR == orte_session_dir(true, NULL, orte_system_info.user, "localhost", NULL, "test-universe2", "test-job", "test-proc")) {
return(false);
}
fprintf(test_out, "removing directories: %s\n\t%s\n\t%s\n",
ompi_process_info.proc_session_dir,
ompi_process_info.job_session_dir,
ompi_process_info.universe_session_dir);
orte_process_info.proc_session_dir,
orte_process_info.job_session_dir,
orte_process_info.universe_session_dir);
/* create some files */
filenm = ompi_os_path(false, ompi_process_info.proc_session_dir, "dum1", NULL);
filenm = orte_os_path(false, orte_process_info.proc_session_dir, "dum1", NULL);
fp = fopen(filenm, "w");
fprintf(fp, "ss");
fclose(fp);
filenm = ompi_os_path(false, ompi_process_info.job_session_dir, "dum2", NULL);
filenm = orte_os_path(false, orte_process_info.job_session_dir, "dum2", NULL);
fp = fopen(filenm, "w");
fprintf(fp, "ss");
fclose(fp);
filenm = ompi_os_path(false, ompi_process_info.universe_session_dir, "dum3", NULL);
filenm = orte_os_path(false, orte_process_info.universe_session_dir, "dum3", NULL);
fp = fopen(filenm, "w");
fprintf(fp, "ss");
fclose(fp);
filenm = ompi_os_path( false, ompi_process_info.job_session_dir, "dir1", NULL);
ompi_os_create_dirpath(filenm, 0777);
filenm = orte_os_path( false, orte_process_info.job_session_dir, "dir1", NULL);
orte_os_create_dirpath(filenm, 0777);
if (OMPI_ERROR == ompi_session_dir_finalize()) {
if (OMPI_ERROR == orte_session_dir_finalize()) {
return(false);
}
@ -390,11 +382,10 @@ static bool test8(void)
void clear_proc_info(void)
{
ompi_process_info.tmpdir_base = NULL;
ompi_process_info.top_session_dir = NULL;
ompi_process_info.universe_session_dir = NULL;
ompi_process_info.job_session_dir = NULL;
ompi_process_info.proc_session_dir = NULL;
orte_process_info.tmpdir_base = NULL;
orte_process_info.top_session_dir = NULL;
orte_process_info.universe_session_dir = NULL;
orte_process_info.job_session_dir = NULL;
orte_process_info.proc_session_dir = NULL;
}
#endif

Просмотреть файл

@ -22,14 +22,6 @@
#include <sys/param.h>
#endif
int main(int argc, char **argv)
{
printf("Test disabled - Does not compile.\n");
return 77;
}
#if 0
#include "util/sys_info.h"
#include "support.h"
@ -40,20 +32,20 @@ static bool test2(void); /* test second time through */
int main(int argc, char* argv[])
{
test_init("ompi_sys_info_t");
test_init("orte_sys_info_t");
if (test1()) {
test_success();
}
else {
test_failure("ompi_sys_info_t test1 failed");
test_failure("orte_sys_info_t test1 failed");
}
if (test2()) {
test_success();
}
else {
test_failure("ompi_sys_info_t test2 failed");
test_failure("orte_sys_info_t test2 failed");
}
test_finalize();
@ -65,16 +57,17 @@ static bool test1(void)
{
/* Test trivial functionality. Program should return with init=true and all ptrs non-NULL */
ompi_sys_info();
if (ompi_system_info.init == false)
orte_sys_info();
if (orte_system_info.init == false)
return(false);
if (ompi_system_info.sysname == NULL ||
ompi_system_info.nodename == NULL ||
ompi_system_info.release == NULL ||
ompi_system_info.version == NULL ||
ompi_system_info.machine == NULL ||
ompi_system_info.path_sep == NULL)
if (orte_system_info.sysname == NULL ||
orte_system_info.nodename == NULL ||
orte_system_info.release == NULL ||
orte_system_info.version == NULL ||
orte_system_info.machine == NULL ||
orte_system_info.user == NULL ||
orte_system_info.path_sep == NULL)
return(false);
return true;
@ -84,7 +77,6 @@ static bool test1(void)
static bool test2(void)
{
/* test it a second time. system should return without crashing and with init=true */
ompi_sys_info();
return(ompi_system_info.init);
orte_sys_info();
return(orte_system_info.init);
}
#endif