File: vb2_gbb_init_tests.c

package info (click to toggle)
vboot-utils 0~R106-15054.B%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,592 kB
  • sloc: ansic: 48,956; sh: 9,637; makefile: 1,006; pascal: 77; python: 61
file content (26 lines) | stat: -rw-r--r-- 775 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}