MCPcopy Create free account
hub / github.com/coreboot/coreboot / efi_test_new_write

Function efi_test_new_write

tests/drivers/efivars.c:157–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157static void efi_test_new_write(void **state)
158{
159 enum cb_err ret;
160 uint8_t buf[16];
161 uint32_t size;
162 int i;
163
164 mock_rdev(true);
165
166 ret = efi_fv_set_option(&flash_rdev_rw, &EficorebootNvDataGuid,
167 name, "is awesome", strlen("is awesome") + 1);
168 assert_int_equal(ret, CB_SUCCESS);
169
170 /* New variable has been written */
171 assert_int_equal(flash_buffer[ALIGN_UP(sizeof(FVH), 4)], 0xaa);
172 assert_int_equal(flash_buffer[ALIGN_UP(sizeof(FVH), 4) + 1], 0x55);
173
174 /* Remaining space is blank */
175 for (i = ALIGN_UP(sizeof(FVH), 4) + 89; i < sizeof(flash_buffer); i++)
176 assert_int_equal(flash_buffer[i], 0xff);
177
178 mock_rdev(false);
179
180 memset(buf, 0, sizeof(buf));
181 size = sizeof(buf);
182 ret = efi_fv_get_option(&flash_rdev_rw, &EficorebootNvDataGuid, name, buf,
183 &size);
184 assert_int_equal(ret, CB_SUCCESS);
185 assert_int_equal(size, strlen("is awesome")+1);
186
187 assert_int_equal(flash_buffer[ALIGN_UP(sizeof(FVH), 4) + 1], 0x55);
188 assert_string_equal((const char *)buf, "is awesome");
189}
190
191int main(void)
192{

Callers

nothing calls this directly

Calls 5

mock_rdevFunction · 0.85
efi_fv_set_optionFunction · 0.85
strlenFunction · 0.85
efi_fv_get_optionFunction · 0.85
memsetFunction · 0.50

Tested by

no test coverage detected