summaryrefslogtreecommitdiffstats
path: root/source/tests
diff options
context:
space:
mode:
Diffstat (limited to 'source/tests')
-rw-r--r--source/tests/basic.c79
-rw-r--r--source/tests/led.c38
2 files changed, 0 insertions, 117 deletions
diff --git a/source/tests/basic.c b/source/tests/basic.c
deleted file mode 100644
index 4f34ba4..0000000
--- a/source/tests/basic.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#define ET_TEST_IMPL
-#include "../test.h"
-#include <inttypes.h>
-#include <stdio.h>
-
-#define TEST_ITERATIONS 16
-
-struct test_with_iterations {
- struct et_test_state_private_base base;
- int iteration;
-};
-
-static int init_test_with_iterations(const struct et_state *state, void *data, et_state_init_data init_data) {
- struct test_with_iterations *priv = data;
- priv->iteration = 0;
- return 0;
-}
-
-static int check_id_tick(const struct et_state *state, void *data, struct et_next_state *next_state) {
- struct test_with_iterations *priv = data;
- struct et_test_plan *test_plan = priv->base.plan;
- struct et_test_plan_entry *cur = test_current(test_plan);
- et_test_status status = TEST_PASS;
- u16 command = 0x9000;
-
- if ((status = test_exi_readwrite(test_plan, &command, sizeof(command), TEST_EPRIV_BASE)) != TEST_PASS) {
- cur->status = status;
- return test_next(test_plan, next_state);
- }
-
- if (command != 0x0470) {
- test_plan_entry_set_error(cur, "bad identifier from gecko: expected 0x0470, got 0x%04" PRIx16, command);
- status = TEST_FAIL;
- }
-
- cur->status = status;
-
- if (status != TEST_PASS || ++priv->iteration >= TEST_ITERATIONS) {
- return test_next(test_plan, next_state);
- }
-
- return 0;
-}
-
-TEST_DEF(check_id, "Identify Gecko (0x09)", TEST_PAUSE_ON_ERROR, init_test_with_iterations, check_id_tick, NULL, struct test_with_iterations);
-
-static int bad_commands_tick(const struct et_state *state, void *data, struct et_next_state *next_state) {
- struct test_with_iterations *priv = data;
- struct et_test_plan *test_plan = priv->base.plan;
- struct et_test_plan_entry *cur = test_current(test_plan);
- et_test_status status = TEST_PASS;
-
- static const u16 bad_commands[] = { 0x0000, 0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0xe000, 0xf000 };
-
- for (int i = 0; i < ARRLEN(bad_commands); ++i) {
- u16 orig_cmd = bad_commands[i];
- u16 cmd = orig_cmd;
- if ((status = test_exi_readwrite(test_plan, &cmd, sizeof(cmd), TEST_EPRIV_BASE)) != TEST_PASS) {
- goto test_fail;
- }
-
- if (cmd != 0x0000) {
- test_plan_entry_set_error(cur, "got bogus response from invalid command 0x%04" PRIx16 ": 0x%04" PRIx16, orig_cmd, cmd);
- status = TEST_FAIL;
- break;
- }
- }
-
-test_fail:
- cur->status = status;
-
- if (status != TEST_PASS || ++priv->iteration >= TEST_ITERATIONS) {
- return test_next(test_plan, next_state);
- }
-
- return 0;
-}
-
-TEST_DEF(bad_commands, "Bad commands", 0, init_test_with_iterations, bad_commands_tick, NULL, struct test_with_iterations);
diff --git a/source/tests/led.c b/source/tests/led.c
deleted file mode 100644
index 82913ae..0000000
--- a/source/tests/led.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#define ET_TEST_IMPL
-#include "../test.h"
-#include <inttypes.h>
-
-static int flash_led_tick(const struct et_state *state, void *data, struct et_next_state *next_state) {
- struct et_test_state_private_base *priv = data;
- struct et_test_plan *plan = priv->plan;
- struct et_test_plan_entry *cur = test_current(plan);
- et_test_status status = TEST_PASS;
-
- for (int i = 0; i < 1024; ++i) {
- u16 cmd_orig, cmd;
-
- if (i & 1) {
- /* LED off */
- cmd_orig = 0x7000;
- } else {
- /* LED on */
- cmd_orig = 0x8000;
- }
-
- cmd = cmd_orig;
- if ((status = test_exi_readwrite(plan, &cmd, sizeof(cmd), TEST_EPRIV_BASE)) != TEST_PASS) {
- break;
- }
-
- if (cmd != 0x0000) {
- status = TEST_FAIL;
- test_plan_entry_set_error(cur, "spurious response to 0x%04" PRIx16 ": 0x%04" PRIx16 " (should be 0x0000)", cmd_orig, cmd);
- break;
- }
- }
-
- cur->status = status;
- return test_next(plan, next_state);
-}
-
-TEST_DEF(flash_led, "Flash LED", 0, NULL, flash_led_tick, NULL, struct et_test_state_private_base);