diff options
| author | 2026-06-29 03:00:12 -0500 | |
|---|---|---|
| committer | 2026-06-29 03:00:12 -0500 | |
| commit | 6bb84fe005fc151df1a67259242da9c0eaf3fe93 (patch) | |
| tree | 683d6e160bf48fd0c235635be874a8fef697402c /source/tests/basic.c | |
| parent | add new tests (diff) | |
begin work on pc side
Diffstat (limited to 'source/tests/basic.c')
| -rw-r--r-- | source/tests/basic.c | 79 |
1 files changed, 0 insertions, 79 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); |
