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

Side by Side Diff: tests/cgptlib_test.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 | « firmware/lib/vboot_kernel.c ('k') | tests/vboot_common_tests.c » ('j') | 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 5
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "cgptlib.h" 8 #include "cgptlib.h"
9 #include "cgptlib_internal.h" 9 #include "cgptlib_internal.h"
10 #include "cgptlib_test.h" 10 #include "cgptlib_test.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 Memcpy(header2, header, sizeof(GptHeader)); 164 Memcpy(header2, header, sizeof(GptHeader));
165 Memcpy(entries2, entries, PARTITION_ENTRIES_SIZE); 165 Memcpy(entries2, entries, PARTITION_ENTRIES_SIZE);
166 header2->my_lba = DEFAULT_DRIVE_SECTORS - 1; /* 466 */ 166 header2->my_lba = DEFAULT_DRIVE_SECTORS - 1; /* 466 */
167 header2->alternate_lba = 1; 167 header2->alternate_lba = 1;
168 header2->entries_lba = DEFAULT_DRIVE_SECTORS - 1 - 32; /* 434 */ 168 header2->entries_lba = DEFAULT_DRIVE_SECTORS - 1 - 32; /* 434 */
169 169
170 RefreshCrc32(gpt); 170 RefreshCrc32(gpt);
171 } 171 }
172 172
173 173
174 /* Tests if the structures are the expected size; if this fails,
175 * struct packing is not working properly. */
176 static int StructSizeTest() {
177
178 EXPECT(GUID_EXPECTED_SIZE == sizeof(Guid));
179 EXPECT(GPTHEADER_EXPECTED_SIZE == sizeof(GptHeader));
180 EXPECT(GPTENTRY_EXPECTED_SIZE == sizeof(GptEntry));
181
182 return TEST_OK;
183 }
184
185
174 /* Tests if the default structure returned by BuildTestGptData() is good. */ 186 /* Tests if the default structure returned by BuildTestGptData() is good. */
175 static int TestBuildTestGptData() { 187 static int TestBuildTestGptData() {
176 GptData* gpt; 188 GptData* gpt;
177 189
178 gpt = GetEmptyGptData(); 190 gpt = GetEmptyGptData();
179 BuildTestGptData(gpt); 191 BuildTestGptData(gpt);
180 EXPECT(GPT_SUCCESS == GptInit(gpt)); 192 EXPECT(GPT_SUCCESS == GptInit(gpt));
181 return TEST_OK; 193 return TEST_OK;
182 } 194 }
183 195
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1093
1082 1094
1083 int main(int argc, char *argv[]) { 1095 int main(int argc, char *argv[]) {
1084 int i; 1096 int i;
1085 int error_count = 0; 1097 int error_count = 0;
1086 struct { 1098 struct {
1087 char *name; 1099 char *name;
1088 test_func fp; 1100 test_func fp;
1089 int retval; 1101 int retval;
1090 } test_cases[] = { 1102 } test_cases[] = {
1103 { TEST_CASE(StructSizeTest), },
1091 { TEST_CASE(TestBuildTestGptData), }, 1104 { TEST_CASE(TestBuildTestGptData), },
1092 { TEST_CASE(ParameterTests), }, 1105 { TEST_CASE(ParameterTests), },
1093 { TEST_CASE(HeaderCrcTest), }, 1106 { TEST_CASE(HeaderCrcTest), },
1094 { TEST_CASE(SignatureTest), }, 1107 { TEST_CASE(SignatureTest), },
1095 { TEST_CASE(RevisionTest), }, 1108 { TEST_CASE(RevisionTest), },
1096 { TEST_CASE(SizeTest), }, 1109 { TEST_CASE(SizeTest), },
1097 { TEST_CASE(CrcFieldTest), }, 1110 { TEST_CASE(CrcFieldTest), },
1098 { TEST_CASE(ReservedFieldsTest), }, 1111 { TEST_CASE(ReservedFieldsTest), },
1099 { TEST_CASE(SizeOfPartitionEntryTest), }, 1112 { TEST_CASE(SizeOfPartitionEntryTest), },
1100 { TEST_CASE(NumberOfPartitionEntriesTest), }, 1113 { TEST_CASE(NumberOfPartitionEntriesTest), },
(...skipping 30 matching lines...) Expand all
1131 printf(COL_RED "The following %d test cases are failed:\n" COL_STOP, 1144 printf(COL_RED "The following %d test cases are failed:\n" COL_STOP,
1132 error_count); 1145 error_count);
1133 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { 1146 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) {
1134 if (test_cases[i].retval) 1147 if (test_cases[i].retval)
1135 printf(" %s()\n", test_cases[i].name); 1148 printf(" %s()\n", test_cases[i].name);
1136 } 1149 }
1137 } 1150 }
1138 1151
1139 return (error_count) ? 1 : 0; 1152 return (error_count) ? 1 : 0;
1140 } 1153 }
OLDNEW
« no previous file with comments | « firmware/lib/vboot_kernel.c ('k') | tests/vboot_common_tests.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698