summaryrefslogtreecommitdiff
path: root/cts
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-06-22 14:36:24 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-06-27 15:52:06 -0700
commita82421df00ac1834d0dc8a93f788c323b1bf1977 (patch)
tree3ce0268be0e05e9b53a6afe5565bbf3cf6e8a06d /cts
parent4c23fa01df623438e7d2bfe51dec6eac4f7d9ff2 (diff)
downloadchrome-ec-a82421df00ac1834d0dc8a93f788c323b1bf1977.tar.gz
eCTS: Print start marker before sync
This patch makes each test print start marker before sync. This will allow us to distinguish the failure before even sync is attempted (CTS_RC_DID_NOT_START, thus probably caused by the previous test) and the failure caused by the hanging partner, in which case the one good and alive will be stuck in sync (and should return _DID_NOT_END or even better _BAD_SYNC once we implement timeout in sync). This patch also: * Adds did_not_start_test to and removes debug_test from meta suite * Consolidates test runner loops into common cts_main_loop * Removes dut_common.h and th_common.h * Removes debug print macro and CTS_DEBUG * Replaces all infinite loops after tests with task_wait_event(-1) * Removes meaningless comments and debug printfs * Removes CTS_TEST_ID_* * Adds sync() to task suite BUG=chromium:736104 BRANCH=none TEST=Run run_ects.sh and verify all tests pass Change-Id: I6ccdf26afac6b8e8cb16483c5d75e4e77e7962f4 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/545176
Diffstat (limited to 'cts')
-rw-r--r--cts/build.mk2
-rw-r--r--cts/common/cts_common.c31
-rw-r--r--cts/common/cts_common.h48
-rw-r--r--cts/common/cts_testlist.h30
-rw-r--r--cts/common/dut_common.c8
-rw-r--r--cts/common/dut_common.h13
-rw-r--r--cts/common/th_common.c1
-rw-r--r--cts/common/th_common.h13
-rw-r--r--cts/gpio/cts.testlist2
-rw-r--r--cts/gpio/dut.c22
-rw-r--r--cts/gpio/th.c22
-rw-r--r--cts/hook/dut.c22
-rw-r--r--cts/i2c/dut.c19
-rw-r--r--cts/i2c/th.c24
-rw-r--r--cts/interrupt/dut.c28
-rw-r--r--cts/interrupt/th.c32
-rw-r--r--cts/meta/cts.testlist54
-rw-r--r--cts/meta/dut.c36
-rw-r--r--cts/meta/th.c47
-rw-r--r--cts/task/dut.c19
-rw-r--r--cts/timer/dut.c25
-rw-r--r--cts/timer/th.c22
22 files changed, 169 insertions, 351 deletions
diff --git a/cts/build.mk b/cts/build.mk
index 63b51c6fbf..ddbcb1e95f 100644
--- a/cts/build.mk
+++ b/cts/build.mk
@@ -17,6 +17,8 @@ CONFIG_I2C_MASTER=y
endif
endif
+cts-y+=common/cts_common.o
+
ifeq ($(BOARD),stm32l476g-eval)
cts-y+=$(CTS_MODULE)/th.o
cts-y+=common/th_common.o
diff --git a/cts/common/cts_common.c b/cts/common/cts_common.c
new file mode 100644
index 0000000000..8975636655
--- /dev/null
+++ b/cts/common/cts_common.c
@@ -0,0 +1,31 @@
+/* Copyright 2017 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 "console.h"
+#include "cts_common.h"
+
+__attribute__((weak)) void clean_state(void)
+{
+ /* Each test overrides as needed */
+}
+
+void cts_main_loop(const struct cts_test* tests, const char *name)
+{
+ enum cts_rc rc;
+ int i;
+
+ cflush();
+ for (i = 0; i < cts_test_count; i++) {
+ CPRINTF("\n%s start\n", tests[i].name);
+ cflush();
+ clean_state();
+ sync();
+ rc = tests[i].run();
+ CPRINTF("\n%s end %d\n", tests[i].name, rc);
+ cflush();
+ }
+
+ CPRINTS("%s test suite finished", name);
+}
diff --git a/cts/common/cts_common.h b/cts/common/cts_common.h
index 3c24b815e7..13a435e655 100644
--- a/cts/common/cts_common.h
+++ b/cts/common/cts_common.h
@@ -15,29 +15,41 @@
#define CPRINTL(format, args...) CPRINTS("%s:%d: "format, \
__func__, __LINE__, ## args)
-#ifdef CTS_DEBUG
-/* These debug tags should not be changed */
-#define CTS_DEBUG_START "\n[DEBUG]\n"
-#define CTS_DEBUG_END "\n[DEBUG_END]\n"
-
-#define CTS_DEBUG_PRINTF(format, args...) \
- do { \
- CPRINTF(CTS_DEBUG_START format CTS_DEBUG_END, ## args); \
- cflush(); \
- } while (0)
-#else
-#define CTS_DEBUG_PRINTF(format, args...)
-#endif
-
#define READ_WAIT_TIME_MS 100
#define CTS_INTERRUPT_TRIGGER_DELAY_US (250 * MSEC)
-/* In a single test, only one board can return unknown, the other must
- * return a useful result (i.e. success, failure, etc)
- */
-
enum cts_rc {
#include "cts.rc"
};
+struct cts_test {
+ enum cts_rc (*run)(void);
+ char *name;
+};
+
+extern const int cts_test_count;
+
+/**
+ * Main loop where each test in a suite is executed
+ *
+ * A test suite can implement its custom loop as needed.
+ *
+ * Args:
+ * @test: List of tests to run
+ * @name: Name of the test to be printed on EC console
+ */
+void cts_main_loop(const struct cts_test* tests, const char *name);
+
+/**
+ * Callback function called at the beginning of the main loop
+ */
+void clean_state(void);
+
+/**
+ * Synchronize DUT and TH
+ *
+ * @return CTS_RC_SUCCESS if sync is successful
+ */
+enum cts_rc sync(void);
+
#endif
diff --git a/cts/common/cts_testlist.h b/cts/common/cts_testlist.h
index 9e18c7f8eb..1586c1348e 100644
--- a/cts/common/cts_testlist.h
+++ b/cts/common/cts_testlist.h
@@ -3,26 +3,28 @@
* found in the LICENSE file.
*/
+#include "util.h"
+
/*
- * CTS_TEST macro is used by dut.c, th.c, and cts.py. Currently, the 2nd
- * and 3rd arguments are only used by cts.py. They specify the expected
- * strings output by TH and DUT, respectively.
+ * CTS_TEST macro takes the following arguments:
+ *
+ * @test: Function running the test
+ * @th_rc: Expected CTS_RC_* from TH
+ * @th_string: Expected string printed by TH
+ * @dut_rc: Expected CTR_RC_* from DUT
+ * @dut_string: Expected string printed by DUT
+ *
+ * CTS_TEST macro is processed in multiple places. One is here for creating
+ * an array of test functions. Only @test is used.
+ *
+ * Another is in cts.py for evaluating the test results against expectations.
*/
-struct cts_test {
- enum cts_rc (*run)(void);
- char *name;
-};
-
+#undef CTS_TEST
#define CTS_TEST(test, th_rc, th_string, dut_rc, dut_string) \
{test, STRINGIFY(test)},
struct cts_test tests[] = {
#include "cts.testlist"
};
-#undef CTS_TEST
-#define CTS_TEST(test, th_rc, th_string, dut_rc, dut_string) CTS_TEST_ID_##test,
-enum {
-#include "cts.testlist"
- CTS_TEST_ID_COUNT,
-};
+const int cts_test_count = ARRAY_SIZE(tests);
diff --git a/cts/common/dut_common.c b/cts/common/dut_common.c
index 23315f970f..6e62a280e2 100644
--- a/cts/common/dut_common.c
+++ b/cts/common/dut_common.c
@@ -3,15 +3,10 @@
* found in the LICENSE file.
*/
+#include "cts_common.h"
#include "gpio.h"
-#include "timer.h"
#include "watchdog.h"
-#include "cts_common.h"
-#include "dut_common.h"
-/* Returns unknown because TH could potentially still get stuck
- * even if the DUT completes the sync
- */
enum cts_rc sync(void)
{
int input_level;
@@ -30,3 +25,4 @@ enum cts_rc sync(void)
return CTS_RC_SUCCESS;
}
+
diff --git a/cts/common/dut_common.h b/cts/common/dut_common.h
deleted file mode 100644
index f812631633..0000000000
--- a/cts/common/dut_common.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Copyright 2016 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.
- */
-
-#ifndef __DUT_COMMON_H
-#define __DUT_COMMON_H
-
-#include "cts_common.h"
-
-enum cts_rc sync(void);
-
-#endif
diff --git a/cts/common/th_common.c b/cts/common/th_common.c
index bcab367658..1d692b7843 100644
--- a/cts/common/th_common.c
+++ b/cts/common/th_common.c
@@ -7,7 +7,6 @@
#include "timer.h"
#include "watchdog.h"
#include "cts_common.h"
-#include "th_common.h"
/* Return SUCCESS if and only if we reach end of function
* Returning success here means sync was successful
diff --git a/cts/common/th_common.h b/cts/common/th_common.h
deleted file mode 100644
index 339375c78c..0000000000
--- a/cts/common/th_common.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Copyright 2016 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.
- */
-
-#ifndef __TH_COMMON_H
-#define __TH_COMMON_H
-
-#include "cts_common.h"
-
-enum cts_rc sync(void);
-
-#endif
diff --git a/cts/gpio/cts.testlist b/cts/gpio/cts.testlist
index be303067a3..113d2b405f 100644
--- a/cts/gpio/cts.testlist
+++ b/cts/gpio/cts.testlist
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-/* Currently tests will execute in the order they are listed here */
-
/* Test whether sync completes successfully */
CTS_TEST(sync_test,,,,)
diff --git a/cts/gpio/dut.c b/cts/gpio/dut.c
index c5b6bf813f..828996db8e 100644
--- a/cts/gpio/dut.c
+++ b/cts/gpio/dut.c
@@ -6,9 +6,9 @@
#include "common.h"
#include "watchdog.h"
#include "uart.h"
+#include "task.h"
#include "timer.h"
#include "watchdog.h"
-#include "dut_common.h"
#include "cts_common.h"
enum cts_rc sync_test(void)
@@ -75,22 +75,6 @@ enum cts_rc od_read_high_test(void)
void cts_task(void)
{
- enum cts_rc result;
- int i;
-
- uart_flush_output();
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- result = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, result);
- uart_flush_output();
- }
-
- CPRINTS("GPIO test suite finished");
- uart_flush_output();
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "GPIO");
+ task_wait_event(-1);
}
diff --git a/cts/gpio/th.c b/cts/gpio/th.c
index d18c1c367a..6c628b0ad5 100644
--- a/cts/gpio/th.c
+++ b/cts/gpio/th.c
@@ -6,9 +6,9 @@
#include "common.h"
#include "watchdog.h"
#include "uart.h"
+#include "task.h"
#include "timer.h"
#include "watchdog.h"
-#include "dut_common.h"
#include "cts_common.h"
enum cts_rc sync_test(void)
@@ -69,22 +69,6 @@ enum cts_rc od_read_high_test(void)
void cts_task(void)
{
- enum cts_rc result;
- int i;
-
- uart_flush_output();
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- result = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, result);
- uart_flush_output();
- }
-
- CPRINTS("GPIO test suite finished");
- uart_flush_output();
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "GPIO");
+ task_wait_event(-1);
}
diff --git a/cts/hook/dut.c b/cts/hook/dut.c
index 8be9121128..17f7c90506 100644
--- a/cts/hook/dut.c
+++ b/cts/hook/dut.c
@@ -8,8 +8,8 @@
#include "common.h"
#include "console.h"
#include "cts_common.h"
-#include "dut_common.h"
#include "hooks.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
#include "watchdog.h"
@@ -160,22 +160,6 @@ static enum cts_rc test_deferred(void)
void cts_task(void)
{
- enum cts_rc result;
- int i;
-
- cflush();
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- result = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, result);
- cflush();
- }
-
- CPRINTS("Hook test finished");
- cflush();
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "Hook");
+ task_wait_event(-1);
}
diff --git a/cts/i2c/dut.c b/cts/i2c/dut.c
index b629475ffa..98805a4fc2 100644
--- a/cts/i2c/dut.c
+++ b/cts/i2c/dut.c
@@ -6,9 +6,9 @@
#include "common.h"
#include "cts_common.h"
#include "cts_i2c.h"
-#include "dut_common.h"
#include "i2c.h"
#include "registers.h"
+#include "task.h"
#include "timer.h"
#include "uart.h"
#include "watchdog.h"
@@ -86,19 +86,6 @@ enum cts_rc read32_test(void)
void cts_task(void)
{
- int i;
-
- cflush();
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- sync();
- CPRINTF("\n%s %d\n", tests[i].name, tests[i].run());
- uart_flush_output();
- }
-
- CPRINTS("I2C test suite finished");
- uart_flush_output();
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "I2C");
+ task_wait_event(-1);
}
diff --git a/cts/i2c/th.c b/cts/i2c/th.c
index 86c3a2c8de..17ed64b9f5 100644
--- a/cts/i2c/th.c
+++ b/cts/i2c/th.c
@@ -7,9 +7,9 @@
#include "common.h"
#include "cts_common.h"
#include "cts_i2c.h"
-#include "dut_common.h"
#include "i2c.h"
#include "registers.h"
+#include "task.h"
#include "timer.h"
#include "uart.h"
#include "watchdog.h"
@@ -61,7 +61,7 @@ static int wait_for_in_flag(uint32_t timeout_ms)
return 1;
}
-static void clear_inbox(void)
+void clean_state(void)
{
memset(inbox, 0, sizeof(inbox));
data_received = 0;
@@ -146,22 +146,6 @@ enum cts_rc read32_test(void)
void cts_task(void)
{
- enum cts_rc result;
- int i;
-
- cflush();
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- clear_inbox();
- sync();
- result = tests[i].run();
- CPRINTF("\n%s %d\n", tests[i].name, result);
- uart_flush_output();
- }
-
- CPRINTS("I2C test suite finished");
- uart_flush_output();
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "I2C");
+ task_wait_event(-1);
}
diff --git a/cts/interrupt/dut.c b/cts/interrupt/dut.c
index 35b47001ca..3c83e5701f 100644
--- a/cts/interrupt/dut.c
+++ b/cts/interrupt/dut.c
@@ -5,10 +5,10 @@
#include <string.h>
#include "common.h"
+#include "cts_common.h"
#include "gpio.h"
#include "registers.h"
#include "task.h"
-#include "dut_common.h"
#include "timer.h"
#include "watchdog.h"
@@ -64,10 +64,11 @@ void cts_irq2(enum gpio_signal signal)
state[state_index++] = 'D';
}
-static void clear_state(void)
+void clean_state(void)
{
uint32_t *event;
+ interrupt_enable();
got_interrupt = 0;
wake_me_up = 0;
state_index = 0;
@@ -176,27 +177,8 @@ enum cts_rc test_nested_interrupt_high_low(void)
void cts_task(void)
{
- enum cts_rc rc;
- int i;
-
gpio_enable_interrupt(GPIO_CTS_IRQ1);
gpio_enable_interrupt(GPIO_CTS_IRQ2);
- interrupt_enable();
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- clear_state();
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- rc = tests[i].run();
- interrupt_enable();
- CPRINTF("\n%s end %d\n", tests[i].name, rc);
- cflush();
- }
-
- CPRINTS("Interrupt test suite finished");
- cflush();
-
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "Interrupt");
+ task_wait_event(-1);
}
diff --git a/cts/interrupt/th.c b/cts/interrupt/th.c
index b409fbd8ef..1639a1868c 100644
--- a/cts/interrupt/th.c
+++ b/cts/interrupt/th.c
@@ -4,11 +4,18 @@
*/
#include "common.h"
-#include "th_common.h"
+#include "cts_common.h"
#include "gpio.h"
+#include "task.h"
#include "timer.h"
#include "watchdog.h"
+void clean_state(void)
+{
+ gpio_set_level(GPIO_OUTPUT_TEST, 1);
+ gpio_set_level(GPIO_CTS_IRQ2, 1);
+}
+
static void trigger_interrupt1(void)
{
usleep(CTS_INTERRUPT_TRIGGER_DELAY_US);
@@ -65,26 +72,7 @@ enum cts_rc test_nested_interrupt_high_low(void)
void cts_task(void)
{
- enum cts_rc rc;
- int i;
-
gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_HIGH);
-
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- gpio_set_level(GPIO_OUTPUT_TEST, 1);
- gpio_set_level(GPIO_CTS_IRQ2, 1);
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- rc = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, rc);
- cflush();
- }
-
- CPRINTS("Interrupt test suite finished");
- cflush();
-
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "Interrupt");
+ task_wait_event(-1);
}
diff --git a/cts/meta/cts.testlist b/cts/meta/cts.testlist
index d453d33e51..443f1b7376 100644
--- a/cts/meta/cts.testlist
+++ b/cts/meta/cts.testlist
@@ -3,50 +3,50 @@
* found in the LICENSE file.
*/
-/* Currently tests will execute in the order they are listed here */
-
-/* Test should succeed show the following debug output:
- * You should see #'s 1-4 on sequential lines:
- * 1
- * 2
- * 3
- * 4
- */
-CTS_TEST(debug_test,,,,)
-
-/* Test should succeed if both report success
- * (expected result: success)
+/*
+ * Test SUCCESS from both TH and DUT
*/
CTS_TEST(success_test,,,,)
-/* Test should fail if one reports success and
- * (one reports failure (expected result: failure)
+/*
+ * Test FAILURE from DUT
*/
CTS_TEST(fail_dut_test,,, CTS_RC_FAILURE,)
-/* Test should fail if one reports success and
- * (one reports failure (expected result: failure)
+/*
+ * Test FAILURE from TH
*/
CTS_TEST(fail_th_test, CTS_RC_FAILURE,,,)
-/* Test should fail when both boards report failure
- * (expected result: failure)
+/*
+ * Test failure from both TH and DUT.
*/
CTS_TEST(fail_both_test, CTS_RC_FAILURE,, CTS_RC_FAILURE,)
-/* Test should fail with bad sync if one reports bad
- * sync and the other reports success (expected result:
- * bad_sync)
+/*
+ * Test bad sync for TH
*/
CTS_TEST(bad_sync_and_success_test, CTS_RC_BAD_SYNC,,,)
-/* Test should fail with bad sync if both boards report
- * bad sync (expected result: bad_sync)
+/*
+ * Test should fail with bad sync.
*/
CTS_TEST(bad_sync_both_test, CTS_RC_BAD_SYNC,, CTS_RC_BAD_SYNC,)
-/* Test should be listed as corrupted if one test hangs,
- * regardless of what the other test outputs
- * (expected result: corrupted)
+/*
+ * Test hang on DUT
*/
CTS_TEST(hang_test, CTS_RC_SUCCESS,, CTS_RC_DID_NOT_END,)
+
+/*
+ * Test CTS_RC_DID_NOT_START
+ *
+ * Since the previous test hung on DUT, this test won't run on DUT.
+ * TH will wait forever in sync(), thus won't end.
+ */
+ CTS_TEST(did_not_start_test, CTS_RC_DID_NOT_END,, CTS_RC_DID_NOT_START,)
+
+/*
+ * TODO: Add test for expected string
+ * TODO: Make sync() return CTS_RC_BAD_SYNC when it times out.
+ */ \ No newline at end of file
diff --git a/cts/meta/dut.c b/cts/meta/dut.c
index b80628449b..c8264ab868 100644
--- a/cts/meta/dut.c
+++ b/cts/meta/dut.c
@@ -4,16 +4,11 @@
*/
#include "common.h"
-#include "uart.h"
+#include "cts_common.h"
+#include "task.h"
#include "timer.h"
+#include "uart.h"
#include "watchdog.h"
-#include "dut_common.h"
-#include "cts_common.h"
-
-enum cts_rc debug_test(void)
-{
- return CTS_RC_SUCCESS;
-}
enum cts_rc success_test(void)
{
@@ -55,26 +50,15 @@ enum cts_rc hang_test(void)
return CTS_RC_SUCCESS;
}
+enum cts_rc did_not_start_test(void)
+{
+ return CTS_RC_SUCCESS;
+}
+
#include "cts_testlist.h"
void cts_task(void)
{
- enum cts_rc result;
- int i;
-
- cflush();
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- result = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, result);
- cflush();
- }
-
- CPRINTS("Meta test finished");
- cflush();
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "Meta");
+ task_wait_event(-1);
}
diff --git a/cts/meta/th.c b/cts/meta/th.c
index c1331ff2a7..8564377b7f 100644
--- a/cts/meta/th.c
+++ b/cts/meta/th.c
@@ -4,60 +4,49 @@
*/
#include "common.h"
-#include "uart.h"
+#include "cts_common.h"
+#include "task.h"
#include "timer.h"
+#include "uart.h"
#include "watchdog.h"
-#include "dut_common.h"
-#include "cts_common.h"
-
-enum cts_rc debug_test(void)
-{
- CTS_DEBUG_PRINTF("You should see #'s 1-4 on sequential lines:");
- CTS_DEBUG_PRINTF("1");
- CTS_DEBUG_PRINTF("2\n3");
- CTS_DEBUG_PRINTF("4");
- return CTS_RC_SUCCESS;
-}
enum cts_rc success_test(void)
{
- CTS_DEBUG_PRINTF("Expect: Success");
return CTS_RC_SUCCESS;
}
enum cts_rc fail_dut_test(void)
{
- CTS_DEBUG_PRINTF("Expect: Failure");
return CTS_RC_SUCCESS;
}
enum cts_rc fail_th_test(void)
{
- CTS_DEBUG_PRINTF("Expect: Failure");
return CTS_RC_FAILURE;
}
enum cts_rc fail_both_test(void)
{
- CTS_DEBUG_PRINTF("Expect: Failure");
return CTS_RC_FAILURE;
}
enum cts_rc bad_sync_and_success_test(void)
{
- CTS_DEBUG_PRINTF("Expect: Bad Sync");
return CTS_RC_BAD_SYNC;
}
enum cts_rc bad_sync_both_test(void)
{
- CTS_DEBUG_PRINTF("Expect: Bad Sync");
return CTS_RC_BAD_SYNC;
}
enum cts_rc hang_test(void)
{
- CTS_DEBUG_PRINTF("This and next, expect: Corrupted");
+ return CTS_RC_SUCCESS;
+}
+
+enum cts_rc did_not_start_test(void)
+{
return CTS_RC_SUCCESS;
}
@@ -65,22 +54,6 @@ enum cts_rc hang_test(void)
void cts_task(void)
{
- enum cts_rc result;
- int i;
-
- cflush();
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- result = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, result);
- cflush();
- }
-
- CPRINTS("Meta test finished");
- cflush();
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "Meta");
+ task_wait_event(-1);
}
diff --git a/cts/task/dut.c b/cts/task/dut.c
index 4cc6e3e4a4..0ca39df926 100644
--- a/cts/task/dut.c
+++ b/cts/task/dut.c
@@ -13,7 +13,7 @@
static int repeat_count;
static int wake_count[3];
-void clear_state(void)
+void clean_state(void)
{
wake_count[0] = wake_count[1] = wake_count[2] = 0;
}
@@ -135,22 +135,7 @@ enum cts_rc test_stack_overflow(void)
void cts_task(void)
{
- enum cts_rc rc;
- int i;
-
task_wake(TASK_ID_TICK);
-
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- clear_state();
- CPRINTF("\n%s start\n", tests[i].name);
- rc = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, rc);
- cflush();
- }
-
- CPRINTS("Task test suite finished");
- cflush();
-
- /* Sleep forever */
+ cts_main_loop(tests, "Task");
task_wait_event(-1);
}
diff --git a/cts/timer/dut.c b/cts/timer/dut.c
index 4089964791..96d7c5a3cf 100644
--- a/cts/timer/dut.c
+++ b/cts/timer/dut.c
@@ -4,8 +4,9 @@
*/
#include "common.h"
-#include "dut_common.h"
+#include "cts_common.h"
#include "gpio.h"
+#include "task.h"
#include "timer.h"
#include "watchdog.h"
@@ -14,7 +15,7 @@ static enum cts_rc timer_calibration_test(void)
gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_HIGH);
sync();
- usleep(SECOND);
+ sleep(1);
gpio_set_level(GPIO_OUTPUT_TEST, 0);
return CTS_RC_SUCCESS;
@@ -24,22 +25,6 @@ static enum cts_rc timer_calibration_test(void)
void cts_task(void)
{
- enum cts_rc rc;
- int i;
-
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- rc = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, rc);
- cflush();
- }
-
- CPRINTS("Timer test suite finished");
- cflush();
-
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "Timer");
+ task_wait_event(-1);
}
diff --git a/cts/timer/th.c b/cts/timer/th.c
index 4c9912fdda..e82cac71ab 100644
--- a/cts/timer/th.c
+++ b/cts/timer/th.c
@@ -4,10 +4,10 @@
*/
#include "common.h"
+#include "cts_common.h"
#include "gpio.h"
#include "registers.h"
#include "task.h"
-#include "th_common.h"
#include "timer.h"
#include "watchdog.h"
@@ -57,22 +57,6 @@ static enum cts_rc timer_calibration_test(void)
void cts_task(void)
{
- enum cts_rc rc;
- int i;
-
- for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
- sync();
- CPRINTF("\n%s start\n", tests[i].name);
- rc = tests[i].run();
- CPRINTF("\n%s end %d\n", tests[i].name, rc);
- cflush();
- }
-
- CPRINTS("Timer test suite finished");
- cflush();
-
- while (1) {
- watchdog_reload();
- sleep(1);
- }
+ cts_main_loop(tests, "Timer");
+ task_wait_event(-1);
}