16dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler * Use of this source code is governed by a BSD-style license that can be 3b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler * found in the LICENSE file. 4b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler * 5172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler * Tests for firmware NV storage library. 6b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler */ 7b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 80c3ba249abb1dc60f5ebabccf84ff13206440b83Bill Richardson#include <stdint.h> 9b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler#include <stdio.h> 10b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler#include <stdlib.h> 11b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler#include <string.h> 12b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 13b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler#include "test_common.h" 14b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler#include "vboot_common.h" 15b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler#include "vboot_nvstorage.h" 16b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 17172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler/* Single NV storage field to test */ 18172602829dc0d79ed65d7ed81225389f090b981fRandall Spanglertypedef struct VbNvField { 19172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler VbNvParam param; /* Parameter index */ 20172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler uint32_t default_value; /* Expected default value */ 21172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler uint32_t test_value; /* Value to test writing */ 22172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler uint32_t test_value2; /* Second value to test writing */ 23172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler char* desc; /* Field description */ 24172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler} VbNvField; 25172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler 26172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler/* Array of fields to test, terminated with a field with desc==NULL. */ 27172602829dc0d79ed65d7ed81225389f090b981fRandall Spanglerstatic VbNvField nvfields[] = { 28172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler {VBNV_DEBUG_RESET_MODE, 0, 1, 0, "debug reset mode"}, 29172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler {VBNV_TRY_B_COUNT, 0, 6, 15, "try B count"}, 30172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler {VBNV_RECOVERY_REQUEST, 0, 0x42, 0xED, "recovery request"}, 31172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler {VBNV_LOCALIZATION_INDEX, 0, 0x69, 0xB0, "localization index"}, 32172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler {VBNV_KERNEL_FIELD, 0, 0x12345678, 0xFEDCBA98, "kernel field"}, 33daa807c51ef6d5bf6599e649d1777432bea8a3e5Randall Spangler {VBNV_DEV_BOOT_USB, 0, 1, 0, "dev boot usb"}, 34a2326ee152ab5b8aee924ccf794cee38d54909bdStefan Reinauer {VBNV_DEV_BOOT_LEGACY, 0, 1, 0, "dev boot legacy"}, 357272a6951107251a5c9b26330c506319a92a54b3Bill Richardson {VBNV_DEV_BOOT_SIGNED_ONLY, 0, 1, 0, "dev boot custom"}, 3629e8807ea045e119e3adeaec40c5f8421901b6fbRandall Spangler {VBNV_DISABLE_DEV_REQUEST, 0, 1, 0, "disable dev request"}, 3729e8807ea045e119e3adeaec40c5f8421901b6fbRandall Spangler {VBNV_CLEAR_TPM_OWNER_REQUEST, 0, 1, 0, "clear tpm owner request"}, 3829e8807ea045e119e3adeaec40c5f8421901b6fbRandall Spangler {VBNV_CLEAR_TPM_OWNER_DONE, 0, 1, 0, "clear tpm owner done"}, 396dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler {VBNV_OPROM_NEEDED, 0, 1, 0, "oprom needed"}, 409e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler {VBNV_FW_TRY_COUNT, 0, 8, 15, "try count"}, 419e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler {VBNV_FW_TRY_NEXT, 0, 1, 0, "try next"}, 429e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler {VBNV_FW_TRIED, 0, 1, 0, "firmware tried"}, 439e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler {VBNV_FW_RESULT, VBNV_FW_RESULT_UNKNOWN, 1, 2, "firmware result"}, 44782300d093a2fbf2ca24e446fb6d65f9f28e56a6Randall Spangler {VBNV_FW_PREV_TRIED, 0, 1, 0, "firmware prev tried"}, 45782300d093a2fbf2ca24e446fb6d65f9f28e56a6Randall Spangler {VBNV_FW_PREV_RESULT, VBNV_FW_RESULT_UNKNOWN, 1, 3, "firmware prev result"}, 46172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler {0, 0, 0, 0, NULL} 47172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler}; 48b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 499e162cdaa7433dff01d3e47ba3a47cb8b39ff3a1Randall Spanglerstatic void VbNvStorageTest(void) { 50b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 51172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler VbNvField* vnf; 52b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvContext c; 53b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler uint8_t goodcrc; 54b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler uint32_t data; 55b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 56b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler memset(&c, 0xA6, sizeof(c)); 57b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 58b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* Open with invalid data should set defaults */ 59b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(VbNvSetup(&c), 0, "VbNvSetup()"); 60b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw[0], 0x70, "VbNvSetup() reset header byte"); 61b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* Close then regenerates the CRC */ 62b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(VbNvTeardown(&c), 0, "VbNvTeardown()"); 63b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_NEQ(c.raw[15], 0, "VbNvTeardown() CRC"); 64b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw_changed, 1, "VbNvTeardown() changed"); 65b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler goodcrc = c.raw[15]; 66b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* Another open-close pair should not cause further changes */ 67b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvSetup(&c); 68b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvTeardown(&c); 69b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw_changed, 0, "VbNvTeardown() didn't change"); 70b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw[15], goodcrc, "VbNvTeardown() CRC same"); 71b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 72b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* Perturbing the header should force defaults */ 73b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler c.raw[0] ^= 0x40; 74b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvSetup(&c); 75b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw[0], 0x70, "VbNvSetup() reset header byte again"); 76b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* Close then regenerates the CRC */ 77b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvTeardown(&c); 78b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw_changed, 1, "VbNvTeardown() changed again"); 79b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw[15], goodcrc, "VbNvTeardown() CRC same again"); 80b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 81b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* So should perturbing some other byte */ 82b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw[11], 0, "Kernel byte starts at 0"); 83b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler c.raw[11] = 12; 84b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvSetup(&c); 85b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw[11], 0, "VbNvSetup() reset kernel byte"); 86b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* Close then regenerates the CRC */ 87b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvTeardown(&c); 88b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw_changed, 1, "VbNvTeardown() changed again"); 89b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw[15], goodcrc, "VbNvTeardown() CRC same again"); 90b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 91b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* Clear the kernel and firmware flags */ 92b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvSetup(&c); 93b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(VbNvGet(&c, VBNV_FIRMWARE_SETTINGS_RESET, &data), 0, 94b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler "Get firmware settings reset"); 95b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(data, 1, "Firmware settings are reset"); 96b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(VbNvSet(&c, VBNV_FIRMWARE_SETTINGS_RESET, 0), 0, 97b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler "Clear firmware settings reset"); 98b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvGet(&c, VBNV_FIRMWARE_SETTINGS_RESET, &data); 99b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(data, 0, "Firmware settings are clear"); 100b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 101b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(VbNvGet(&c, VBNV_KERNEL_SETTINGS_RESET, &data), 0, 102b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler "Get kernel settings reset"); 103b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(data, 1, "Kernel settings are reset"); 104b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(VbNvSet(&c, VBNV_KERNEL_SETTINGS_RESET, 0), 0, 105b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler "Clear kernel settings reset"); 106b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvGet(&c, VBNV_KERNEL_SETTINGS_RESET, &data); 107b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(data, 0, "Kernel settings are clear"); 108b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw[0], 0x40, "Header byte now just has the header bit"); 109b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvTeardown(&c); 110b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* That should have changed the CRC */ 111b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_NEQ(c.raw[15], goodcrc, "VbNvTeardown() CRC changed due to flags clear"); 112b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 1136dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler /* Test explicitly setting the reset flags again */ 1146dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSetup(&c); 1156dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSet(&c, VBNV_FIRMWARE_SETTINGS_RESET, 1); 1166dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvGet(&c, VBNV_FIRMWARE_SETTINGS_RESET, &data); 1176dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler TEST_EQ(data, 1, "Firmware settings forced reset"); 1186dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSet(&c, VBNV_FIRMWARE_SETTINGS_RESET, 0); 1196dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler 1206dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSet(&c, VBNV_KERNEL_SETTINGS_RESET, 1); 1216dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvGet(&c, VBNV_KERNEL_SETTINGS_RESET, &data); 1226dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler TEST_EQ(data, 1, "Kernel settings forced reset"); 1236dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSet(&c, VBNV_KERNEL_SETTINGS_RESET, 0); 1246dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvTeardown(&c); 1256dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler 1266dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler /* Get/set an invalid field */ 1276dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSetup(&c); 1286dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler TEST_EQ(VbNvGet(&c, -1, &data), 1, "Get invalid setting"); 1296dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler TEST_EQ(VbNvSet(&c, -1, 0), 1, "Set invalid setting"); 1306dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvTeardown(&c); 1316dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler 132172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler /* Test other fields */ 133b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvSetup(&c); 1349e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler /* Test all defaults first, since some fields alias onto others */ 135172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler for (vnf = nvfields; vnf->desc; vnf++) { 1369e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler printf("Testing field: %s\n", vnf->desc); 1379e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(VbNvGet(&c, vnf->param, &data), 0, " get"); 1389e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(data, vnf->default_value, " default"); 1399e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler } 1409e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler /* Now test get/set */ 1419e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler for (vnf = nvfields; vnf->desc; vnf++) { 1429e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler printf("Testing field: %s\n", vnf->desc); 1439e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(VbNvSet(&c, vnf->param, vnf->test_value), 0, " set 1"); 1449e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(VbNvGet(&c, vnf->param, &data), 0, " get 1"); 1459e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(data, vnf->test_value, " value 1"); 1469e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler 1479e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(VbNvSet(&c, vnf->param, vnf->test_value2), 0, " set 2"); 1489e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(VbNvGet(&c, vnf->param, &data), 0, " get 2"); 1499e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(data, vnf->test_value2, " value 2"); 150172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler } 151b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvTeardown(&c); 152b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 153b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* None of those changes should have caused a reset to defaults */ 154b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvSetup(&c); 155b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvGet(&c, VBNV_FIRMWARE_SETTINGS_RESET, &data); 156b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(data, 0, "Firmware settings are still clear"); 157b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvGet(&c, VBNV_KERNEL_SETTINGS_RESET, &data); 158b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(data, 0, "Kernel settings are still clear"); 159b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvTeardown(&c); 160b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 161b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler /* Verify writing identical settings doesn't cause the CRC to regenerate */ 162b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvSetup(&c); 163b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.regenerate_crc, 0, "No regen CRC on open"); 164172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler for (vnf = nvfields; vnf->desc; vnf++) 165172602829dc0d79ed65d7ed81225389f090b981fRandall Spangler TEST_EQ(VbNvSet(&c, vnf->param, vnf->test_value2), 0, vnf->desc); 166b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.regenerate_crc, 0, "No regen CRC if data not changed"); 167b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler VbNvTeardown(&c); 168b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler TEST_EQ(c.raw_changed, 0, "No raw change if data not changed"); 1696dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler 1706dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler /* Test out-of-range fields mapping to defaults */ 1716dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSetup(&c); 1726dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSet(&c, VBNV_TRY_B_COUNT, 16); 1736dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvGet(&c, VBNV_TRY_B_COUNT, &data); 1746dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler TEST_EQ(data, 15, "Try b count out of range"); 1759e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler VbNvSetup(&c); 1769e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler VbNvSet(&c, VBNV_FW_TRY_COUNT, 16); 1779e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler VbNvGet(&c, VBNV_FW_TRY_COUNT, &data); 1789e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(data, 15, "Try count out of range"); 1796dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSet(&c, VBNV_RECOVERY_REQUEST, 0x101); 1806dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvGet(&c, VBNV_RECOVERY_REQUEST, &data); 1816dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler TEST_EQ(data, VBNV_RECOVERY_LEGACY, "Recovery request out of range"); 1826dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvSet(&c, VBNV_LOCALIZATION_INDEX, 0x102); 1836dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvGet(&c, VBNV_LOCALIZATION_INDEX, &data); 1846dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler TEST_EQ(data, 0, "Localization index out of range"); 1859e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler VbNvSet(&c, VBNV_FW_RESULT, VBNV_FW_RESULT_UNKNOWN + 100); 1869e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler VbNvGet(&c, VBNV_FW_RESULT, &data); 1879e1da784487fb8cfbe4e76693e07205b66675bdaRandall Spangler TEST_EQ(data, VBNV_FW_RESULT_UNKNOWN, "Firmware result out of range"); 1886dbf9d9160b2927d76017d0f51919e0880f9b2ccRandall Spangler VbNvTeardown(&c); 189b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler} 190b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 191b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 192b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spanglerint main(int argc, char* argv[]) { 193b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler int error_code = 0; 194b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 1959e162cdaa7433dff01d3e47ba3a47cb8b39ff3a1Randall Spangler VbNvStorageTest(); 196b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 1972500185a83b453580f187087fffc6376f19f8ff0Simon Glass if (vboot_api_stub_check_memory()) 1982500185a83b453580f187087fffc6376f19f8ff0Simon Glass error_code = 255; 199b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler if (!gTestSuccess) 200b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler error_code = 255; 201b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler 202b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler return error_code; 203b944534edd3799b3353f73bcb8ee90161d640c2bRandall Spangler} 204