2004-05-25 21:38:16 +00:00
|
|
|
/*
|
2004-11-22 01:38:40 +00:00
|
|
|
* 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.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-05-25 21:38:16 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 01:03:09 +00:00
|
|
|
#include "ompi_config.h"
|
2004-05-25 21:38:16 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2004-10-20 01:03:09 +00:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
2004-05-25 21:38:16 +00:00
|
|
|
#include <sys/param.h>
|
2004-10-20 01:03:09 +00:00
|
|
|
#endif
|
2004-05-25 21:38:16 +00:00
|
|
|
|
2005-03-22 14:41:45 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
printf("Test disabled - Does not compile.\n");
|
|
|
|
return 77;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
2004-05-25 21:38:16 +00:00
|
|
|
#include "util/sys_info.h"
|
|
|
|
#include "util/os_path.h"
|
2004-08-09 21:39:31 +00:00
|
|
|
#include "support.h"
|
2004-05-25 21:38:16 +00:00
|
|
|
|
|
|
|
static bool test1(void); /* trivial answer test */
|
|
|
|
static bool test2(void); /* relative path test */
|
|
|
|
static bool test3(void); /* absolute path test */
|
|
|
|
static bool test4(void); /* missing path separator test */
|
|
|
|
static bool test5(void); /* very long path name test */
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
|
2004-08-09 21:39:31 +00:00
|
|
|
test_init("ompi_os_path_t");
|
2004-05-25 21:38:16 +00:00
|
|
|
|
|
|
|
if (test1()) {
|
2004-08-09 21:39:31 +00:00
|
|
|
test_success();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
test_failure("ompi_os_path_t test1 failed");
|
2004-05-25 21:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test2()) {
|
2004-08-09 21:39:31 +00:00
|
|
|
test_success();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
test_failure("ompi_os_path_t test2 failed");
|
2004-05-25 21:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test3()) {
|
2004-08-09 21:39:31 +00:00
|
|
|
test_success();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
test_failure("ompi_os_path_t test3 failed");
|
2004-05-25 21:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test4()) {
|
2004-08-09 21:39:31 +00:00
|
|
|
test_success();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
test_failure("ompi_os_path_t test4 failed");
|
2004-05-25 21:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test5()) {
|
2004-08-09 21:39:31 +00:00
|
|
|
test_success();
|
2004-05-25 21:38:16 +00:00
|
|
|
}
|
2004-08-09 21:39:31 +00:00
|
|
|
else {
|
|
|
|
test_failure("ompi_os_path_t test5 failed");
|
2004-05-25 21:38:16 +00:00
|
|
|
}
|
|
|
|
|
2004-08-09 21:39:31 +00:00
|
|
|
test_finalize();
|
|
|
|
return 0;
|
2004-05-25 21:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool test1(void)
|
|
|
|
{
|
|
|
|
char *out;
|
|
|
|
|
|
|
|
/* Test trivial functionality. Program should return "." 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))
|
|
|
|
return(false);
|
|
|
|
}
|
|
|
|
if (NULL != (out = ompi_os_path(false,NULL))) {
|
|
|
|
if (0 != strcmp(ompi_system_info.path_sep, out))
|
|
|
|
return(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool test2(void)
|
|
|
|
{
|
|
|
|
char *out;
|
|
|
|
char *a[] = { "aaa", "bbb", "ccc", NULL };
|
|
|
|
|
|
|
|
if (NULL == ompi_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, a[0]);
|
|
|
|
if (0 != strcmp(out, ompi_os_path(true, a[0], NULL)))
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
out = strcat(out, ompi_system_info.path_sep);
|
|
|
|
out = strcat(out, a[1]);
|
|
|
|
if (0 != strcmp(out, ompi_os_path(true, a[0], a[1], NULL)))
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
out = strcat(out, ompi_system_info.path_sep);
|
|
|
|
out = strcat(out, a[2]);
|
|
|
|
if (0 != strcmp(out, ompi_os_path(true, a[0], a[1], a[2], NULL)))
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool test3(void)
|
|
|
|
{
|
|
|
|
char *out;
|
|
|
|
char *a[] = { "aaa", "bbb", "ccc", NULL };
|
|
|
|
|
|
|
|
if (NULL == ompi_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 = strcat(out, a[0]);
|
|
|
|
if (0 != strcmp(out, ompi_os_path(false, a[0], NULL)))
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
out = strcat(out, ompi_system_info.path_sep);
|
|
|
|
out = strcat(out, a[1]);
|
|
|
|
if (0 != strcmp(out, ompi_os_path(false, a[0], a[1], NULL)))
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
out = strcat(out, ompi_system_info.path_sep);
|
|
|
|
out = strcat(out, a[2]);
|
|
|
|
if (0 != strcmp(out, ompi_os_path(false, a[0], a[1], a[2], NULL)))
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool test4(void)
|
|
|
|
{
|
|
|
|
char a[MAXPATHLEN + 10];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (NULL == ompi_system_info.path_sep) {
|
|
|
|
printf("test4 cannot be run\n");
|
|
|
|
return(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i< MAXPATHLEN+5; i++) {
|
|
|
|
a[i] = 'a';
|
|
|
|
}
|
|
|
|
if (NULL != ompi_os_path(false, a, NULL)) {
|
|
|
|
return(false);
|
|
|
|
}
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return(test1());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-22 14:41:45 +00:00
|
|
|
#endif
|