* rework build_base_env to take an env pointer rather than assuming environ
* rework build_base_env to use newly discovered (by me, anyway) argv interface * add test case for build_base_env where I discovered I can't do boolean logic.... This commit was SVN r2209.
Этот коммит содержится в:
родитель
8ff450f0ee
Коммит
faebdd3404
@ -35,7 +35,7 @@ extern "C" {
|
||||
ompi_rte_node_schedule_t *sched,
|
||||
ompi_list_t *nodelist);
|
||||
|
||||
int mca_pcm_base_build_base_env(char ***envp);
|
||||
int mca_pcm_base_build_base_env(char **in_env, char ***out_envp);
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
extern char **environ;
|
||||
|
||||
char *
|
||||
mca_pcm_base_no_unique_name(void)
|
||||
{
|
||||
@ -22,28 +20,24 @@ mca_pcm_base_no_unique_name(void)
|
||||
|
||||
|
||||
int
|
||||
mca_pcm_base_build_base_env(char ***envp)
|
||||
mca_pcm_base_build_base_env(char **in_env, char ***out_envp)
|
||||
{
|
||||
char **env = NULL;
|
||||
int envc = 0;
|
||||
int i, j;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
for (i = 0 ; environ[i] != NULL ; ++i) {
|
||||
if (0 != strncmp("OMPI_", environ[i], strlen("OMPI_"))) {
|
||||
++envc;
|
||||
for (i = 0 ; in_env[i] != NULL ; ++i) {
|
||||
if (0 == strncmp("OMPI_", in_env[i], strlen("OMPI_"))) {
|
||||
ret = ompi_argv_append(&envc, &env, in_env[i]);
|
||||
if (OMPI_SUCCESS != ret) {
|
||||
ompi_argv_free(env);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
env = (char**) malloc(sizeof(char*) * (envc + 1));
|
||||
if (NULL == env) return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
*out_envp = env;
|
||||
|
||||
env[envc] = NULL;
|
||||
for (i = 0, j = 0 ; environ[i] != NULL ; ++i) {
|
||||
if (0 != strncmp("OMPI_", environ[i], strlen("OMPI_"))) {
|
||||
env[j] = strdup(environ[i]);
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
@ -11,11 +11,20 @@ EXTRA_DIST = \
|
||||
test2_out_std
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
build_env \
|
||||
sched_comm
|
||||
|
||||
build_env_SOURCES = \
|
||||
build_env.c
|
||||
build_env_LDADD = \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/test/support/libsupport.la
|
||||
build_env_DEPENDENCIES = $(build_env_LDADD)
|
||||
|
||||
sched_comm_SOURCES = \
|
||||
sched_comm.c
|
||||
sched_comm_LDADD = \
|
||||
$(top_builddir)/src/libmpi.la \
|
||||
$(top_builddir)/test/support/libsupport.la
|
||||
sched_comm_DEPENDENCIES = $(sched_comm_LDADD)
|
||||
|
||||
|
60
test/mca/pcm/base/build_env.c
Обычный файл
60
test/mca/pcm/base/build_env.c
Обычный файл
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include "support.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mca/pcm/base/base.h"
|
||||
|
||||
char *env[] = {
|
||||
"ENV0=",
|
||||
"OMPI_MCA_CONFIG_FOO=blah",
|
||||
"ENV1=blah blah blah",
|
||||
"FOO_OMPI_MCA_BLAH=hi there",
|
||||
"ENV2=foo bar is fun",
|
||||
"ENV3=123",
|
||||
NULL
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
int len = 0;
|
||||
char ** out = NULL;
|
||||
int i;
|
||||
|
||||
test_init("sched_comm_t");
|
||||
|
||||
len = ompi_argv_count(env);
|
||||
if (len != 6) {
|
||||
test_failure( "ompi_argv_count(env) failed" );
|
||||
} else {
|
||||
test_success();
|
||||
}
|
||||
|
||||
ret = mca_pcm_base_build_base_env(env, &out);
|
||||
if (OMPI_SUCCESS != ret) {
|
||||
test_failure("mca_pcm_base_build_base_env");
|
||||
} else {
|
||||
test_success();
|
||||
}
|
||||
|
||||
len = ompi_argv_count(out);
|
||||
if (len != 1) {
|
||||
printf("out:\n");
|
||||
for (i = 0 ; out[i] != NULL ; ++i) {
|
||||
printf("\t%s\n", out[i]);
|
||||
}
|
||||
test_failure("ompi_argv_count(out)");
|
||||
} else {
|
||||
test_success();
|
||||
}
|
||||
|
||||
test_finalize();
|
||||
return 0;
|
||||
}
|
Загрузка…
x
Ссылка в новой задаче
Block a user