1 /*
2 Copyright (c) 2018, MIPI Alliance, Inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16
17 * Neither the name of the copyright holder nor the names of its
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * Contributors:
36 * Norbert Schulz (Intel Corporation) - Initial API and implementation
37 */
38
39 #include "mipi_syst_gtest.h"
40
41 #include "../../src/mipi_syst_init.c"
42 #include "mipi_syst_platform.c"
43 #include "../../src/mipi_syst_writer.c"
44
45 std::stringstream MipiSysTFixtureOutput::sstr;
46
47 struct mipi_syst_origin MipiSysTFixtureBase::origin = MIPI_SYST_GEN_ORIGIN_MODULE(1, 2);
48
49 /* Test structure sizes used in binary output processing
50 */
TEST_F(MipiSysTFixtureBase,syst_structure_sizes)51 TEST_F(MipiSysTFixtureBase, syst_structure_sizes)
52 {
53 EXPECT_EQ(1, sizeof(mipi_syst_u8)) << "mipi_syst_u8 not 1 byte long";
54 EXPECT_EQ(2, sizeof(mipi_syst_u16)) << "mipi_syst_u16 not 2 byte long";
55 EXPECT_EQ(4, sizeof(mipi_syst_u32)) << "mipi_syst_u32 not 4 byte long";
56 EXPECT_EQ(8, sizeof(mipi_syst_u64)) << "mipi_syst_u64 not 8 byte long";
57
58 EXPECT_EQ(1, sizeof(mipi_syst_s8)) << "mipi_syst_s8 not 1 byte long";
59 EXPECT_EQ(2, sizeof(mipi_syst_s16)) << "mipi_syst_s16 not 2 byte long";
60 EXPECT_EQ(4, sizeof(mipi_syst_s32)) << "mipi_syst_s32 not 4 byte long";
61 EXPECT_EQ(8, sizeof(mipi_syst_s64)) << "mipi_syst_s64 not 8 byte long";
62
63 EXPECT_EQ(16, sizeof(struct mipi_syst_guid)) << "struct mipi_syst_guid not 16 byte long";
64
65 EXPECT_EQ(4, sizeof(struct mipi_syst_msg_tag)) << "struct mipi_syst_msg_tag must be 32bit";
66 EXPECT_EQ(4, sizeof(struct mipi_syst_scatter_prog )) << "syst_scatter_prog_t must be 32bit";
67 EXPECT_EQ(4, sizeof(union mipi_syst_msglocation32)) << "mipi_syst_msglocation32 must be 32bit";
68 EXPECT_EQ(8, sizeof(union mipi_syst_msglocation64)) << "mipi_syst_msglocation64 must be 64bit";
69 }
70
TEST_F(MipiSysTFixtureBase,syst_little_endian_swap)71 TEST_F(MipiSysTFixtureBase, syst_little_endian_swap)
72 {
73 union { mipi_syst_u16 v; mipi_syst_u8 b[2]; } v16 = { MIPI_SYST_HTOLE16(0x1234) };
74 EXPECT_EQ(v16.b[0], 0x34);
75 EXPECT_EQ(v16.b[1], 0x12);
76
77 union { mipi_syst_u32 v; mipi_syst_u8 b[4]; } v32 = { MIPI_SYST_HTOLE32(0x12345678) };
78 EXPECT_EQ(v32.b[0], 0x78);
79 EXPECT_EQ(v32.b[1], 0x56);
80 EXPECT_EQ(v32.b[2], 0x34);
81 EXPECT_EQ(v32.b[3], 0x12);
82
83 union { mipi_syst_u64 v; mipi_syst_u8 b[8]; } v64 = { MIPI_SYST_HTOLE64(0x12345678AABBCCDDull) };
84 EXPECT_EQ(v64.b[0], 0xDD);
85 EXPECT_EQ(v64.b[1], 0xCC);
86 EXPECT_EQ(v64.b[2], 0xBB);
87 EXPECT_EQ(v64.b[3], 0xAA);
88 EXPECT_EQ(v64.b[4], 0x78);
89 EXPECT_EQ(v64.b[5], 0x56);
90 EXPECT_EQ(v64.b[6], 0x34);
91 EXPECT_EQ(v64.b[7], 0x12);
92 }
93
94
95 /* test header bitfield alignment*/
TEST_F(MipiSysTFixtureBase,syst_header_bit_alignment)96 TEST_F(MipiSysTFixtureBase, syst_header_bit_alignment)
97 {
98 union {
99 mipi_syst_msg_tag tag;
100 mipi_syst_u32 val;
101 mipi_syst_u8 b[4];
102 } native, little;
103
104 little.val = native.val = 0;
105 native.tag.et_type = 0xF;
106 little.b[0] = 0xF;
107 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (type)";
108
109 little.val = native.val = 0;
110 native.tag.et_severity = 0x7;
111 little.b[0] = 0x7<< 4;
112 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (severity)";
113
114 little.val = native.val = 0;
115 native.tag.et_res7 = 1;
116 little.b[0] = 0x80;
117 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (res7)";
118
119 little.val = native.val = 0;
120 native.tag.et_location = 1;
121 little.b[1] = 1;
122 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (location)";
123
124 little.val = native.val = 0;
125 native.tag.et_length = 1;
126 little.b[1] = 1<<1;
127 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (length)";
128
129 little.val = native.val = 0;
130 native.tag.et_chksum = 1;
131 little.b[1] = 1<<2;
132 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (chksum)";
133
134 little.val = native.val = 0;
135 native.tag.et_timestamp = 1;
136 little.b[1] = 1<<3;
137 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (timestamp)";
138
139 little.val = native.val = 0;
140 native.tag.et_modunit = 0x7FF;
141 little.b[1] = 0xF << 4;
142 little.b[2] = 0x7F;
143 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (origin)";
144
145 little.val = native.val = 0;
146 native.tag.et_guid = 1;
147 little.b[2] = 0x80;
148 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (guid)";
149
150 little.val = native.val = 0;
151 native.tag.et_subtype = 0x3F;
152 little.b[3] = 0x3F;
153 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (subtype)";
154
155 little.val = native.val = 0;
156 native.tag.et_res30 = 1;
157 little.b[3] = 0x40;
158 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (res30)";
159
160 little.val = native.val = 0;
161 native.tag.et_res31 = 1;
162 little.b[3] = 0x80;
163 EXPECT_EQ(little.val, MIPI_SYST_HTOLE32(native.val)) << "mipi_syst_msg_tag bit alignment wrong (res31)";
164 }
165
166 /* Check initialization of global state
167 */
TEST_F(MipiSysTFixtureBase,syst_global_state_creation)168 TEST_F(MipiSysTFixtureBase, syst_global_state_creation)
169 {
170 struct mipi_syst_header* ph = &syst_hdr;
171
172 EXPECT_EQ(ph->systh_version, MIPI_SYST_VERSION_CODE) << "syst header has unexpected version";
173 #if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA)
174 EXPECT_EQ(ph->systh_inith, &platform_handle_init) << "syst header handle init hook wrong";
175 EXPECT_EQ(ph->systh_releaseh, &platform_handle_release) << "syst header handle release hook wrong";
176 #endif
177 #if defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE)
178 EXPECT_EQ(ph->systh_writer, &mipi_syst_scatter_write) << "syst header writer function wrong ";
179 #endif
180 }
181
TEST_F(MipiSysTFixtureBase,syst_custom_state_creation)182 TEST_F(MipiSysTFixtureBase, syst_custom_state_creation)
183 {
184 struct mipi_syst_header custom_hdr;
185
186 MIPI_SYST_INIT_STATE(&custom_hdr, mipi_syst_platform_init, (void*)0);
187
188 EXPECT_EQ(custom_hdr.systh_version, MIPI_SYST_VERSION_CODE) << "syst header has unexpected version";
189 #if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA)
190 EXPECT_EQ(custom_hdr.systh_inith, &platform_handle_init) << "syst header handle init hook wrong";
191 EXPECT_EQ(custom_hdr.systh_releaseh, &platform_handle_release) << "syst header handle release hook wrong";
192 #endif
193 #if defined(MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE)
194 EXPECT_EQ(custom_hdr.systh_writer, &mipi_syst_scatter_write) << "syst header writer function wrong ";
195 #endif
196
197 MIPI_SYST_SHUTDOWN_STATE(&custom_hdr, mipi_syst_platform_destroy);
198 }
199
200 /* Check initialization of handle state
201 */
TEST_F(MipiSysTFixtureBase,syst_handle_static_creation)202 TEST_F(MipiSysTFixtureBase, syst_handle_static_creation)
203 {
204 struct mipi_syst_handle sh;
205 struct mipi_syst_handle* ph;
206
207 ph = MIPI_SYST_INIT_HANDLE(&sh, NULL);
208 MIPI_SYST_SET_HANDLE_MODULE_UNIT(ph, 1,2);
209
210 ASSERT_EQ(ph, &sh) << "static allocation did not return passed pointer";
211
212 EXPECT_EQ(&syst_hdr, ph->systh_header) << "header not set in handle";
213 EXPECT_EQ(0, ph->systh_flags.shf_alloc) << "handle indicates allocation, but is static";
214 EXPECT_EQ(0x012, ph->systh_tag.et_modunit) << "module id not set in handle";
215
216 MIPI_SYST_DELETE_HANDLE(ph);
217 }
218
TEST_F(MipiSysTFixtureBase,syst_custom_handle_static_creation)219 TEST_F(MipiSysTFixtureBase, syst_custom_handle_static_creation)
220 {
221 struct mipi_syst_handle sh;
222 struct mipi_syst_handle* ph;
223
224 struct mipi_syst_header custom_hdr;
225 MIPI_SYST_INIT_STATE(&custom_hdr, mipi_syst_platform_init, (void*)0);
226
227 ph = MIPI_SYST_INIT_HANDLE_STATE(&custom_hdr, &sh, &origin);
228
229 ASSERT_EQ(ph, &sh) << "static allocation did not return passed pointer";
230
231 EXPECT_EQ(&custom_hdr, ph->systh_header) << "custom header not set in handle";
232 EXPECT_EQ(0, ph->systh_flags.shf_alloc) << "handle indicates allocation, but is static";
233 #if defined(MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID)
234 EXPECT_EQ(0x012, ph->systh_tag.et_modunit) << "origin id not set in handle";
235 #endif
236 MIPI_SYST_DELETE_HANDLE(ph);
237 MIPI_SYST_SHUTDOWN_STATE(&custom_hdr, mipi_syst_platform_destroy);
238 }
239
240 #if defined(MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID)
TEST_F(MipiSysTFixtureBase,syst_test_guid_origin_handle_creation)241 TEST_F(MipiSysTFixtureBase, syst_test_guid_origin_handle_creation)
242 {
243 struct mipi_syst_handle sh;
244 struct mipi_syst_handle* ph;
245 struct mipi_syst_origin guid_origin =
246 MIPI_SYST_GEN_ORIGIN_GUID(
247 0x494E5443, 0xA2AE, 0x4C70, 0xABB5, 0xD1A79E9CEA35,
248 0x7FF);
249
250 ph = MIPI_SYST_INIT_HANDLE(&sh, &guid_origin);
251
252 ASSERT_EQ(ph, &sh) << "static allocation did not return passed pointer";
253
254 EXPECT_EQ(&syst_hdr, ph->systh_header) << "header not set in handle";
255 EXPECT_EQ(0, ph->systh_flags.shf_alloc) << "handle indicates allocation, but is static";
256 EXPECT_EQ(0x7FF, ph->systh_tag.et_modunit) << "module id not set in handle";
257 EXPECT_EQ(ph->systh_guid.u.ll[0], MIPI_SYST_HTOLE64(guid_origin.guid.u.ll[0]));
258 EXPECT_EQ(ph->systh_guid.u.ll[1], MIPI_SYST_HTOLE64(guid_origin.guid.u.ll[1]));
259 MIPI_SYST_DELETE_HANDLE(ph);
260 }
261 #endif
262
263 #if defined(MIPI_SYST_PCFG_ENABLE_HEAP_MEMORY)
TEST_F(MipiSysTFixtureBase,syst_handle_dynamic_creation)264 TEST_F(MipiSysTFixtureBase, syst_handle_dynamic_creation)
265 {
266 struct mipi_syst_handle* ph;
267
268 ph = MIPI_SYST_ALLOC_HANDLE(NULL);
269 MIPI_SYST_SET_HANDLE_MODULE_UNIT(ph, 1,2);
270
271 ASSERT_NE(ph, (struct mipi_syst_handle*)0) << "allocation failed";
272
273 EXPECT_EQ(&syst_hdr, ph->systh_header) << "header not set in handle";
274 EXPECT_EQ(1, ph->systh_flags.shf_alloc) << "handle indicates static, but is allocated";
275 EXPECT_EQ(0x012, ph->systh_tag.et_modunit) << "origin id not set in handle";
276
277 MIPI_SYST_DELETE_HANDLE(ph);
278 }
279
TEST_F(MipiSysTFixtureBase,syst_custom_handle_dynamic_creation)280 TEST_F(MipiSysTFixtureBase, syst_custom_handle_dynamic_creation)
281 {
282 struct mipi_syst_handle* ph;
283 struct mipi_syst_header custom_hdr;
284 MIPI_SYST_INIT_STATE(&custom_hdr, mipi_syst_platform_init, (void*)0);
285
286 ph = MIPI_SYST_ALLOC_HANDLE_STATE(&custom_hdr, NULL);
287 MIPI_SYST_SET_HANDLE_MODULE_UNIT(ph, 1,2);
288
289 ASSERT_NE(ph, (struct mipi_syst_handle*)0) << "allocation failed";
290
291 EXPECT_EQ(&custom_hdr, ph->systh_header) << "custom header not set in handle";
292 EXPECT_EQ(1, ph->systh_flags.shf_alloc) << "handle indicates static, but is allocated";
293 EXPECT_EQ(0x012, ph->systh_tag.et_modunit) << "origin id not set in handle";
294
295 MIPI_SYST_DELETE_HANDLE(ph);
296 }
297 #endif
298
TEST_F(MipiSysTFixtureBase,syst_message_flags)299 TEST_F(MipiSysTFixtureBase, syst_message_flags)
300 {
301 struct mipi_syst_handle* ph;
302 struct mipi_syst_header custom_hdr;
303 MIPI_SYST_INIT_STATE(&custom_hdr, mipi_syst_platform_init, (void*)0);
304
305 ph = MIPI_SYST_ALLOC_HANDLE_STATE(&custom_hdr, &origin);
306
307 ASSERT_NE(ph, (struct mipi_syst_handle*)0) << "allocation failed";
308
309
310 #if defined(MIPI_SYST_PCFG_ENABLE_CHECKSUM)
311 EXPECT_EQ(0,MIPI_SYST_GET_HANDLE_CHECKSUM(ph));
312
313 MIPI_SYST_ENABLE_HANDLE_CHECKSUM(ph, 1);
314 EXPECT_NE(0, MIPI_SYST_GET_HANDLE_CHECKSUM(ph));
315
316 MIPI_SYST_ENABLE_HANDLE_CHECKSUM(ph, 0);
317 EXPECT_EQ(0, MIPI_SYST_GET_HANDLE_CHECKSUM(ph));
318 #endif
319 #if defined(MIPI_SYST_PCFG_ENABLE_TIMESTAMP)
320 EXPECT_EQ(0,MIPI_SYST_GET_HANDLE_TIMESTAMP(ph));
321
322 MIPI_SYST_ENABLE_HANDLE_TIMESTAMP(ph, 1);
323 EXPECT_NE(0, MIPI_SYST_GET_HANDLE_TIMESTAMP(ph));
324
325 MIPI_SYST_ENABLE_HANDLE_TIMESTAMP(ph, 0);
326 EXPECT_EQ(0, MIPI_SYST_GET_HANDLE_TIMESTAMP(ph));
327 #endif
328 MIPI_SYST_DELETE_HANDLE(ph);
329 }
330
331
TEST_F(MipiSysTFixtureBase,syst_version_macro)332 TEST_F(MipiSysTFixtureBase, syst_version_macro)
333 {
334 mipi_syst_u32 version = (MIPI_SYST_VERSION_MAJOR<<16) |(MIPI_SYST_VERSION_MINOR<<8)|MIPI_SYST_VERSION_PATCH;
335 std::stringstream sstr;
336 sstr << MIPI_SYST_VERSION_MAJOR << "." << MIPI_SYST_VERSION_MINOR << "." << MIPI_SYST_VERSION_PATCH;
337 std::string verstr(sstr.str());
338
339 EXPECT_STREQ(verstr.c_str(), MIPI_SYST_VERSION_STRING);
340
341 EXPECT_EQ(MIPI_SYST_VERSION_CODE, version) << "unexpected version code";
342
343
344 ASSERT_LT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3),
345 MIPI_SYST_MAKE_VERSION_CODE(2,0,0));
346 ASSERT_LT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3),
347 MIPI_SYST_MAKE_VERSION_CODE(1,3,3));
348 ASSERT_LT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3),
349 MIPI_SYST_MAKE_VERSION_CODE(1,2,4));
350
351 ASSERT_GT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3),
352 MIPI_SYST_MAKE_VERSION_CODE(0,2,3));
353 ASSERT_GT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3),
354 MIPI_SYST_MAKE_VERSION_CODE(1,1,3));
355 ASSERT_GT(MIPI_SYST_MAKE_VERSION_CODE(1,2,3),
356 MIPI_SYST_MAKE_VERSION_CODE(1,2,2));
357 }
358
TEST_F(MipiSysTFixtureBase,syst_handle_nullptr)359 TEST_F(MipiSysTFixtureBase, syst_handle_nullptr)
360 {
361 MIPI_SYST_INIT_HANDLE(0,NULL);
362 MIPI_SYST_DELETE_HANDLE(0);
363
364 EXPECT_EQ(0,0); // only reached if above calls don't crash
365 }
366
367 // {1DBBA102-DFFD-4A05-8CED-F744046715ED}
368
369 struct mipi_syst_guid guid1=
370 {{0x1d, 0xbb, 0xa1, 0x02, 0xdf, 0xfd, 0x4a, 0x05, 0x8c, 0xed, 0xf7, 0x44, 0x4, 0x67, 0x15, 0xed} };
371
372 struct mipi_syst_guid guid2 = MIPI_SYST_GEN_GUID(0x1DBBA102, 0xDFFD, 0x4A05, 0x8CED, 0xF744046715ED);
373
TEST_F(MipiSysTFixtureBase,syst_guid)374 TEST_F(MipiSysTFixtureBase, syst_guid)
375 {
376 union {
377 struct mipi_syst_guid g; mipi_syst_u64 ll[2];
378 } v;
379
380 v.ll[0] = MIPI_SYST_HTOLE64(guid2.u.ll[0]);
381 v.ll[1] = MIPI_SYST_HTOLE64(guid2.u.ll[1]);
382
383 EXPECT_EQ(guid1.u.b[0], guid2.u.b[0]);
384 EXPECT_EQ(guid1.u.b[1], guid2.u.b[1]);
385 EXPECT_EQ(guid1.u.b[2], guid2.u.b[2]);
386 EXPECT_EQ(guid1.u.b[3], guid2.u.b[3]);
387 EXPECT_EQ(guid1.u.b[4], guid2.u.b[4]);
388 EXPECT_EQ(guid1.u.b[5], guid2.u.b[5]);
389 EXPECT_EQ(guid1.u.b[6], guid2.u.b[6]);
390 EXPECT_EQ(guid1.u.b[7], guid2.u.b[7]);
391 EXPECT_EQ(guid1.u.b[8], guid2.u.b[8]);
392 EXPECT_EQ(guid1.u.b[9], guid2.u.b[9]);
393 EXPECT_EQ(guid1.u.b[10], guid2.u.b[10]);
394 EXPECT_EQ(guid1.u.b[11], guid2.u.b[11]);
395 EXPECT_EQ(guid1.u.b[12], guid2.u.b[12]);
396 EXPECT_EQ(guid1.u.b[13], guid2.u.b[13]);
397 EXPECT_EQ(guid1.u.b[14], guid2.u.b[14]);
398 EXPECT_EQ(guid1.u.b[15], guid2.u.b[15]);
399 }
400
401 #define LONG_STR \
402 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
403 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" \
404 "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" \
405 "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
406
TEST_F(MipiSysTFixtureBase,syst_hash)407 TEST_F(MipiSysTFixtureBase, syst_hash)
408 {
409 mipi_syst_u32 val1, val2, val3;
410
411 val1 = _MIPI_SYST_HASH_AT_CPP_TIME("", 0);
412 val2 = _MIPI_SYST_HASH_AT_RUN_TIME("", 0);
413 EXPECT_EQ(val1, val2);
414
415 EXPECT_EQ(0x0, _MIPI_SYST_HASH_AT_RUN_TIME("", 0));
416 EXPECT_EQ(0x19ae84c4, _MIPI_SYST_HASH_AT_RUN_TIME("hello world", 0));
417
418 val1 = _MIPI_SYST_HASH_AT_CPP_TIME("hello world", 0);
419 val2 = _MIPI_SYST_HASH_AT_RUN_TIME("hello world", 0);
420 EXPECT_EQ(val1, val2);
421
422 val1 = _MIPI_SYST_HASH_AT_CPP_TIME(LONG_STR, 0);
423 val2 = _MIPI_SYST_HASH_AT_RUN_TIME(LONG_STR, 0);
424 EXPECT_EQ(val1, val2);
425
426 val1 = _MIPI_SYST_HASH_AT_CPP_TIME(LONG_STR, 0);
427 val2 = _MIPI_SYST_HASH_AT_CPP_TIME(LONG_STR, 1);
428 val3 = _MIPI_SYST_HASH_AT_CPP_TIME(LONG_STR, 3);
429 EXPECT_NE(val1, val2);
430 EXPECT_NE(val1, val3);
431 EXPECT_NE(val2, val3);
432 }