summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/common/src/main.c
blob: 978c699d247a707cfe3a6199c22e9e58624a3de9 (plain)
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
27
28
29
30
31
32
33
34
35
/* Copyright 2021 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
#include "ec_app_main.h"
#include "test/drivers/test_state.h"

bool drivers_predicate_pre_main(const void *state)
{
	return ((struct test_state *)state)->ec_app_main_run == false;
}

bool drivers_predicate_post_main(const void *state)
{
	return !drivers_predicate_pre_main(state);
}

void test_main(void)
{
	struct test_state state = {
		.ec_app_main_run = false,
	};

	/* Run all the suites that depend on main not being called yet */
	ztest_run_all(&state);

	ec_app_main();
	state.ec_app_main_run = true;

	/* Run all the suites that depend on main being called */
	ztest_run_all(&state);
}