xref: /aosp_15_r20/external/vboot_reference/tests/vb2_gbb_init_tests.c (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1 /* Copyright 2022 The ChromiumOS Authors
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  *
5  * Test that vb2_get_gbb aborts if gbb_offset is not initialized. This
6  * is in a separate file from vb2_gbb_tests so that vb2_get_gbb is not
7  * mocked.
8  */
9 
10 #include "2common.h"
11 #include "common/tests.h"
12 
test_abort_if_gbb_uninit(void)13 static void test_abort_if_gbb_uninit(void) {
14 	struct vb2_context *ctx;
15 	uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE]
16 		__attribute__((aligned(VB2_WORKBUF_ALIGN)));
17 	TEST_SUCC(vb2api_init(workbuf, sizeof(workbuf), &ctx),
18 		  "vb2api_init failed");
19 	TEST_ABORT(vb2_get_gbb(ctx), "gbb_offset is not initialized");
20 }
21 
main(int argc,char * argv[])22 int main(int argc, char *argv[])
23 {
24 	test_abort_if_gbb_uninit();
25 	return gTestSuccess ? 0 : 255;
26 }
27