diff options
| author | Daiki Ueno <dueno@redhat.com> | 2019-06-01 09:17:00 +0200 | 
|---|---|---|
| committer | Daiki Ueno <ueno@gnu.org> | 2019-06-18 14:17:28 +0200 | 
| commit | 6bebd5747aa49d4a124d23d4967f65a771799fe5 (patch) | |
| tree | ecaf0c0a800f34e262d16dbaa4b3e6deeef4a5f4 | |
| parent | 51382cd59c89e862443421a9d697a709f2244f36 (diff) | |
tests: Add tmpdir argument to p11_test_copy_setgid
To prevent BUILDDIR being embedded in the library.
| -rw-r--r-- | common/test-compat.c | 4 | ||||
| -rw-r--r-- | common/test.c | 7 | ||||
| -rw-r--r-- | common/test.h | 3 | ||||
| -rw-r--r-- | p11-kit/test-conf.c | 2 | 
4 files changed, 10 insertions, 6 deletions
| diff --git a/common/test-compat.c b/common/test-compat.c index 8b5d2e6..e1deac8 100644 --- a/common/test-compat.c +++ b/common/test-compat.c @@ -70,7 +70,7 @@ test_getauxval (void)  	ret = p11_test_run_child (args, true);  	assert_num_eq (ret, 0); -	path = p11_test_copy_setgid (args[0]); +	path = p11_test_copy_setgid (args[0], BUILDDIR);  	if (path == NULL)  		return; @@ -95,7 +95,7 @@ test_secure_getenv (void)  	ret = p11_test_run_child (args, true);  	assert_num_eq (ret, 5); -	path = p11_test_copy_setgid (args[0]); +	path = p11_test_copy_setgid (args[0], BUILDDIR);  	if (path == NULL)  		return; diff --git a/common/test.c b/common/test.c index 3827ab0..9749a91 100644 --- a/common/test.c +++ b/common/test.c @@ -579,7 +579,8 @@ copy_file (const char *input,  }  char * -p11_test_copy_setgid (const char *input) +p11_test_copy_setgid (const char *input, +		      const char *tmpdir)  {  	gid_t groups[128];  		char *path; @@ -600,7 +601,9 @@ p11_test_copy_setgid (const char *input)  		return NULL;  	} -	path = strdup (BUILDDIR "/test-setgid.XXXXXX"); +	if (asprintf(&path, "%s/test-setgid.XXXXXX", tmpdir) < 0) +		assert_not_reached(); +  	assert (path != NULL);  	fd = mkstemp (path); diff --git a/common/test.h b/common/test.h index 1c952b0..81b90f6 100644 --- a/common/test.h +++ b/common/test.h @@ -162,7 +162,8 @@ void        p11_test_file_delete    (const char *directory,  #ifdef OS_UNIX -char *      p11_test_copy_setgid    (const char *path); +char *      p11_test_copy_setgid    (const char *path, +				     const char *tmpdir);  int         p11_test_run_child      (const char **argv,                                       bool quiet_out); diff --git a/p11-kit/test-conf.c b/p11-kit/test-conf.c index a140aaa..f4ef0f6 100644 --- a/p11-kit/test-conf.c +++ b/p11-kit/test-conf.c @@ -410,7 +410,7 @@ test_setuid (void)  	ret = p11_test_run_child (args, true);  	assert_num_eq (ret, 33); -	path = p11_test_copy_setgid (args[0]); +	path = p11_test_copy_setgid (args[0], BUILDDIR);  	if (path == NULL)  		return; | 
