Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 1 | /** |
| 2 | * Defines tests for validating CPER-JSON IR output from the cper-parse library. |
Ed Tanous | fedd457 | 2024-07-12 13:56:00 -0700 | [diff] [blame^] | 3 | * |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 4 | * Author: Lawrence.Tang@arm.com |
| 5 | **/ |
| 6 | |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 7 | #include <cctype> |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 8 | #include "gtest/gtest.h" |
| 9 | #include "test-utils.hpp" |
| 10 | extern "C" { |
Lawrence Tang | 5202bbb | 2022-08-12 14:54:36 +0100 | [diff] [blame] | 11 | #include <json.h> |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 12 | #include "../cper-parse.h" |
| 13 | #include "../json-schema.h" |
| 14 | #include "../generator/cper-generate.h" |
Lawrence Tang | 580423f | 2022-08-24 09:37:53 +0100 | [diff] [blame] | 15 | #include "../sections/cper-section.h" |
Lawrence Tang | 40519cb | 2022-08-24 15:50:08 +0100 | [diff] [blame] | 16 | #include "../generator/sections/gen-section.h" |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | /* |
| 20 | * Test templates. |
| 21 | */ |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 22 | |
| 23 | //Tests a single randomly generated CPER section of the given type to ensure CPER-JSON IR validity. |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 24 | void cper_log_section_ir_test(const char *section_name, int single_section) |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 25 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 26 | //Generate full CPER record for the given type. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 27 | char *buf; |
| 28 | size_t size; |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 29 | FILE *record = generate_record_memstream(§ion_name, 1, &buf, &size, |
| 30 | single_section); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 31 | |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 32 | //Convert to IR, free resources. |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 33 | json_object *ir; |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 34 | if (single_section) { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 35 | ir = cper_single_section_to_ir(record); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 36 | } else { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 37 | ir = cper_to_ir(record); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 38 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 39 | fclose(record); |
| 40 | free(buf); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 41 | |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 42 | //Validate against schema. |
| 43 | char error_message[JSON_ERROR_MSG_MAX_LEN] = { 0 }; |
| 44 | int valid = validate_schema_from_file("./specification/cper-json.json", |
| 45 | ir, error_message); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 46 | json_object_put(ir); |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 47 | ASSERT_TRUE(valid) |
| 48 | << "IR validation test failed (single section mode = " |
| 49 | << single_section << ") with message: " << error_message; |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 50 | } |
| 51 | |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 52 | //Checks for binary round-trip equality for a given randomly generated CPER record. |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 53 | void cper_log_section_binary_test(const char *section_name, int single_section) |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 54 | { |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 55 | //Generate CPER record for the given type. |
| 56 | char *buf; |
| 57 | size_t size; |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 58 | FILE *record = generate_record_memstream(§ion_name, 1, &buf, &size, |
| 59 | single_section); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 60 | |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 61 | //Convert to IR. |
| 62 | json_object *ir; |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 63 | if (single_section) { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 64 | ir = cper_single_section_to_ir(record); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 65 | } else { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 66 | ir = cper_to_ir(record); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 67 | } |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 68 | |
| 69 | //Now convert back to binary, and get a stream out. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 70 | char *cper_buf; |
| 71 | size_t cper_buf_size; |
| 72 | FILE *stream = open_memstream(&cper_buf, &cper_buf_size); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 73 | if (single_section) { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 74 | ir_single_section_to_cper(ir, stream); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 75 | } else { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 76 | ir_to_cper(ir, stream); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 77 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 78 | size_t cper_len = ftell(stream); |
| 79 | fclose(stream); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 80 | |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 81 | //Validate the two are identical. |
| 82 | ASSERT_GE(size, cper_len); |
| 83 | ASSERT_EQ(memcmp(buf, cper_buf, cper_len), 0) |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 84 | << "Binary output was not identical to input (single section mode = " |
| 85 | << single_section << ")."; |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 86 | |
| 87 | //Free everything up. |
| 88 | fclose(record); |
| 89 | free(buf); |
| 90 | free(cper_buf); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 91 | json_object_put(ir); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 92 | } |
| 93 | |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 94 | //Tests randomly generated CPER sections for IR validity of a given type, in both single section mode and full CPER log mode. |
| 95 | void cper_log_section_dual_ir_test(const char *section_name) |
| 96 | { |
| 97 | cper_log_section_ir_test(section_name, 0); |
| 98 | cper_log_section_ir_test(section_name, 1); |
| 99 | } |
| 100 | |
| 101 | //Tests randomly generated CPER sections for binary compatibility of a given type, in both single section mode and full CPER log mode. |
| 102 | void cper_log_section_dual_binary_test(const char *section_name) |
| 103 | { |
| 104 | cper_log_section_binary_test(section_name, 0); |
| 105 | cper_log_section_binary_test(section_name, 1); |
| 106 | } |
| 107 | |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 108 | /* |
Lawrence Tang | 580423f | 2022-08-24 09:37:53 +0100 | [diff] [blame] | 109 | * Non-single section assertions. |
| 110 | */ |
| 111 | TEST(CompileTimeAssertions, TwoWayConversion) |
| 112 | { |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 113 | for (size_t i = 0; i < section_definitions_len; i++) { |
Lawrence Tang | 580423f | 2022-08-24 09:37:53 +0100 | [diff] [blame] | 114 | //If a conversion one way exists, a conversion the other way must exist. |
Lawrence Tang | 40519cb | 2022-08-24 15:50:08 +0100 | [diff] [blame] | 115 | std::string err = |
| 116 | "If a CPER conversion exists one way, there must be an equivalent method in reverse."; |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 117 | if (section_definitions[i].ToCPER != NULL) { |
| 118 | ASSERT_NE(section_definitions[i].ToIR, nullptr) << err; |
| 119 | } |
| 120 | if (section_definitions[i].ToIR != NULL) { |
| 121 | ASSERT_NE(section_definitions[i].ToCPER, nullptr) |
| 122 | << err; |
| 123 | } |
Lawrence Tang | 580423f | 2022-08-24 09:37:53 +0100 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
Lawrence Tang | 40519cb | 2022-08-24 15:50:08 +0100 | [diff] [blame] | 127 | TEST(CompileTimeAssertions, ShortcodeNoSpaces) |
| 128 | { |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 129 | for (size_t i = 0; i < generator_definitions_len; i++) { |
Lawrence Tang | 40519cb | 2022-08-24 15:50:08 +0100 | [diff] [blame] | 130 | for (int j = 0; |
| 131 | generator_definitions[i].ShortName[j + 1] != '\0'; j++) { |
| 132 | ASSERT_FALSE( |
| 133 | isspace(generator_definitions[i].ShortName[j])) |
| 134 | << "Illegal space character detected in shortcode '" |
| 135 | << generator_definitions[i].ShortName << "'."; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
Lawrence Tang | 580423f | 2022-08-24 09:37:53 +0100 | [diff] [blame] | 140 | /* |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 141 | * Single section tests. |
| 142 | */ |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 143 | |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 144 | //Generic processor tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 145 | TEST(GenericProcessorTests, IRValid) |
| 146 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 147 | cper_log_section_dual_ir_test("generic"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 148 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 149 | TEST(GenericProcessorTests, BinaryEqual) |
| 150 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 151 | cper_log_section_dual_binary_test("generic"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | //IA32/x64 tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 155 | TEST(IA32x64Tests, IRValid) |
| 156 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 157 | cper_log_section_dual_ir_test("ia32x64"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 158 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 159 | TEST(IA32x64Tests, BinaryEqual) |
| 160 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 161 | cper_log_section_dual_binary_test("ia32x64"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 162 | } |
| 163 | |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 164 | // TEST(IPFTests, IRValid) { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 165 | // cper_log_section_dual_ir_test("ipf"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 166 | // } |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 167 | |
| 168 | //ARM tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 169 | TEST(ArmTests, IRValid) |
| 170 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 171 | cper_log_section_dual_ir_test("arm"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 172 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 173 | TEST(ArmTests, BinaryEqual) |
| 174 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 175 | cper_log_section_dual_binary_test("arm"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | //Memory tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 179 | TEST(MemoryTests, IRValid) |
| 180 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 181 | cper_log_section_dual_ir_test("memory"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 182 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 183 | TEST(MemoryTests, BinaryEqual) |
| 184 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 185 | cper_log_section_dual_binary_test("memory"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | //Memory 2 tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 189 | TEST(Memory2Tests, IRValid) |
| 190 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 191 | cper_log_section_dual_ir_test("memory2"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 192 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 193 | TEST(Memory2Tests, BinaryEqual) |
| 194 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 195 | cper_log_section_dual_binary_test("memory2"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | //PCIe tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 199 | TEST(PCIeTests, IRValid) |
| 200 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 201 | cper_log_section_dual_ir_test("pcie"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 202 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 203 | TEST(PCIeTests, BinaryEqual) |
| 204 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 205 | cper_log_section_dual_binary_test("pcie"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | //Firmware tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 209 | TEST(FirmwareTests, IRValid) |
| 210 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 211 | cper_log_section_dual_ir_test("firmware"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 212 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 213 | TEST(FirmwareTests, BinaryEqual) |
| 214 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 215 | cper_log_section_dual_binary_test("firmware"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | //PCI Bus tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 219 | TEST(PCIBusTests, IRValid) |
| 220 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 221 | cper_log_section_dual_ir_test("pcibus"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 222 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 223 | TEST(PCIBusTests, BinaryEqual) |
| 224 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 225 | cper_log_section_dual_binary_test("pcibus"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | //PCI Device tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 229 | TEST(PCIDevTests, IRValid) |
| 230 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 231 | cper_log_section_dual_ir_test("pcidev"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 232 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 233 | TEST(PCIDevTests, BinaryEqual) |
| 234 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 235 | cper_log_section_dual_binary_test("pcidev"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | //Generic DMAr tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 239 | TEST(DMArGenericTests, IRValid) |
| 240 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 241 | cper_log_section_dual_ir_test("dmargeneric"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 242 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 243 | TEST(DMArGenericTests, BinaryEqual) |
| 244 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 245 | cper_log_section_dual_binary_test("dmargeneric"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | //VT-d DMAr tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 249 | TEST(DMArVtdTests, IRValid) |
| 250 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 251 | cper_log_section_dual_ir_test("dmarvtd"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 252 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 253 | TEST(DMArVtdTests, BinaryEqual) |
| 254 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 255 | cper_log_section_dual_binary_test("dmarvtd"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | //IOMMU DMAr tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 259 | TEST(DMArIOMMUTests, IRValid) |
| 260 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 261 | cper_log_section_dual_ir_test("dmariommu"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 262 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 263 | TEST(DMArIOMMUTests, BinaryEqual) |
| 264 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 265 | cper_log_section_dual_binary_test("dmariommu"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | //CCIX PER tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 269 | TEST(CCIXPERTests, IRValid) |
| 270 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 271 | cper_log_section_dual_ir_test("ccixper"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 272 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 273 | TEST(CCIXPERTests, BinaryEqual) |
| 274 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 275 | cper_log_section_dual_binary_test("ccixper"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | //CXL Protocol tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 279 | TEST(CXLProtocolTests, IRValid) |
| 280 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 281 | cper_log_section_dual_ir_test("cxlprotocol"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 282 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 283 | TEST(CXLProtocolTests, BinaryEqual) |
| 284 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 285 | cper_log_section_dual_binary_test("cxlprotocol"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | //CXL Component tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 289 | TEST(CXLComponentTests, IRValid) |
| 290 | { |
Lawrence Tang | 8f97745 | 2022-08-24 14:55:07 +0100 | [diff] [blame] | 291 | cper_log_section_dual_ir_test("cxlcomponent-media"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 292 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 293 | TEST(CXLComponentTests, BinaryEqual) |
| 294 | { |
Lawrence Tang | 8f97745 | 2022-08-24 14:55:07 +0100 | [diff] [blame] | 295 | cper_log_section_dual_binary_test("cxlcomponent-media"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | //Unknown section tests. |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 299 | TEST(UnknownSectionTests, IRValid) |
| 300 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 301 | cper_log_section_dual_ir_test("unknown"); |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 302 | } |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 303 | TEST(UnknownSectionTests, BinaryEqual) |
| 304 | { |
Lawrence Tang | a4f662f | 2022-08-08 14:37:36 +0100 | [diff] [blame] | 305 | cper_log_section_dual_binary_test("unknown"); |
Lawrence Tang | cd50520 | 2022-07-19 16:55:11 +0100 | [diff] [blame] | 306 | } |
Lawrence Tang | d34f2b1 | 2022-07-19 15:36:31 +0100 | [diff] [blame] | 307 | |
| 308 | //Entrypoint for the testing program. |
| 309 | int main() |
| 310 | { |
Lawrence Tang | e407b4c | 2022-07-21 13:54:01 +0100 | [diff] [blame] | 311 | testing::InitGoogleTest(); |
| 312 | return RUN_ALL_TESTS(); |
John Chung | f8fc705 | 2024-05-03 20:05:29 +0800 | [diff] [blame] | 313 | } |