Line data Source code
1 : /**
2 : * Copyright Notice:
3 : * Copyright 2023-2025 DMTF. All rights reserved.
4 : * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
5 : **/
6 :
7 : #include "spdm_unit_test.h"
8 : #include "library/spdm_crypt_lib.h"
9 : #include "internal/libspdm_common_lib.h"
10 :
11 1 : void libspdm_test_fips(void **state)
12 : {
13 : bool status;
14 1 : status = false;
15 :
16 : #if LIBSPDM_FIPS_MODE
17 :
18 : libspdm_fips_selftest_context_t fips_selftest_context;
19 1 : fips_selftest_context.tested_algo = 0;
20 1 : fips_selftest_context.self_test_result = 0;
21 :
22 1 : status = libspdm_fips_run_selftest(&fips_selftest_context);
23 1 : assert_true(status);
24 : #else
25 : LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "test is valid only when LIBSPDM_FIPS_MODE is open.\n"));
26 : assert_true(status);
27 : #endif
28 1 : }
29 :
30 1 : int libspdm_crypt_lib_setup(void **state)
31 : {
32 1 : return 0;
33 : }
34 :
35 1 : int libspdm_crypt_lib_teardown(void **state)
36 : {
37 1 : return 0;
38 : }
39 :
40 1 : int libspdm_crypt_lib_test_main(void)
41 : {
42 1 : const struct CMUnitTest spdm_crypt_lib_tests[] = {
43 : cmocka_unit_test(libspdm_test_fips),
44 : };
45 :
46 1 : return cmocka_run_group_tests(spdm_crypt_lib_tests,
47 : libspdm_crypt_lib_setup,
48 : libspdm_crypt_lib_teardown);
49 : }
50 :
51 1 : int main(void)
52 : {
53 1 : int return_value = 0;
54 :
55 1 : if (libspdm_crypt_lib_test_main() != 0) {
56 0 : return_value = 1;
57 : }
58 :
59 1 : return return_value;
60 : }
|