Software APIs
rom_test.h
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#ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_TESTING_ROM_TEST_H_
6#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_TESTING_ROM_TEST_H_
7
8#include "gmock/gmock.h"
9#include "gtest/gtest.h"
10
11namespace rom_test {
12
13/**
14 * Test fixture for ROM tests.
15 *
16 * Test suites should derive their test fixtures from this class. This class
17 * enforces that mock methods are called in the order `EXPECT_CALL` statements
18 * are written. In cases where this behavior is not desired, test fixtures can
19 * derive from `Unordered<RomTest>` instead to opt-out.
20 */
21class RomTest : public testing::Test {
22 protected:
23 std::unique_ptr<testing::InSequence> seq_ =
24 std::make_unique<testing::InSequence>();
25};
26
27/**
28 * Mixin for unordered calls.
29 *
30 * @see RomTest.
31 */
32template <typename T>
33class Unordered : public T {
34 protected:
35 Unordered() : T() { T::seq_.reset(); }
36};
37
38} // namespace rom_test
39#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_TESTING_ROM_TEST_H_