]> FriiDump Source - friidump.git/blob - tests/test_hlds_e7_profiles.c
Record A102 and B101 live profile evidence
[friidump.git] / tests / test_hlds_e7_profiles.c
1 #include "dvd_drive.h"
2
3 #include <stdio.h>
4 #include <string.h>
5
6 typedef struct {
7     const char *label;
8     const char *vendor;
9     const char *product;
10     const char *revision;
11     bool exact;
12     u_int32_t type;
13     u_int32_t cdb;
14     u_int32_t gate;
15     u_int32_t blocks;
16     int method;
17     const char *record_id;
18     const char *tokens;
19     const char *support_tier;
20 } profile_case;
21
22 static int check_case(const profile_case *test) {
23     dvd_hlds_e7_profile_info info;
24     bool exact = dvd_lookup_hlds_e7_profile(
25         test->vendor,
26         test->product,
27         test->revision,
28         &info);
29     u_int32_t detected = dvd_detect_hlds_e7_type_for_identity(
30         test->vendor,
31         test->product,
32         test->revision);
33
34     if (exact != test->exact) {
35         fprintf(stderr,
36             "FAIL: %s exact=%d expected=%d\n",
37             test->label, (int) exact, (int) test->exact);
38         return 0;
39     }
40
41     if (detected != test->type) {
42         fprintf(stderr,
43             "FAIL: %s type=%u expected=%u\n",
44             test->label, detected, test->type);
45         return 0;
46     }
47
48     if (!exact) {
49         printf("PASS: %s legacy type=%u\n", test->label, detected);
50         return 1;
51     }
52
53     if (
54         info.type != test->type ||
55         info.static_cdb_base != test->cdb ||
56         info.static_gate != test->gate ||
57         info.mem_blocks != test->blocks ||
58         info.preferred_method != test->method ||
59         !info.tokens ||
60         strcmp(info.tokens, test->tokens) != 0 ||
61         !info.record_id ||
62         strcmp(info.record_id, test->record_id) != 0 ||
63         !info.support_tier ||
64         strcmp(info.support_tier, test->support_tier) != 0
65     ) {
66         fprintf(stderr,
67             "FAIL: %s type=%u cdb=0x%03x gate=0x%08x "
68             "blocks=%u method=%d tokens=%s record=%s tier=%s\n",
69             test->label,
70             info.type,
71             info.static_cdb_base,
72             info.static_gate,
73             info.mem_blocks,
74             info.preferred_method,
75             info.tokens ? info.tokens : "(null)",
76             info.record_id ? info.record_id : "(null)",
77             info.support_tier ? info.support_tier : "(null)");
78         return 0;
79     }
80
81     printf("PASS: %s exact cdb=0x%03x gate=0x%08x\n",
82         test->label, info.static_cdb_base, info.static_gate);
83     return 1;
84 }
85
86 int main(void) {
87     static const profile_case cases[] = {
88         {
89             "A102 live inquiry alias",
90             "HL-DT-ST", "CDRW/DVD GCC4243", "A102",
91             true, 3, 0x880U, 0x9003731dU, 5, 8,
92             "hybrid_identity_v3:stage5b_0439",
93             "HL;IT;RPC;RPC_JCS3;RPC_SUFFIX",
94             "known_supported_profile_hardening_live_validated"
95         },
96         {
97             "A102 canonical alias",
98             "HL-DT-ST", "GCC-4243N", "a102",
99             true, 3, 0x880U, 0x9003731dU, 5, 8,
100             "hybrid_identity_v3:stage5b_0439",
101             "HL;IT;RPC;RPC_JCS3;RPC_SUFFIX",
102             "known_supported_profile_hardening_live_validated"
103         },
104         {
105             "B101 live inquiry alias",
106             "HL-DT-ST", "CDRW/DVD GCC4244", "B101",
107             true, 3, 0x894U, 0x900386d2U, 5, 8,
108             "hybrid_identity_v3:stage5b_0426",
109             "HL;IT;RPC;RPC_JCS3;RPC_SUFFIX",
110             "known_supported_profile_hardening_live_validated"
111         },
112         {
113             "B101 canonical alias",
114             "HL-DT-ST", "GCC-4244N", "b101",
115             true, 3, 0x894U, 0x900386d2U, 5, 8,
116             "hybrid_identity_v3:stage5b_0426",
117             "HL;IT;RPC;RPC_JCS3;RPC_SUFFIX",
118             "known_supported_profile_hardening_live_validated"
119         },
120         {
121             "A101 existing canonical profile",
122             "HL-DT-ST", "GCC-4241N", "A101",
123             true, 21, 0x85cU, 0x900356b7U, 1, 8,
124             "stage5b_0064",
125             "HL;IT;RPC;RPC_JCS3;RPC_SUFFIX",
126             "error_prone_supported_profile_hardening"
127         },
128         {
129             "GDR-8050L 0012 hybrid operating identity",
130             "HL-DT-ST", "DVD-ROM GDR8050L", "0012",
131             true, 44, 0x5d0U, 0x90026160U, 1, 8,
132             "hybrid_identity_v3:gdr8050l_0012",
133             "HL;IT;RPC;RPC_JD4_SPACE;RPC_SUFFIX",
134             "hybrid_crossflash_modified_firmware_only"
135         },
136         {
137             "GDR-8050L 0L23 has no false exact metadata",
138             "HL-DT-ST", "DVD-ROM GDR8050L", "0L23",
139             false, 44, 0, 0, 0, 0, NULL, NULL, NULL
140         },
141         {
142             "A103 conservative Type3 fallback",
143             "HL-DT-ST", "CDRW/DVD GCC4243", "A103",
144             false, 3, 0, 0, 0, 0, NULL, NULL, NULL
145         },
146         {
147             "B102 conservative Type3 fallback",
148             "HL-DT-ST", "CDRW/DVD GCC4244", "B102",
149             false, 3, 0, 0, 0, 0, NULL, NULL, NULL
150         },
151         {
152             "non-HL vendor rejected",
153             "NOT-HL", "CDRW/DVD GCC4243", "A102",
154             false, 0, 0, 0, 0, 0, NULL, NULL, NULL
155         }
156     };
157     size_t i;
158     int ok = 1;
159
160     for (i = 0; i < sizeof(cases) / sizeof(cases[0]); i++)
161         ok &= check_case(&cases[i]);
162
163     if (!ok)
164         return 1;
165
166     printf("HLDS E7 PROFILE SELECTION TESTS: PASS\n");
167     return 0;
168 }