diff options
Diffstat (limited to 'p11-kit/test-modules.c')
-rw-r--r-- | p11-kit/test-modules.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/p11-kit/test-modules.c b/p11-kit/test-modules.c index f274502..837e7ff 100644 --- a/p11-kit/test-modules.c +++ b/p11-kit/test-modules.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Red Hat Inc + * Copyright (c) 2012, 2015 Red Hat Inc * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,6 +39,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <libgen.h> #include "debug.h" #include "library.h" @@ -126,6 +127,25 @@ lookup_module_with_name (CK_FUNCTION_LIST_PTR_PTR modules, return match; } +static CK_FUNCTION_LIST_PTR +lookup_module_with_filename (CK_FUNCTION_LIST_PTR_PTR modules, + const char *name) +{ + CK_FUNCTION_LIST_PTR match = NULL; + char *module_name; + int i; + + for (i = 0; match == NULL && modules[i] != NULL; i++) { + module_name = p11_kit_module_get_filename (modules[i]); + assert_ptr_not_null (module_name); + if (strcmp (basename(module_name), name) == 0) + match = modules[i]; + free (module_name); + } + + return match; +} + static void test_disable (void) { @@ -157,6 +177,23 @@ test_disable (void) } static void +test_filename (void) +{ + CK_FUNCTION_LIST_PTR_PTR modules; + + /* + * The module four should be present, as we don't match any prognames + * that it has disabled. + */ + + modules = initialize_and_get_modules (); +#ifndef _WIN32 + assert (lookup_module_with_filename (modules, "mock-four.so") != NULL); +#endif + finalize_and_free_modules (modules); +} + +static void test_disable_later (void) { CK_FUNCTION_LIST_PTR_PTR modules; @@ -398,6 +435,7 @@ main (int argc, { p11_library_init (); + p11_test (test_filename, "/modules/test_filename"); p11_test (test_no_duplicates, "/modules/test_no_duplicates"); p11_test (test_disable, "/modules/test_disable"); p11_test (test_disable_later, "/modules/test_disable_later"); |