summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-01-15 23:29:00 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-21 17:49:23 +0000
commited57bea6f742b57d0314feafa7d4ecce24ab8480 (patch)
tree6bc5c2877b935b1cd7d2091d5df43a04b198ea5e /zephyr
parent542725baca37eaf62be58af9da4a447bd4ba0236 (diff)
downloadchrome-ec-ed57bea6f742b57d0314feafa7d4ecce24ab8480.tar.gz
common:test: refactor test_util.h to accommodate Zephyr
This change refactors test functionality in test_util.h to better accomomdate zTests. This is done by: * Removing the shim version of test_util.h. This was causing a conflict that made it harder to tell what's being used. This involved migrating some needed code over: - Defining different TASK_PARAMS. - Defining test_pass for Zephyr tests. * Creating a macro (DECLARE_EC_TEST) that will automatically handle creating the individual test functions for both platform and Zephyr tests. * Creating a macro (TEST_MAIN) that will automatically handle creating the main test entry function. This use to be test_main(void) for Zephyr and run_test(int, char**) for platform/ec. To do this we'll be removing the int, char** arguments from platform/ec. This may result in some tests having to be refactored, but overall should improve the test codebase as tests should remain deterministic (i.e. not depend on any outside arguments/parameters). * Creating some common ztest_ function/macros that will allow writing platform/ec tests in a zephyr like style. see test/base32.c for an example. * Update the type of __shared_mem_buf to match Zephyr. This was causing an issue now with the full test_util.h in zephyr/test/system/. BRANCH=none BUG=b:168032590 TEST=make runhosttests TEST=zmake configure --test -B build/host/base32 zephyr/test/base32 Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I72173a3e94c7df09a2966e7ffeb9f5668d030f29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2634401 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/shim/include/test_util.h34
1 files changed, 0 insertions, 34 deletions
diff --git a/zephyr/shim/include/test_util.h b/zephyr/shim/include/test_util.h
deleted file mode 100644
index cc28bcf697..0000000000
--- a/zephyr/shim/include/test_util.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2020 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.
- */
-
-/* Various utility for unit testing */
-
-#ifndef __CROS_EC_TEST_UTIL_H
-#define __CROS_EC_TEST_UTIL_H
-
-#include <ztest.h>
-#include "ec_tasks.h"
-
-/*
- * We need these macros so that a test can be built for either Ztest or the
- * EC test framework.
- *
- * Ztest unit tests are void and do not return a value. In the EC framework,
- * if none of the assertions fail, the test is supposed to return EC_SUCCESS,
- * so just define that as empty and `return EC_SUCCESS;` will get pre-processed
- * into `return ;`
- */
-#define EC_TEST_RETURN void
-#define EC_SUCCESS
-#define test_pass ztest_test_pass
-
-/* Zephyr threads have three void pointers as parameters */
-#define TASK_PARAMS void *p1, void *p2, void *p3
-
-uint32_t prng(uint32_t seed);
-
-uint32_t prng_no_seed(void);
-
-#endif /* __CROS_EC_TEST_UTIL_H */