1
1

Updated to fix compiler errors. ompi_session_dir.c needs to be re-visited at a later date to make certain that everything is being tested.

This commit was SVN r2067.
Этот коммит содержится в:
Ginger Young 2004-08-11 19:50:58 +00:00
родитель 304d1b832b
Коммит 69b8be7d8c
2 изменённых файлов: 31 добавлений и 46 удалений

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

@ -16,27 +16,15 @@ AM_CPPFLAGS = \
-DLAM_CONFIGURE_HOST="\"@LAM_CONFIGURE_HOST@\"" \ -DLAM_CONFIGURE_HOST="\"@LAM_CONFIGURE_HOST@\"" \
-DLAM_CONFIGURE_DATE="\"@LAM_CONFIGURE_DATE@\"" -DLAM_CONFIGURE_DATE="\"@LAM_CONFIGURE_DATE@\""
libs = $(top_builddir)/src/libmpi.la
bin_PROGRAMS = \ bin_PROGRAMS = \
openmpi openmpi
openmpi_SOURCES = \ openmpi_SOURCES = \
ompi_session_dir.c ompi_session_dir.c
bogus_sources = \
openmpi.h \
ompi_init.h \
ompi_init.c \
openmpi.c
openmpi_LDADD = \ openmpi_LDADD = \
$(libs) \ $(top_builddir)/src/mca/pcm/base/pcm_base_open.lo \
$(LIBMPI_EXTRA_LIBS) \ $(top_builddir)/src/libmpi.la
$(LIBLAM_EXTRA_LIBS) \
$(top_builddir)/src/util/os_path.lo \
$(top_builddir)/src/util/os_create_dirpath.lo \
$(top_builddir)/src/util/sys_info.lo
openmpi_DFLAGS = $(LIBMPI_EXTRA_LDFLAGS) $(LIBLAM_EXTRA_LDFLAGS) openmpi_DFLAGS = $(LIBMPI_EXTRA_LDFLAGS) $(LIBLAM_EXTRA_LDFLAGS)
openmpi_DEPENDENCIES = $(libs) \ openmpi_DEPENDENCIES = $(libs) \

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

