Skip to content

Commit 1739cff

Browse files
committed
feat(irq_tests): add support to run IRQ tests (uart and timer)
Signed-off-by: Diogo Costa <[email protected]>
1 parent 5d136eb commit 1739cff

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

tests/recipes/single-baremetal/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ let
4040
inherit toolchain;
4141
guest_name = "baremetal";
4242
list_tests = "";
43-
list_suites = "CPU_BOOT_CHECK";
43+
list_suites = "CPU_BOOT_CHECK IRQ_CHECK";
4444
inherit log_level;
4545
}
4646
)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include "testf.h"
2+
// #include <plat.h>
3+
// #include <irq.h>
4+
// #include <timer.h>
5+
// #include <uart.h>
6+
// #include <core.h>
7+
#include <core.h>
8+
#include <stdlib.h>
9+
#include <stdio.h>
10+
#include <string.h>
11+
#include <cpu.h>
12+
#include <wfi.h>
13+
#include <spinlock.h>
14+
#include <plat.h>
15+
#include <irq.h>
16+
#include <uart.h>
17+
#include <timer.h>
18+
19+
void test_interrupt_timer_callback();
20+
void uart_rx_handler();
21+
22+
23+
bool irq_en_timer = false;
24+
bool irq_en_uart = false;
25+
26+
#define TIMER_INTERVAL (TIME_MS(100))
27+
#define TEST_TIMEOUT (TIME_S(1))
28+
29+
BAO_TEST(IRQ_CHECK, TIMER)
30+
{
31+
irq_set_handler(TIMER_IRQ_ID, test_interrupt_timer_callback);
32+
irq_enable(TIMER_IRQ_ID);
33+
timer_set(TIMER_INTERVAL);
34+
irq_set_prio(TIMER_IRQ_ID, IRQ_MAX_PRIO);
35+
36+
timer_wait(TEST_TIMEOUT);
37+
38+
EXPECTED_TRUE(irq_en_timer);
39+
}
40+
41+
BAO_TEST(IRQ_CHECK, UART)
42+
{
43+
irq_set_handler(33, uart_rx_handler);
44+
uart_enable_rxirq();
45+
irq_enable(33);
46+
irq_set_prio(33, IRQ_MAX_PRIO);
47+
48+
timer_wait(TEST_TIMEOUT);
49+
EXPECTED_TRUE(irq_en_uart);
50+
}
51+
52+
void test_interrupt_timer_callback()
53+
{
54+
irq_en_timer = true;
55+
timer_set(TIMER_INTERVAL);
56+
}
57+
58+
void uart_rx_handler(){
59+
uart_clear_rxirq();
60+
irq_en_uart = true;
61+
}

0 commit comments

Comments
 (0)