Debian Codegraph @

src/test/test-chid.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "chid.h"
4 #include "tests.h"
5
6 static const char16_t *const test_fields[_CHID_SMBIOS_FIELDS_MAX] = {
7 [CHID_SMBIOS_MANUFACTURER] = u"Micro-Star International Co., Ltd.",
8 [CHID_SMBIOS_PRODUCT_NAME] = u"MS-7D70",
9 [CHID_SMBIOS_PRODUCT_SKU] = u"To be filled by O.E.M.",
10 [CHID_SMBIOS_FAMILY] = u"To be filled by O.E.M.",
11 [CHID_SMBIOS_BASEBOARD_PRODUCT] = u"MPG X670E CARBON WIFI (MS-7D70)",
12 [CHID_SMBIOS_BASEBOARD_MANUFACTURER] = u"Micro-Star International Co., Ltd.",
13 [CHID_SMBIOS_ENCLOSURE_TYPE] = u"3",
14 };
15
16 /* Actual output of `fwupdtool hwids`:
17 BiosVendor: American Megatrends International, LLC.
18 BiosVersion: 1.E5
19 BiosMajorRelease: 5
20 BiosMinorRelease: 32
21 FirmwareMajorRelease: ff
22 FirmwareMinorRelease: ff
23 Manufacturer: Micro-Star International Co., Ltd.
24 Family: To be filled by O.E.M.
25 ProductName: MS-7D70
26 ProductSku: To be filled by O.E.M.
27 EnclosureKind: 3
28 BaseboardManufacturer: Micro-Star International Co., Ltd.
29 BaseboardProduct: MPG X670E CARBON WIFI (MS-7D70)
30 Hardware IDs
31 ------------
32 {f59668ca-22bc-52a0-b6b5-1f6ce81b08e0} <- Manufacturer + Family + ProductName + ProductSku + BiosVendor + BiosVersion + BiosMajorRelease + BiosMinorRelease
33 {f735f7a0-40da-5bfe-8ac2-0090532ee6d0} <- Manufacturer + Family + ProductName + BiosVendor + BiosVersion + BiosMajorRelease + BiosMinorRelease
34 {25880e68-e005-5ca7-88b6-650de596604f} <- Manufacturer + ProductName + BiosVendor + BiosVersion + BiosMajorRelease + BiosMinorRelease
35 {01e09b32-de05-56ca-b9d1-9486ad5f381d} <- Manufacturer + Family + ProductName + ProductSku + BaseboardManufacturer + BaseboardProduct
36 {cad87a11-1813-507b-9aab-9a5f457b649c} <- Manufacturer + Family + ProductName + ProductSku
37 {377c823d-60d1-55b0-9678-76cd2af9d086} <- Manufacturer + Family + ProductName
38 {28ac9cf2-5bde-59f7-aebe-4b3d008090fe} <- Manufacturer + ProductSku + BaseboardManufacturer + BaseboardProduct
39 {e821e0e2-e11a-5e94-bf5d-ffe53c5e5048} <- Manufacturer + ProductSku
40 {1c092f1d-dc7b-564f-8a3d-128d7292fab8} <- Manufacturer + ProductName + BaseboardManufacturer + BaseboardProduct
41 {c12c1f4a-332d-5d72-aa36-7a3d413b479a} <- Manufacturer + ProductName
42 {28ac9cf2-5bde-59f7-aebe-4b3d008090fe} <- Manufacturer + Family + BaseboardManufacturer + BaseboardProduct
43 {e821e0e2-e11a-5e94-bf5d-ffe53c5e5048} <- Manufacturer + Family
44 {bdd76d3e-147f-58a9-a0b2-42136454ed07} <- Manufacturer + EnclosureKind
45 {b2e58e8b-fb10-5cd0-8fb0-5bd931f1871a} <- Manufacturer + BaseboardManufacturer + BaseboardProduct
46 {50af5797-a2f2-58b1-9a1a-453bcbb2e025} <- Manufacturer
47 Extra Hardware IDs
48 ------------------
49 {e6ff1b45-1955-5701-89ab-04fe2280cb4a} <- Manufacturer + Family + ProductName + ProductSku + BiosVendor
50 {8c4a76b9-e29e-5a3c-9072-9664898ecae6} <- Manufacturer + Family + ProductName + BiosVendor
51 {7b3d90ce-ed79-5951-a48a-764ea9f11146} <- Manufacturer + BiosVendor
52 */
53
54 static const EFI_GUID actual_chids[CHID_TYPES_MAX] = {
55 {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
56 {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
57 {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
58 {0x01e09b32, 0xde05, 0x56ca, {0xb9, 0xd1, 0x94, 0x86, 0xad, 0x5f, 0x38, 0x1d}},
59 {0xcad87a11, 0x1813, 0x507b, {0x9a, 0xab, 0x9a, 0x5f, 0x45, 0x7b, 0x64, 0x9c}},
60 {0x377c823d, 0x60d1, 0x55b0, {0x96, 0x78, 0x76, 0xcd, 0x2a, 0xf9, 0xd0, 0x86}},
61 {0x28ac9cf2, 0x5bde, 0x59f7, {0xae, 0xbe, 0x4b, 0x3d, 0x00, 0x80, 0x90, 0xfe}},
62 {0xe821e0e2, 0xe11a, 0x5e94, {0xbf, 0x5d, 0xff, 0xe5, 0x3c, 0x5e, 0x50, 0x48}},
63 {0x1c092f1d, 0xdc7b, 0x564f, {0x8a, 0x3d, 0x12, 0x8d, 0x72, 0x92, 0xfa, 0xb8}},
64 {0xc12c1f4a, 0x332d, 0x5d72, {0xaa, 0x36, 0x7a, 0x3d, 0x41, 0x3b, 0x47, 0x9a}},
65 {0x28ac9cf2, 0x5bde, 0x59f7, {0xae, 0xbe, 0x4b, 0x3d, 0x00, 0x80, 0x90, 0xfe}},
66 {0xe821e0e2, 0xe11a, 0x5e94, {0xbf, 0x5d, 0xff, 0xe5, 0x3c, 0x5e, 0x50, 0x48}},
67 {0xbdd76d3e, 0x147f, 0x58a9, {0xa0, 0xb2, 0x42, 0x13, 0x64, 0x54, 0xed, 0x07}},
68 {0xb2e58e8b, 0xfb10, 0x5cd0, {0x8f, 0xb0, 0x5b, 0xd9, 0x31, 0xf1, 0x87, 0x1a}},
69 {0x50af5797, 0xa2f2, 0x58b1, {0x9a, 0x1a, 0x45, 0x3b, 0xcb, 0xb2, 0xe0, 0x25}},
70 };
71
72 TEST(chid) {
73 /* Results compared with output of 'fwupdtool hwids' */
74 EFI_GUID chids[CHID_TYPES_MAX];
75 chid_calculate(test_fields, chids);
76 for (size_t i = 0; i < ELEMENTSOF(chids); i++)
77 ASSERT_EQ_EFI_GUID(&chids[i], &actual_chids[i]);
78 }
79
80 static int intro(void) {
81 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
82 return EXIT_SUCCESS;
83 #else
84 return log_tests_skipped("cannot run CHID calculation on big-endian machine");
85 #endif
86 }
87
88 DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);