@ -82,31 +82,36 @@ static bool test1(void)
/* see if we can create a specified path */ /* see if we can create a specified path */
prefix = ompi_os_path(false, "tmp", NULL); prefix = ompi_os_path(false, "tmp", NULL);
if (OMPI_ERROR == ompi_session_dir_init(prefix, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) { if (OMPI_ERROR == ompi_session_dir(true, prefix, "test-universe",
ompi_system_info.user, NULL, NULL, NULL, NULL)) {
free(prefix); free(prefix);
return(false); return(false);
} }
/* see if it can access an existing path */ /* see if it can access an existing path */
if (OMPI_ERROR == ompi_session_dir(prefix, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) { if (OMPI_ERROR == ompi_session_dir(false, prefix, "test-universe",
ompi_system_info.user, NULL, NULL, NULL, NULL)) {
free(prefix); free(prefix);
return(false); return(false);
} }
rmdir(ompi_system_info.session_dir); /* Currently, to remove the session, we need to call
tmp = strdup(dirname(ompi_system_info.session_dir)); * ompi_session_dir_finalize.
rmdir(tmp); *
free(ompi_system_info.session_dir); * NOTE: this will have to change at a future revision, since the
* plan is to leave the session dir around. We will have to
* call a TBD function that will remove the session.
*/
ompi_session_dir_finalize ();
free(prefix); free(prefix);
free(tmp); free(tmp);
/* check what happens when given prefix that won't allow access */ /* check what happens when given prefix that won't allow access */
tmp2 = ompi_os_path(false, "test", NULL); /* assume we don't have root privileges */ tmp2 = ompi_os_path(false, "test", NULL); /* assume we don't have root privileges */
if (OMPI_SUCCESS == ompi_session_dir(tmp2, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) { if (OMPI_SUCCESS == ompi_session_dir(true, tmp2, "test-universe",
ompi_system_info.user, NULL, NULL, NULL, NULL)) {
printf("created temp directory in %s - shouldn't have been able to do so\n", tmp2); printf("created temp directory in %s - shouldn't have been able to do so\n", tmp2);
rmdir(ompi_system_info.session_dir); ompi_session_dir_finalize();
tmp = strdup(dirname(ompi_system_info.session_dir));
rmdir(tmp);
free(tmp); free(tmp);
free(tmp2); free(tmp2);
return(false); return(false);
@ -124,14 +129,13 @@ static bool test2(void)
setenv("OMPI_PREFIX_ENV", "/tmp/trythis", 1); setenv("OMPI_PREFIX_ENV", "/tmp/trythis", 1);
if (OMPI_ERROR == ompi_session_dir(NULL, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) { if (OMPI_ERROR == ompi_session_dir(true, NULL, "test-universe",
ompi_system_info.user, NULL, NULL, NULL, NULL)) {
unsetenv("OMPI_PREFIX_ENV"); unsetenv("OMPI_PREFIX_ENV");
return(false); return(false);
} }
rmdir(ompi_system_info.session_dir); ompi_session_dir_finalize ();
tmp = strdup(dirname(ompi_system_info.session_dir));
rmdir(tmp);
free(tmp); free(tmp);
unsetenv("OMPI_PREFIX_ENV"); unsetenv("OMPI_PREFIX_ENV");
@ -148,14 +152,13 @@ static bool test3(void)
setenv("TMPDIR", "/tmp/trythis", 1); setenv("TMPDIR", "/tmp/trythis", 1);
if (OMPI_ERROR == ompi_session_dir(NULL, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) { if (OMPI_ERROR == ompi_session_dir(true, NULL, "test-universe",
ompi_system_info.user, NULL, NULL, NULL, NULL)) {
unsetenv("TMPDIR"); unsetenv("TMPDIR");
return(false); return(false);
} }
rmdir(ompi_system_info.session_dir); ompi_session_dir_finalize ();
tmp = strdup(dirname(ompi_system_info.session_dir));
rmdir(tmp);
free(tmp); free(tmp);
unsetenv("TMPDIR"); unsetenv("TMPDIR");
@ -171,14 +174,13 @@ static bool test4(void)
setenv("TMP", "/tmp/trythis", 1); setenv("TMP", "/tmp/trythis", 1);
if (OMPI_ERROR == ompi_session_dir(NULL, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) { if (OMPI_ERROR == ompi_session_dir(true, NULL, "test-universe",
ompi_system_info.user, NULL, NULL, NULL, NULL)) {
unsetenv("TMP"); unsetenv("TMP");
return(false); return(false);
} }
rmdir(ompi_system_info.session_dir); ompi_session_dir_finalize ();
tmp = strdup(dirname(ompi_system_info.session_dir));
rmdir(tmp);
free(tmp); free(tmp);
unsetenv("TMP"); unsetenv("TMP");
@ -194,14 +196,12 @@ static bool test5(void)
setenv("HOME", "/tmp/trythis", 1); setenv("HOME", "/tmp/trythis", 1);
if (OMPI_ERROR == ompi_session_dir(NULL, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) { if (OMPI_ERROR == ompi_session_dir(true, NULL, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) {
unsetenv("HOME"); unsetenv("HOME");
return(false); return(false);
} }
rmdir(ompi_system_info.session_dir); ompi_session_dir_finalize ();
tmp = strdup(dirname(ompi_system_info.session_dir));
rmdir(tmp);
free(tmp); free(tmp);
unsetenv("HOME"); unsetenv("HOME");
@ -212,19 +212,16 @@ static bool test5(void)
static bool test6(void) static bool test6(void)
{ {
char *tmp;
/* no enviro variables set, no prefix given /* no enviro variables set, no prefix given
* Program should turn to default of /tmp (where "/" is whatever * Program should turn to default of /tmp (where "/" is whatever
* top-level directory is appropriate for given system) * top-level directory is appropriate for given system)
*/ */
if (OMPI_ERROR == ompi_session_dir(NULL, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) { if (OMPI_ERROR == ompi_session_dir(true, NULL, "test-universe",
ompi_system_info.user, NULL, NULL, NULL, NULL)) {
return(false); return(false);
} }
rmdir(ompi_system_info.session_dir); ompi_session_dir_finalize();
tmp = strdup(dirname(ompi_system_info.session_dir));
rmdir(tmp);
return(true); return(true);
} }