summaryrefslogtreecommitdiff
path: root/zephyr/test/ap_power/src/main.c
blob: d653b51164ff587f41e6a531030194289c99f7bd (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
36
37
38
/* 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.
 */

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

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

bool ap_power_predicate_post_main(const void *state)
{
	return !ap_power_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_test_suites(&state);

	ec_app_main();
	state.ec_app_main_run = true;

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

	/* Check that every suite ran */
	ztest_verify_all_test_suites_ran();
}