summaryrefslogtreecommitdiff
path: root/p11-kit/tests
diff options
context:
space:
mode:
Diffstat (limited to 'p11-kit/tests')
-rw-r--r--p11-kit/tests/files/package-modules/four.module1
-rw-r--r--p11-kit/tests/files/package-modules/win32/four.module1
-rw-r--r--p11-kit/tests/files/system-modules/two-duplicate.module1
-rw-r--r--p11-kit/tests/files/system-modules/two.badname1
-rw-r--r--p11-kit/tests/files/system-modules/win32/one.module3
-rw-r--r--p11-kit/tests/files/system-modules/win32/two-duplicate.module1
-rw-r--r--p11-kit/tests/files/system-modules/win32/two.badname1
-rw-r--r--p11-kit/tests/files/user-modules/three.module3
-rw-r--r--p11-kit/tests/files/user-modules/win32/three.module3
-rw-r--r--p11-kit/tests/test-modules.c42
10 files changed, 54 insertions, 3 deletions
diff --git a/p11-kit/tests/files/package-modules/four.module b/p11-kit/tests/files/package-modules/four.module
index 6eace3c..545c285 100644
--- a/p11-kit/tests/files/package-modules/four.module
+++ b/p11-kit/tests/files/package-modules/four.module
@@ -1,3 +1,4 @@
module: mock-four.so
disable-in: test-disable, test-other
+priority: 4 \ No newline at end of file
diff --git a/p11-kit/tests/files/package-modules/win32/four.module b/p11-kit/tests/files/package-modules/win32/four.module
index 7fd1540..6dc87c9 100644
--- a/p11-kit/tests/files/package-modules/win32/four.module
+++ b/p11-kit/tests/files/package-modules/win32/four.module
@@ -1,3 +1,4 @@
module: mock-four.dll
disable-in: test-disable, test-other
+priority: 4 \ No newline at end of file
diff --git a/p11-kit/tests/files/system-modules/two-duplicate.module b/p11-kit/tests/files/system-modules/two-duplicate.module
index 907aa75..756af69 100644
--- a/p11-kit/tests/files/system-modules/two-duplicate.module
+++ b/p11-kit/tests/files/system-modules/two-duplicate.module
@@ -1,3 +1,4 @@
# This is a duplicate of the 'two' module
module: mock-two.so
+# no priority, use name \ No newline at end of file
diff --git a/p11-kit/tests/files/system-modules/two.badname b/p11-kit/tests/files/system-modules/two.badname
index 0d41cac..eec3af0 100644
--- a/p11-kit/tests/files/system-modules/two.badname
+++ b/p11-kit/tests/files/system-modules/two.badname
@@ -3,3 +3,4 @@
module: mock-two.so
setting: system2
+# no priority, use name \ No newline at end of file
diff --git a/p11-kit/tests/files/system-modules/win32/one.module b/p11-kit/tests/files/system-modules/win32/one.module
index 5f80304..d153ce5 100644
--- a/p11-kit/tests/files/system-modules/win32/one.module
+++ b/p11-kit/tests/files/system-modules/win32/one.module
@@ -1,3 +1,4 @@
module: mock-one.dll
-setting: system1 \ No newline at end of file
+setting: system1
+# no order, use name \ No newline at end of file
diff --git a/p11-kit/tests/files/system-modules/win32/two-duplicate.module b/p11-kit/tests/files/system-modules/win32/two-duplicate.module
index e80c9e8..54ef1cc 100644
--- a/p11-kit/tests/files/system-modules/win32/two-duplicate.module
+++ b/p11-kit/tests/files/system-modules/win32/two-duplicate.module
@@ -1,3 +1,4 @@
# This is a duplicate of the 'two' module
module: mock-two.dll
+# no order, use name \ No newline at end of file
diff --git a/p11-kit/tests/files/system-modules/win32/two.badname b/p11-kit/tests/files/system-modules/win32/two.badname
index ae44b83..af63cf9 100644
--- a/p11-kit/tests/files/system-modules/win32/two.badname
+++ b/p11-kit/tests/files/system-modules/win32/two.badname
@@ -3,3 +3,4 @@
module: mock-two.dll
setting: system2
+# no order, use name \ No newline at end of file
diff --git a/p11-kit/tests/files/user-modules/three.module b/p11-kit/tests/files/user-modules/three.module
index 00caab5..3a2366d 100644
--- a/p11-kit/tests/files/user-modules/three.module
+++ b/p11-kit/tests/files/user-modules/three.module
@@ -2,4 +2,5 @@
module: mock-three.so
setting: user3
-enable-in: test-enable \ No newline at end of file
+enable-in: test-enable
+priority: 3 \ No newline at end of file
diff --git a/p11-kit/tests/files/user-modules/win32/three.module b/p11-kit/tests/files/user-modules/win32/three.module
index 58f883d..30a3b63 100644
--- a/p11-kit/tests/files/user-modules/win32/three.module
+++ b/p11-kit/tests/files/user-modules/win32/three.module
@@ -2,4 +2,5 @@
module: mock-three.dll
setting: user3
-enable-in: test-enable \ No newline at end of file
+enable-in: test-enable
+priority: 3 \ No newline at end of file
diff --git a/p11-kit/tests/test-modules.c b/p11-kit/tests/test-modules.c
index eb8d952..5bdbaa4 100644
--- a/p11-kit/tests/test-modules.c
+++ b/p11-kit/tests/test-modules.c
@@ -219,6 +219,47 @@ test_enable (CuTest *tc)
p11_kit_set_progname (NULL);
}
+static void
+test_priority (CuTest *tc)
+{
+ CK_FUNCTION_LIST_PTR_PTR modules;
+ char *name;
+ int i;
+
+ /*
+ * The expected order.
+ * - four is marked with a priority of 4, the highest therefore first
+ * - three is marked with a priority of 3, next highest
+ * - one and two do not have priority marked, so they default to zero
+ * and fallback to sorting alphabetically. 'o' comes before 't'
+ */
+
+ const char *expected[] = { "four", "three", "one", "two.badname" };
+
+ /* This enables module three */
+ p11_kit_set_progname ("test-enable");
+
+ modules = initialize_and_get_modules (tc);
+
+ /* The loaded modules should not contain duplicates */
+ for (i = 0; modules[i] != NULL; i++) {
+ name = p11_kit_registered_module_to_name (modules[i]);
+ CuAssertPtrNotNull (tc, name);
+
+ /* Either one of these can be loaded, as this is a duplicate module */
+ if (strcmp (name, "two-duplicate") == 0) {
+ free (name);
+ name = strdup ("two.badname");
+ }
+
+ CuAssertStrEquals (tc, expected[i], name);
+ free (name);
+ }
+
+ CuAssertIntEquals (tc, 4, i);
+ finalize_and_free_modules (tc, modules);
+}
+
int
main (void)
{
@@ -233,6 +274,7 @@ main (void)
SUITE_ADD_TEST (suite, test_disable);
SUITE_ADD_TEST (suite, test_disable_later);
SUITE_ADD_TEST (suite, test_enable);
+ SUITE_ADD_TEST (suite, test_priority);
p11_kit_be_quiet ();