custom-env: Add support for argument array
execve() takes the same form for arguments as environment: an array of constant pointers to mutable strings, terminated by a NULL. To make it easier for users who want to build up their own argument strings to pass to execve, add support for argument arrays to custom_env. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
committed by
Pekka Paalanen
parent
2a9cae17d8
commit
e568a025e1
@@ -73,6 +73,8 @@ setup_env(struct weston_test_harness *harness)
|
||||
|
||||
DECLARE_FIXTURE_SETUP(setup_env);
|
||||
|
||||
#define DEFAULT_ENVP (char * const []) { "ENV1=one", "ENV2=two", "ENV3=three", NULL }
|
||||
|
||||
TEST(basic_env)
|
||||
{
|
||||
struct custom_env env;
|
||||
@@ -85,3 +87,20 @@ TEST(basic_env)
|
||||
assert(env.env_finalized);
|
||||
custom_env_fini(&env);
|
||||
}
|
||||
|
||||
TEST(basic_env_arg)
|
||||
{
|
||||
struct custom_env env;
|
||||
char *const argp[] = { "arg1", "arg2", "arg3", NULL };
|
||||
|
||||
custom_env_init_from_environ(&env);
|
||||
custom_env_add_arg(&env, "arg1");
|
||||
custom_env_add_arg(&env, "arg2");
|
||||
custom_env_add_arg(&env, "arg3");
|
||||
|
||||
ASSERT_STR_ARRAY_MATCH("envp", custom_env_get_envp(&env), DEFAULT_ENVP);
|
||||
assert(env.env_finalized);
|
||||
ASSERT_STR_ARRAY_MATCH("argp", custom_env_get_argp(&env), argp);
|
||||
assert(env.arg_finalized);
|
||||
custom_env_fini(&env);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user