diff options
Diffstat (limited to 'source/tests/led.c')
| -rw-r--r-- | source/tests/led.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/tests/led.c b/source/tests/led.c new file mode 100644 index 0000000..82913ae --- /dev/null +++ b/source/tests/led.c @@ -0,0 +1,38 @@ +#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); |
