diff options
author | Raul E Rangel <rrangel@chromium.org> | 2022-08-22 11:45:36 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-22 20:27:58 +0000 |
commit | a658ca22d014dc74fd3d615f9eb379e1b420c418 (patch) | |
tree | 22473bfe715ceeede28849712fad0f80e29cfe40 /test/kb_8042.c | |
parent | ca38c1c4c96a54f5854eccbda573c8e46bda92fc (diff) | |
download | chrome-ec-a658ca22d014dc74fd3d615f9eb379e1b420c418.tar.gz |
8042: Abort test runner if the test gets into a bad state
If we can't propagate an error code, we can't fail a test. The next
best thing we can do is abort the test runner. Since tests have the
ability to leak state, it's possible for an earlier failing test to
break a later test. By aborting we prevent getting flooded with false
failures.
BUG=b:242886255
BRANCH=none
TEST=run unit tests
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: Iebdeadeeaa584a65da5329858aa24abfa6e76b03
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3846284
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'test/kb_8042.c')
-rw-r--r-- | test/kb_8042.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/kb_8042.c b/test/kb_8042.c index 273f36b5d9..967f6bf345 100644 --- a/test/kb_8042.c +++ b/test/kb_8042.c @@ -58,7 +58,8 @@ void lpc_keyboard_put_char(uint8_t chr, int send_irq) if (lpc_keyboard_has_char()) { ccprintf("%s:%s ERROR: output buffer is full!\n", __FILE__, __func__); - return; + /* We can't fail the test, but we can abort!. */ + exit(1); } output_buffer.data = chr; @@ -69,8 +70,11 @@ void lpc_keyboard_put_char(uint8_t chr, int send_irq) void send_aux_data_to_device(uint8_t data) { - if (queue_add_unit(&aux_to_device, &data) == 0) + if (queue_add_unit(&aux_to_device, &data) == 0) { ccprintf("%s: ERROR: aux_to_device queue is full!\n", __FILE__); + /* We can't fail the test, but we can abort!. */ + exit(1); + } } void lpc_aux_put_char(uint8_t chr, int send_irq) @@ -78,7 +82,8 @@ void lpc_aux_put_char(uint8_t chr, int send_irq) if (lpc_keyboard_has_char()) { ccprintf("%s:%s ERROR: output buffer is full!\n", __FILE__, __func__); - return; + /* We can't fail the test, but we can abort!. */ + exit(1); } output_buffer.data = chr; @@ -261,9 +266,12 @@ void before_test(void) void after_test(void) { - if (output_buffer.full) + if (output_buffer.full) { ccprintf("%s:%s ERROR: output buffer is not empty!\n", __FILE__, __func__); + /* We can't fail the test, but we can abort!. */ + exit(1); + } } static int test_8042_aux_loopback(void) |