]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: allow to export custom env vars
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 6 Jun 2012 04:42:30 +0000 (01:42 -0300)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 6 Jun 2012 04:45:30 +0000 (01:45 -0300)
testsuite/testsuite.c
testsuite/testsuite.h

index 14af73ede59e498044e2bc6210e3edde096874b2..cc1d26bd867ff3fa4f74bff09a8a989060ea664d 100644 (file)
@@ -174,6 +174,7 @@ static void test_export_environ(const struct test *t)
        char *preload = NULL;
        size_t preloadlen = 0;
        size_t i;
+       const struct keyval *env;
 
        unsetenv("LD_PRELOAD");
 
@@ -207,6 +208,9 @@ static void test_export_environ(const struct test *t)
                setenv("LD_PRELOAD", preload, 1);
 
        free(preload);
+
+       for (env = t->env_vars; env && env->key; env++)
+               setenv(env->key, env->val, 1);
 }
 
 static inline int test_run_child(const struct test *t, int fdout[2],
index be3bfb85c893a490c1fe621ee870b82803f146a7..e0825d5e9bfc850bd95ccd4491564c1c0b534c07 100644 (file)
@@ -72,6 +72,10 @@ enum test_config {
 #define S_TC_INIT_MODULE_RETCODES "TESTSUITE_INIT_MODULE_RETCODES"
 #define S_TC_DELETE_MODULE_RETCODES "TESTSUITE_DELETE_MODULE_RETCODES"
 
+struct keyval {
+       const char *key;
+       const char *val;
+};
 
 struct test {
        const char *name;
@@ -83,6 +87,7 @@ struct test {
        testfunc func;
        const char *config[_TC_LAST];
        const char *path;
+       const struct keyval *env_vars;
        bool need_spawn;
        bool expected_fail;
 };