Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(728)

Side by Side Diff: tests/vboot_common_tests.c

Issue 2865014: Assorted integration fixes. (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Add struct size tests Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/cgptlib_test.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Tests for firmware image library. 5 * Tests for firmware image library.
6 */ 6 */
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 #include "test_common.h" 11 #include "test_common.h"
12 #include "vboot_common.h" 12 #include "vboot_common.h"
13 13
14 /* Test struct packing */
15 static void StructPackingTest(void) {
16 TEST_EQ(EXPECTED_VBPUBLICKEY_SIZE, sizeof(VbPublicKey),
17 "sizeof(VbPublicKey)");
18 TEST_EQ(EXPECTED_VBSIGNATURE_SIZE, sizeof(VbSignature),
19 "sizeof(VbSignature)");
20 TEST_EQ(EXPECTED_VBKEYBLOCKHEADER_SIZE, sizeof(VbKeyBlockHeader),
21 "sizeof(VbKeyBlockHeader)");
22 TEST_EQ(EXPECTED_VBFIRMWAREPREAMBLEHEADER_SIZE,
23 sizeof(VbFirmwarePreambleHeader), "sizeof(VbFirmwarePreambleHeader)");
24 TEST_EQ(EXPECTED_VBKERNELPREAMBLEHEADER_SIZE,
25 sizeof(VbKernelPreambleHeader), "sizeof(VbKernelPreambleHeader)");
26 }
27
14 28
15 /* Helper functions not dependent on specific key sizes */ 29 /* Helper functions not dependent on specific key sizes */
16 void VerifyHelperFunctions(void) { 30 static void VerifyHelperFunctions(void) {
17 31
18 { 32 {
19 uint8_t p[1]; 33 uint8_t p[1];
20 TEST_EQ(OffsetOf(p, p), 0, "OffsetOf() equal"); 34 TEST_EQ(OffsetOf(p, p), 0, "OffsetOf() equal");
21 TEST_EQ(OffsetOf(p, p+10), 10, "OffsetOf() positive"); 35 TEST_EQ(OffsetOf(p, p+10), 10, "OffsetOf() positive");
22 TEST_EQ(OffsetOf(p, p+0x12345678), 0x12345678, "OffsetOf() large"); 36 TEST_EQ(OffsetOf(p, p+0x12345678), 0x12345678, "OffsetOf() large");
23 } 37 }
24 38
25 { 39 {
26 VbPublicKey k = {sizeof(k), 2, 3, 4}; 40 VbPublicKey k = {sizeof(k), 2, 3, 4};
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 TEST_EQ(VerifySignatureInside(&s, 99, &s), 1, 98 TEST_EQ(VerifySignatureInside(&s, 99, &s), 1,
85 "SignatureInside offset too big"); 99 "SignatureInside offset too big");
86 } 100 }
87 101
88 } 102 }
89 103
90 104
91 int main(int argc, char* argv[]) { 105 int main(int argc, char* argv[]) {
92 int error_code = 0; 106 int error_code = 0;
93 107
94 /* Test helper functions */ 108 StructPackingTest();
95 VerifyHelperFunctions(); 109 VerifyHelperFunctions();
96 110
97 if (!gTestSuccess) 111 if (!gTestSuccess)
98 error_code = 255; 112 error_code = 255;
99 113
100 return error_code; 114 return error_code;
101 } 115 }
OLDNEW
« no previous file with comments | « tests/cgptlib_test.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698