1 #include "extensions/openpower-pels/paths.hpp"
2 
3 #include <filesystem>
4 #include <memory>
5 #include <vector>
6 
7 #include <gtest/gtest.h>
8 
9 /**
10  * @brief Test fixture to remove the pelID file that PELs use.
11  */
12 class CleanLogID : public ::testing::Test
13 {
14   protected:
15     static void SetUpTestCase()
16     {
17         pelIDFile = openpower::pels::getPELIDFile();
18     }
19 
20     static void TearDownTestCase()
21     {
22         std::filesystem::remove_all(
23             std::filesystem::path{pelIDFile}.parent_path());
24     }
25 
26     static std::filesystem::path pelIDFile;
27 };
28 
29 /**
30  * @brief Tells the factory which PEL to create
31  */
32 enum class TestPelType
33 {
34     pelSimple,
35     privateHeaderSimple,
36     userHeaderSimple
37 };
38 
39 /**
40  * @brief PEL data factory, for testing
41  *
42  * @param[in] type - the type of data to create
43  *
44  * @return std::unique_ptr<std::vector<uint8_t>> - the PEL data
45  */
46 std::unique_ptr<std::vector<uint8_t>> pelDataFactory(TestPelType type);
47 
48 /**
49  * @brief Helper function to read raw PEL data from a file
50  *
51  * @param[in] path - the path to read
52  *
53  * @return std::unique_ptr<std::vector<uint8_t>> - the data from the file
54  */
55 std::unique_ptr<std::vector<uint8_t>>
56     readPELFile(const std::filesystem::path& path);
57