Software APIs
boot_svc_min_bl0_sec_ver_unittest.cc
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include "sw/device/silicon_creator/lib/boot_svc/boot_svc_min_bl0_sec_ver.h"
6 
7 #include "gtest/gtest.h"
8 #include "sw/device/silicon_creator/lib/boot_data.h"
9 #include "sw/device/silicon_creator/lib/boot_svc/mock_boot_svc_header.h"
10 #include "sw/device/silicon_creator/testing/rom_test.h"
11 
12 namespace boot_svc_min_bl0_sec_ver_unittest {
13 namespace {
14 
16  protected:
17  rom_test::MockBootSvcHeader boot_svc_header_;
18 };
19 
20 TEST_F(BootSvcMinBl0SecVerTest, ReqInit) {
22  constexpr uint32_t kMinBl0SecVersion = 0x12345678;
23  EXPECT_CALL(boot_svc_header_,
24  Finalize(kBootSvcMinBl0SecVerReqType, sizeof(msg), &msg.header));
25 
26  boot_svc_min_bl0_sec_ver_req_init(kMinBl0SecVersion, &msg);
27 
28  EXPECT_EQ(msg.min_bl0_sec_ver, kMinBl0SecVersion);
29 }
30 
31 TEST_F(BootSvcMinBl0SecVerTest, ResInit) {
33  constexpr rom_error_t kStatus = kErrorOk;
34  constexpr uint32_t kMinBl0SecVersion = 0x12345678;
35  EXPECT_CALL(boot_svc_header_,
36  Finalize(kBootSvcMinBl0SecVerResType, sizeof(msg), &msg.header));
37 
38  boot_svc_min_bl0_sec_ver_res_init(kMinBl0SecVersion, kStatus, &msg);
39 
40  EXPECT_EQ(msg.min_bl0_sec_ver, kMinBl0SecVersion);
41  EXPECT_EQ(msg.status, kStatus);
42 }
43 
44 } // namespace
45 } // namespace boot_svc_min_bl0_sec_ver_unittest