summaryrefslogtreecommitdiff
path: root/trust/tests
diff options
context:
space:
mode:
Diffstat (limited to 'trust/tests')
-rw-r--r--trust/tests/Makefile.am2
-rw-r--r--trust/tests/frob-token.c2
-rw-r--r--trust/tests/test-module.c30
-rw-r--r--trust/tests/test-token.c13
4 files changed, 36 insertions, 11 deletions
diff --git a/trust/tests/Makefile.am b/trust/tests/Makefile.am
index a964948..aedc6f3 100644
--- a/trust/tests/Makefile.am
+++ b/trust/tests/Makefile.am
@@ -7,6 +7,8 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(srcdir)/.. \
-I$(top_srcdir)/common \
+ -DDATADIR=\"$(datadir)\" \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
$(CUTEST_CFLAGS)
noinst_LTLIBRARIES = \
diff --git a/trust/tests/frob-token.c b/trust/tests/frob-token.c
index 622dad4..5d57ec1 100644
--- a/trust/tests/frob-token.c
+++ b/trust/tests/frob-token.c
@@ -52,7 +52,7 @@ main (int argc,
return 2;
}
- token = p11_token_new (1, argv[1]);
+ token = p11_token_new (1, argv[1], "Label");
count = p11_token_load (token);
printf ("%d files loaded\n", count);
diff --git a/trust/tests/test-module.c b/trust/tests/test-module.c
index de0a3b1..57df78e 100644
--- a/trust/tests/test-module.c
+++ b/trust/tests/test-module.c
@@ -184,6 +184,8 @@ test_get_slot_info (CuTest *cu)
static void
test_get_token_info (CuTest *cu)
{
+ CK_C_INITIALIZE_ARGS args;
+ CK_FUNCTION_LIST *module;
CK_SLOT_ID slots[NUM_SLOTS];
CK_TOKEN_INFO info;
char label[32];
@@ -193,20 +195,29 @@ test_get_token_info (CuTest *cu)
/* These are the paths passed in in setup() */
const char *labels[] = {
- "input",
- "self-signed-with-ku.der",
- "thawte.pem"
+ "System Trust",
+ "Default Trust",
+ "the-basename",
};
- setup (cu);
+ /* This is the entry point of the trust module, linked to this test */
+ rv = C_GetFunctionList (&module);
+ CuAssertTrue (cu, rv == CKR_OK);
+
+ memset (&args, 0, sizeof (args));
+ args.pReserved = "paths='" SYSCONFDIR "/input:" DATADIR "/files/blah:" "/some/other/path/the-basename'";
+ args.flags = CKF_OS_LOCKING_OK;
+
+ rv = module->C_Initialize (&args);
+ CuAssertTrue (cu, rv == CKR_OK);
count = NUM_SLOTS;
- rv = test.module->C_GetSlotList (TRUE, slots, &count);
- CuAssertIntEquals (cu, CKR_OK, rv);
- CuAssertIntEquals (cu, NUM_SLOTS, count);
+ rv = module->C_GetSlotList (CK_TRUE, slots, &count);
+ CuAssertTrue (cu, rv == CKR_OK);
+ CuAssertTrue (cu, count == NUM_SLOTS);
for (i = 0; i < NUM_SLOTS; i++) {
- rv = test.module->C_GetTokenInfo (slots[i], &info);
+ rv = module->C_GetTokenInfo (slots[i], &info);
CuAssertIntEquals (cu, CKR_OK, rv);
memset (label, ' ', sizeof (label));
@@ -214,7 +225,8 @@ test_get_token_info (CuTest *cu)
CuAssertTrue (cu, memcmp (info.label, label, sizeof (label)) == 0);
}
- teardown (cu);
+ rv = module->C_Finalize (NULL);
+ CuAssertIntEquals (cu, CKR_OK, rv);
}
static void
diff --git a/trust/tests/test-token.c b/trust/tests/test-token.c
index c62fae2..ebe434d 100644
--- a/trust/tests/test-token.c
+++ b/trust/tests/test-token.c
@@ -54,7 +54,7 @@ static void
setup (CuTest *cu,
const char *path)
{
- test.token = p11_token_new (333, path);
+ test.token = p11_token_new (333, path, "Label");
CuAssertPtrNotNull (cu, test.token);
}
@@ -208,6 +208,16 @@ test_token_path (CuTest *cu)
}
static void
+test_token_label (CuTest *cu)
+{
+ setup (cu, "/wheee");
+
+ CuAssertStrEquals (cu, "Label", p11_token_get_label (test.token));
+
+ teardown (cu);
+}
+
+static void
test_token_slot (CuTest *cu)
{
setup (cu, "/unneeded");
@@ -231,6 +241,7 @@ main (void)
SUITE_ADD_TEST (suite, test_token_load);
SUITE_ADD_TEST (suite, test_token_flags);
SUITE_ADD_TEST (suite, test_token_path);
+ SUITE_ADD_TEST (suite, test_token_label);
SUITE_ADD_TEST (suite, test_token_slot);
CuSuiteRun (suite);