From 5488976a20d1036ba425b4061e435a53a022f876 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Tue, 18 Oct 2016 09:27:34 -0700 Subject: eCTS: Add nested interrupt test (High->Low) Add a nested interrupt test to eCTS. Higher priority IRQ is fired, followed by lower priority IRQ. Handlers should be executed sequentially. P1 *-----* / \ P2 / *-----* / \ task_cts ----* *---- B C A D BUG=chromium:653195 BRANCH=none TEST=cts.py -m interrupt; make buildall Change-Id: Ia9f1bf4205cefe8bdc11cc0aa3ad2057359b73ef Signed-off-by: Daisuke Nojiri Reviewed-on: https://chromium-review.googlesource.com/409611 Reviewed-by: Randall Spangler --- cts/cts.py | 2 +- cts/interrupt/cts.testlist | 12 ++++++++++++ cts/interrupt/dut.c | 29 +++++++++++++++++++++++++---- cts/interrupt/th.c | 7 +++++++ 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/cts/cts.py b/cts/cts.py index b42f16c44b..82955436c7 100755 --- a/cts/cts.py +++ b/cts/cts.py @@ -33,7 +33,7 @@ CTS_COLOR_RED = '#fb7d7d' CTS_COLOR_GREEN = '#7dfb9f' DEFAULT_TH = 'stm32l476g-eval' DEFAULT_DUT = 'nucleo-f072rb' -MAX_SUITE_TIME_SEC = 3 +MAX_SUITE_TIME_SEC = 5 CTS_DEBUG_START = '[DEBUG]' CTS_DEBUG_END = '[DEBUG_END]' CTS_TEST_RESULT_DIR = '/tmp/cts' diff --git a/cts/interrupt/cts.testlist b/cts/interrupt/cts.testlist index 01d6c1b06e..6e0265ed60 100644 --- a/cts/interrupt/cts.testlist +++ b/cts/interrupt/cts.testlist @@ -25,6 +25,18 @@ CTS_TEST(test_task_disable_irq) */ CTS_TEST(test_nested_interrupt_low_high) +/* Test nested interrupt. Higher priority IRQ is fired, followed by + * lower priority IRQ. Handlers should be executed sequentially. + * + * P1 *-----* + * / \ + * P2 / *-----* + * / \ + * task_cts ----* *---- + * B C A D + */ +CTS_TEST(test_nested_interrupt_high_low) + /* * Other ideas * diff --git a/cts/interrupt/dut.c b/cts/interrupt/dut.c index 9bf7eabde6..a04d5659d5 100644 --- a/cts/interrupt/dut.c +++ b/cts/interrupt/dut.c @@ -45,12 +45,15 @@ static int busy_loop(void) void cts_irq1(enum gpio_signal signal) { state[state_index++] = 'B'; - /* test some APIs */ + got_interrupt = in_interrupt_context(); /* Wake up the CTS task */ if (wake_me_up) task_wake(TASK_ID_CTS); + + busy_loop(); + state[state_index++] = 'C'; } @@ -82,7 +85,7 @@ enum cts_rc test_task_wait_event(void) /* Sleep and wait for interrupt. This shouldn't time out. */ event = task_wait_event(CTS_INTERRUPT_TRIGGER_DELAY_US * 2); if (event != TASK_EVENT_WAKE) { - CPRINTS("Woke up by 0x%08x", event); + CPRINTS("Woken up by unexpected event: 0x%08x", event); return CTS_RC_FAILURE; } if (!got_interrupt) { @@ -103,7 +106,7 @@ enum cts_rc test_task_disable_irq(void) /* Sleep and wait for interrupt. This should time out. */ event = task_wait_event(CTS_INTERRUPT_TRIGGER_DELAY_US * 2); if (event != TASK_EVENT_TIMER) { - CPRINTS("Woke up by 0x%08x", event); + CPRINTS("Woken up by unexpected event: 0x%08x", event); return CTS_RC_FAILURE; } task_enable_irq(CTS_IRQ_NUMBER); @@ -136,7 +139,7 @@ enum cts_rc test_nested_interrupt_low_high(void) event = task_wait_event(CTS_INTERRUPT_TRIGGER_DELAY_US * 4); if (event != TASK_EVENT_TIMER) { - CPRINTS("Woke up by 0x%08x", event); + CPRINTS("Woken up by unexpected event: 0x%08x", event); return CTS_RC_FAILURE; } if (!got_interrupt) { @@ -151,6 +154,24 @@ enum cts_rc test_nested_interrupt_low_high(void) return CTS_RC_SUCCESS; } +enum cts_rc test_nested_interrupt_high_low(void) +{ + uint32_t event; + + event = task_wait_event(CTS_INTERRUPT_TRIGGER_DELAY_US * 4); + if (event != TASK_EVENT_TIMER) { + CPRINTS("Woken up by unexpected event: 0x%08x", event); + return CTS_RC_FAILURE; + } + + if (memcmp(state, "BCAD", sizeof(state))) { + CPRINTS("State transition differs from expectation"); + return CTS_RC_FAILURE; + } + + return CTS_RC_SUCCESS; +} + #include "cts_testlist.h" void cts_task(void) diff --git a/cts/interrupt/th.c b/cts/interrupt/th.c index 87582490ed..0949faa8b2 100644 --- a/cts/interrupt/th.c +++ b/cts/interrupt/th.c @@ -54,6 +54,13 @@ enum cts_rc test_nested_interrupt_low_high(void) return CTS_RC_SUCCESS; } +enum cts_rc test_nested_interrupt_high_low(void) +{ + trigger_interrupt1(); + trigger_interrupt2(); + return CTS_RC_SUCCESS; +} + #include "cts_testlist.h" void cts_task(void) -- cgit v1.2.1