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

Side by Side Diff: tests/vboot_nvstorage_test.c

Issue 6469059: VbNvStorage cleanup and comments (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Fixes from code review Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « firmware/linktest/main.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 #include <string.h> 10 #include <string.h>
11 11
12 #include "test_common.h" 12 #include "test_common.h"
13 #include "vboot_common.h" 13 #include "vboot_common.h"
14 #include "vboot_nvstorage.h" 14 #include "vboot_nvstorage.h"
15 15
16 #if 0
17 16
18 /* Initialize the NV storage library. This must be called before any 17 static void VbNvStorageTest(void) {
19 * other functions in this library. Returns 0 if success, non-zero if
20 * error. */
21 int VbNvSetup(VbNvContext* context);
22
23 /* Clean up and flush changes back to the raw data. This must be
24 * called after other functions in this library. Caller must check
25 * context.raw_changed after calling tis function. Returns 0 if
26 * success, non-zero if error. */
27 int VbNvTeardown(VbNvContext* context);
28
29 /* Read a NV storage parameter into *dest. Returns 0 if success,
30 * non-zero if error. */
31 int VbNvGet(VbNvContext* context, VbNvParam param, uint32_t* dest);
32
33 /* Set a NV storage param to a new value. Returns 0 if success,
34 * non-zero if error. */
35 int VbNvSet(VbNvContext* context, VbNvParam param, uint32_t value);
36
37 typedef struct VbNvContext {
38 /* Raw NV data. Caller must fill this before calling VbNvStart(). */
39 uint8_t raw[NV_BLOCK_SIZE];
40 /* Flag indicating whether raw data has changed. Set by VbNvStop() if
41 * the raw data has changed and needs to be stored to the underlying
42 * non-volatile data store. */
43 int raw_changed;
44
45 /* Internal data for NV storage routines. Caller should not touch
46 * these fields. */
47 int regenerate_crc;
48
49 } VbNvContext;
50
51 #endif
52
53 static void VbStorageTest(void) {
54 18
55 VbNvContext c; 19 VbNvContext c;
56 uint8_t goodcrc; 20 uint8_t goodcrc;
57 uint32_t data; 21 uint32_t data;
58 22
59 memset(&c, 0xA6, sizeof(c)); 23 memset(&c, 0xA6, sizeof(c));
60 24
61 /* Open with invalid data should set defaults */ 25 /* Open with invalid data should set defaults */
62 TEST_EQ(VbNvSetup(&c), 0, "VbNvSetup()"); 26 TEST_EQ(VbNvSetup(&c), 0, "VbNvSetup()");
63 TEST_EQ(c.raw[0], 0x70, "VbNvSetup() reset header byte"); 27 TEST_EQ(c.raw[0], 0x70, "VbNvSetup() reset header byte");
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 TEST_EQ(c.raw_changed, 0, "No raw change if data not changed"); 158 TEST_EQ(c.raw_changed, 0, "No raw change if data not changed");
195 } 159 }
196 160
197 161
198 /* disable MSVC warnings on unused arguments */ 162 /* disable MSVC warnings on unused arguments */
199 __pragma(warning (disable: 4100)) 163 __pragma(warning (disable: 4100))
200 164
201 int main(int argc, char* argv[]) { 165 int main(int argc, char* argv[]) {
202 int error_code = 0; 166 int error_code = 0;
203 167
204 VbStorageTest(); 168 VbNvStorageTest();
205 169
206 if (!gTestSuccess) 170 if (!gTestSuccess)
207 error_code = 255; 171 error_code = 255;
208 172
209 return error_code; 173 return error_code;
210 } 174 }
OLDNEW
« no previous file with comments | « firmware/linktest/main.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698