2 * Copyright (c) 2013 Red Hat Inc
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * * Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the
10 * following disclaimer.
11 * * Redistributions in binary form must reproduce the
12 * above copyright notice, this list of conditions and
13 * the following disclaimer in the documentation and/or
14 * other materials provided with the distribution.
15 * * The names of contributors to this software may not be
16 * used to endorse or promote products derived from this
17 * software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
32 * Author: Stef Walter <stefw@redhat.com>
51 static CK_FUNCTION_LIST_PTR
52 setup_mock_module (CK_SESSION_HANDLE *session)
54 CK_FUNCTION_LIST_PTR module;
60 rv = p11_module_load_inlock_reentrant (&mock_module, 0, &module);
61 assert (rv == CKR_OK);
62 assert_ptr_not_null (module);
63 assert (p11_virtual_is_wrapper (module));
67 rv = p11_kit_module_initialize (module);
68 assert (rv == CKR_OK);
71 rv = (module->C_OpenSession) (MOCK_SLOT_ONE_ID,
72 CKF_RW_SESSION | CKF_SERIAL_SESSION,
74 assert (rv == CKR_OK);
81 teardown_mock_module (CK_FUNCTION_LIST_PTR module)
85 rv = p11_kit_module_finalize (module);
86 assert (rv == CKR_OK);
90 rv = p11_module_release_inlock_reentrant (module);
91 assert (rv == CKR_OK);
96 /* Bring in all the mock module tests */
97 #include "test-mock.c"
106 test_mock_add_tests ("/log");
109 p11_log_output = false;
111 return p11_test_run (argc, argv);