summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/test_util.h3
-rw-r--r--test/crc32.c4
-rw-r--r--test/lightbar.c18
3 files changed, 15 insertions, 10 deletions
diff --git a/include/test_util.h b/include/test_util.h
index c85986b229..b30b663ffb 100644
--- a/include/test_util.h
+++ b/include/test_util.h
@@ -12,6 +12,9 @@
#include "console.h"
#include "stack_trace.h"
+/* This allows tests to be easily commented out in run_test for debugging */
+#define test_static static __attribute__((unused))
+
#define RUN_TEST(n) \
do { \
ccprintf("Running %s...", #n); \
diff --git a/test/crc32.c b/test/crc32.c
index e3f6f8d5c6..986a1c60c3 100644
--- a/test/crc32.c
+++ b/test/crc32.c
@@ -12,7 +12,7 @@
#include "util.h"
// test that static version matches context version
-static int test_static(void)
+static int test_static_version(void)
{
uint32_t crc;
const uint32_t input = 0xdeadbeef;
@@ -67,7 +67,7 @@ void run_test(void)
{
test_reset();
- RUN_TEST(test_static);
+ RUN_TEST(test_static_version);
RUN_TEST(test_8);
RUN_TEST(test_kat0);
diff --git a/test/lightbar.c b/test/lightbar.c
index 8a21c1fc62..d0952c92e8 100644
--- a/test/lightbar.c
+++ b/test/lightbar.c
@@ -11,7 +11,6 @@
#include "timer.h"
#include "util.h"
-
static int get_seq(void)
{
int rv;
@@ -53,7 +52,7 @@ static int set_seq(int s)
return EC_RES_SUCCESS;
}
-static int test_double_oneshots(void)
+test_static int test_double_oneshots(void)
{
/* Start in S0 */
TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS);
@@ -125,7 +124,7 @@ static int test_double_oneshots(void)
return EC_SUCCESS;
}
-static int test_oneshots_norm_msg(void)
+test_static int test_oneshots_norm_msg(void)
{
/* Revert to the next state when interrupted with a normal message. */
enum lightbar_sequence seqs[] = {
@@ -154,7 +153,7 @@ static int test_oneshots_norm_msg(void)
return EC_SUCCESS;
}
-static int test_stop_timeout(void)
+test_static int test_stop_timeout(void)
{
int i;
@@ -188,7 +187,7 @@ static int test_stop_timeout(void)
return EC_SUCCESS;
}
-static int test_oneshots_timeout(void)
+test_static int test_oneshots_timeout(void)
{
/* These should revert to the previous state after running */
enum lightbar_sequence seqs[] = {
@@ -215,7 +214,7 @@ static int test_oneshots_timeout(void)
return EC_SUCCESS;
}
-static int test_transition_states(void)
+test_static int test_transition_states(void)
{
/* S5S3 */
TEST_ASSERT(set_seq(LIGHTBAR_S5S3) == EC_RES_SUCCESS);
@@ -240,7 +239,7 @@ static int test_transition_states(void)
return EC_SUCCESS;
}
-static int test_stable_states(void)
+test_static int test_stable_states(void)
{
int i;
@@ -301,7 +300,7 @@ int lid_is_open(void)
return 1;
}
-static int test_als_lightbar(void)
+test_static int test_als_lightbar(void)
{
int lux_data[] = { 500, 100, 35, 15, 30, 35, 55, 70, 55, 100 };
int exp_gcid[] = { 0, 0, 1, 2, 2, 2, 1, 0, 0, 0 };
@@ -322,6 +321,9 @@ static int test_als_lightbar(void)
void run_test(void)
{
+ /* Ensure tasks are started before running tests */
+ usleep(SECOND);
+
RUN_TEST(test_stable_states);
RUN_TEST(test_transition_states);
RUN_TEST(test_oneshots_timeout);