Update unit test for session directory generator.
This commit was SVN r1958.
Этот коммит содержится в:
родитель
17a929c9dd
Коммит
b60e7fc95a
@ -11,6 +11,7 @@ noinst_PROGRAMS = \
|
||||
ompi_os_path \
|
||||
ompi_sys_info \
|
||||
ompi_os_create_dirpath \
|
||||
ompi_session_dir \
|
||||
ompi_argv
|
||||
|
||||
ompi_numtostr_SOURCES = ompi_numtostr.c
|
||||
@ -89,3 +90,23 @@ ompi_os_create_dirpath_LDADD = \
|
||||
$(top_builddir)/src/util/os_create_dirpath.lo \
|
||||
$(top_builddir)/test/support/libsupport.la
|
||||
ompi_os_create_dirpath_DEPENDENCIES = $(ompi_os_create_dirpath_LDADD)
|
||||
|
||||
ompi_session_dir_SOURCES = ompi_session_dir.c
|
||||
ompi_session_dir_LDADD = \
|
||||
$(top_builddir)/src/util/sys_info.lo \
|
||||
$(top_builddir)/src/class/ompi_object.lo \
|
||||
$(top_builddir)/src/util/malloc.lo \
|
||||
$(top_builddir)/src/util/output.lo \
|
||||
$(top_builddir)/src/util/argv.lo \
|
||||
$(top_builddir)/src/util/strncpy.lo \
|
||||
$(top_builddir)/src/threads/mutex.lo \
|
||||
$(top_builddir)/src/threads/mutex_pthread.lo \
|
||||
$(top_builddir)/src/threads/mutex_spinlock.lo \
|
||||
$(top_builddir)/src/threads/mutex_spinwait.lo \
|
||||
$(top_builddir)/src/util/os_path.lo \
|
||||
$(top_builddir)/src/util/os_create_dirpath.lo \
|
||||
$(top_builddir)/src/util/proc_info.lo \
|
||||
$(top_builddir)/src/util/session_dir.lo \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/test/support/libsupport.la
|
||||
ompi_session_dir_DEPENDENCIES = $(ompi_session_dir_LDADD)
|
||||
|
@ -16,6 +16,27 @@
|
||||
#include "util/os_path.h"
|
||||
#include "util/session_dir.h"
|
||||
|
||||
struct ompi_proc_info_t {
|
||||
bool init; /**< Certifies that values have been filled.
|
||||
* Certifies that the ompi_sys_info() function has been
|
||||
* called at least once so fields have valid values
|
||||
*/
|
||||
char *universe_session_dir; /**< Location of universe temp dir.
|
||||
* The session directory has the form
|
||||
* <prefix><openmpi-sessions-user><universe>, where the prefix
|
||||
* can either be provided by the user via the
|
||||
* --tmpdir command-line flag, the use of one of several
|
||||
* environmental variables, or else a default location.
|
||||
*/
|
||||
|
||||
char *job_session_dir; /**< Session directory for job */
|
||||
|
||||
char *proc_session_dir; /**< Session directory for the process */
|
||||
};
|
||||
typedef struct ompi_proc_info_t ompi_proc_info_t;
|
||||
|
||||
ompi_proc_info_t ompi_process_info;
|
||||
|
||||
static bool test1(void); /* given prefix, both one that works and one that fails */
|
||||
static bool test2(void); /* no prefix given, OMPI_PREFIX_ENV set, one good and one bad */
|
||||
static bool test3(void); /* no prefix given, TMPDIR set, one good and one bad */
|
||||
@ -36,6 +57,8 @@ int main(int argc, char* argv[])
|
||||
if (test1()) {
|
||||
printf("test1 passed\n");
|
||||
test1f = true;
|
||||
} else {
|
||||
printf("test1 failed\n");
|
||||
}
|
||||
|
||||
if (test2()) {
|
||||
@ -82,30 +105,32 @@ static bool test1(void)
|
||||
/* see if we can create a specified path */
|
||||
|
||||
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, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
|
||||
printf("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(prefix, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) {
|
||||
if (OMPI_ERROR == ompi_session_dir(false, prefix, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
|
||||
printf("test1 - couldn't access existing path\n");
|
||||
free(prefix);
|
||||
return(false);
|
||||
}
|
||||
|
||||
rmdir(ompi_system_info.session_dir);
|
||||
tmp = strdup(dirname(ompi_system_info.session_dir));
|
||||
rmdir(ompi_process_info.universe_session_dir);
|
||||
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
|
||||
rmdir(tmp);
|
||||
free(ompi_system_info.session_dir);
|
||||
free(ompi_process_info.universe_session_dir);
|
||||
free(prefix);
|
||||
free(tmp);
|
||||
|
||||
/* 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 */
|
||||
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, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
|
||||
printf("created temp directory in %s - shouldn't have been able to do so\n", tmp2);
|
||||
rmdir(ompi_system_info.session_dir);
|
||||
tmp = strdup(dirname(ompi_system_info.session_dir));
|
||||
rmdir(ompi_process_info.universe_session_dir);
|
||||
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
|
||||
rmdir(tmp);
|
||||
free(tmp);
|
||||
free(tmp2);
|
||||
@ -124,13 +149,13 @@ static bool test2(void)
|
||||
|
||||
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, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
|
||||
unsetenv("OMPI_PREFIX_ENV");
|
||||
return(false);
|
||||
}
|
||||
|
||||
rmdir(ompi_system_info.session_dir);
|
||||
tmp = strdup(dirname(ompi_system_info.session_dir));
|
||||
rmdir(ompi_process_info.universe_session_dir);
|
||||
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
|
||||
rmdir(tmp);
|
||||
free(tmp);
|
||||
|
||||
@ -148,13 +173,13 @@ static bool test3(void)
|
||||
|
||||
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, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
|
||||
unsetenv("TMPDIR");
|
||||
return(false);
|
||||
}
|
||||
|
||||
rmdir(ompi_system_info.session_dir);
|
||||
tmp = strdup(dirname(ompi_system_info.session_dir));
|
||||
rmdir(ompi_process_info.universe_session_dir);
|
||||
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
|
||||
rmdir(tmp);
|
||||
free(tmp);
|
||||
|
||||
@ -171,13 +196,13 @@ static bool test4(void)
|
||||
|
||||
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, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
|
||||
unsetenv("TMP");
|
||||
return(false);
|
||||
}
|
||||
|
||||
rmdir(ompi_system_info.session_dir);
|
||||
tmp = strdup(dirname(ompi_system_info.session_dir));
|
||||
rmdir(ompi_process_info.universe_session_dir);
|
||||
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
|
||||
rmdir(tmp);
|
||||
free(tmp);
|
||||
|
||||
@ -194,13 +219,13 @@ static bool test5(void)
|
||||
|
||||
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, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
|
||||
unsetenv("HOME");
|
||||
return(false);
|
||||
}
|
||||
|
||||
rmdir(ompi_system_info.session_dir);
|
||||
tmp = strdup(dirname(ompi_system_info.session_dir));
|
||||
rmdir(ompi_process_info.universe_session_dir);
|
||||
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
|
||||
rmdir(tmp);
|
||||
free(tmp);
|
||||
|
||||
@ -218,12 +243,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(NULL, "test-universe", ompi_system_info.user, NULL, NULL, NULL, NULL)) {
|
||||
if (OMPI_ERROR == ompi_session_dir(true, NULL, ompi_system_info.user, NULL, NULL, "test-universe", NULL, NULL)) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
rmdir(ompi_system_info.session_dir);
|
||||
tmp = strdup(dirname(ompi_system_info.session_dir));
|
||||
rmdir(ompi_process_info.universe_session_dir);
|
||||
tmp = strdup(dirname(ompi_process_info.universe_session_dir));
|
||||
rmdir(tmp);
|
||||
|
||||
return(true);
|
@ -51,7 +51,6 @@ static bool test1(void)
|
||||
return(false);
|
||||
|
||||
if (ompi_system_info.sysname == NULL ||
|
||||
ompi_system_info.pid <= 0 ||
|
||||
ompi_system_info.nodename == NULL ||
|
||||
ompi_system_info.release == NULL ||
|
||||
ompi_system_info.version == NULL ||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user