/* Copyright 2021 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <zephyr/zephyr.h>
#include <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_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();
}

/* Copyright 2021 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <zephyr/zephyr.h>
#include <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);
}

Fix listing of test cases
zephyr: Fix listing of test cases

Use correct ZTEST API so test cases can be listed

BUG=b:240364238
BRANCH=NONE
TEST=./zephyr.exe -list

Signed-off-by: Al Semjonovs <c3a2ecb550cad1e7d5a943ca6241377f7b43ffc4@google.com>
Change-Id: If3b603ab64421da558228e67a907039a1674ba0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3789128
Reviewed-by: Yuval Peress <50dc11c009bd4d7e9d9d15a383c1743ce5ee82ef@google.com>
