diff options
Diffstat (limited to 'tests/vb2_gbb_init_tests.c')
-rw-r--r-- | tests/vb2_gbb_init_tests.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/vb2_gbb_init_tests.c b/tests/vb2_gbb_init_tests.c new file mode 100644 index 00000000..9a3989c0 --- /dev/null +++ b/tests/vb2_gbb_init_tests.c @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Test that vb2_get_gbb aborts if gbb_offset is not initialized. This + * is in a separate file from vb2_gbb_tests so that vb2_get_gbb is not + * mocked. + */ + +#include "2common.h" +#include "common/tests.h" + +static void test_abort_if_gbb_uninit(void) { + struct vb2_context *ctx; + uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE] + __attribute__((aligned(VB2_WORKBUF_ALIGN))); + TEST_SUCC(vb2api_init(workbuf, sizeof(workbuf), &ctx), + "vb2api_init failed"); + TEST_ABORT(vb2_get_gbb(ctx), "gbb_offset is not initialized"); +} + +int main(int argc, char *argv[]) +{ + test_abort_if_gbb_uninit(); + return gTestSuccess ? 0 : 255; +} |