diff options
author | Daiki Ueno <dueno@redhat.com> | 2018-02-27 14:57:45 +0100 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2018-02-27 16:33:59 +0100 |
commit | d2318ca31774d6a02eff5d0b3af2f3c89cb58c9d (patch) | |
tree | ecdcab6c66207109462c88a0a1faf93f816aedd0 /p11-kit | |
parent | 264ecf416d6d07c558d80031c077a46a909a6f90 (diff) |
test-server: Add test for detecting address
Diffstat (limited to 'p11-kit')
-rw-r--r-- | p11-kit/test-server.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/p11-kit/test-server.c b/p11-kit/test-server.c index d9330a0..ca9ac42 100644 --- a/p11-kit/test-server.c +++ b/p11-kit/test-server.c @@ -79,10 +79,16 @@ setup_server (void *arg) struct pollfd pfd; int ret; const char *envvar; + char *path; test.directory = p11_test_directory ("p11-test-server"); - if (asprintf (&test.socket_path, "%s/pkcs11", test.directory) < 0) + if (asprintf (&path, "%s/p11-kit", test.directory) < 0) assert_not_reached (); + if (mkdir (path, 0700) < 0) + assert_not_reached (); + if (asprintf (&test.socket_path, "%s/pkcs11", path) < 0) + assert_not_reached (); + free (path); unlink (test.socket_path); ret = socketpair (AF_UNIX, SOCK_STREAM, 0, fds); @@ -154,6 +160,27 @@ test_initialize (void *unused) } static void +test_initialize_no_address (void *unused) +{ + CK_FUNCTION_LIST_PTR module; + CK_RV rv; + + unsetenv ("P11_KIT_SERVER_ADDRESS"); + setenv ("XDG_RUNTIME_DIR", test.directory, 1); + + module = p11_kit_module_load (BUILDDIR "/.libs/p11-kit-client" SHLEXT, 0); + assert (module != NULL); + + rv = p11_kit_module_initialize (module); + assert (rv == CKR_OK); + + rv = p11_kit_module_finalize (module); + assert (rv == CKR_OK); + + p11_kit_module_release (module); +} + +static void test_open_session (void *unused) { CK_SESSION_HANDLE session; @@ -223,6 +250,7 @@ main (int argc, p11_fixture (setup_server, teardown_server); p11_testx (test_initialize, (void *)"pkcs11:", "/server/initialize"); + p11_testx (test_initialize_no_address, (void *)"pkcs11:", "/server/initialize-no-address"); p11_testx (test_open_session, (void *)"pkcs11:", "/server/open-session"); p11_testx (test_open_session_write_protected, (void *)"pkcs11:?write-protected=yes", "/server/open-session-write-protected"); |