Skip to content

Commit fe2144f

Browse files
committed
ticker tests: optimize RAM usage.
1 parent 4adba7c commit fe2144f

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

TESTS/mbed_hal/ticker/main.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,24 +1570,21 @@ static void test_overflow_event_update_when_spurious_interrupt()
15701570
static void test_irq_handler_single_event()
15711571
{
15721572
const timestamp_t event_timestamp = 0xAAAAAAAA;
1573-
static const timestamp_t interface_timestamp_after_irq = event_timestamp + 100;
1574-
static const uint32_t event_id = 0xFFAAFFAA;
1573+
const timestamp_t interface_timestamp_after_irq = event_timestamp + 100;
15751574

1576-
static uint32_t handler_call = 0;
1575+
uint32_t handler_call = 0;
15771576
struct irq_handler_stub_t {
15781577
static void event_handler(uint32_t id) {
1579-
++handler_call;
1578+
++ (*((uint32_t*) id));
15801579
interface_stub.timestamp = interface_timestamp_after_irq;
1581-
TEST_ASSERT_EQUAL_UINT32(event_id, id);
15821580
}
15831581
};
1584-
handler_call = 0;
15851582

15861583
ticker_set_handler(&ticker_stub, irq_handler_stub_t::event_handler);
15871584
interface_stub.set_interrupt_call = 0;
15881585

15891586
ticker_event_t e;
1590-
ticker_insert_event(&ticker_stub, &e, event_timestamp, event_id);
1587+
ticker_insert_event(&ticker_stub, &e, event_timestamp, (uint32_t) &handler_call);
15911588

15921589
interface_stub.timestamp = event_timestamp;
15931590
interface_stub.set_interrupt_call = 0;
@@ -1635,7 +1632,7 @@ static void test_irq_handler_single_event_spurious()
16351632
TIMESTAMP_MAX_DELTA - 1
16361633
};
16371634

1638-
static ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 };
1635+
ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 };
16391636

16401637
for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) {
16411638
ticker_insert_event_us(
@@ -1739,13 +1736,12 @@ static void test_irq_handler_multiple_event_single_dequeue_overflow()
17391736
10 + TIMESTAMP_MAX_DELTA + 1
17401737
};
17411738

1742-
static size_t handler_called = 0;
1739+
size_t handler_called = 0;
17431740
struct irq_handler_stub_t {
17441741
static void event_handler(uint32_t id) {
1745-
++handler_called;
1742+
++ (*((size_t*) id));
17461743
}
17471744
};
1748-
handler_called = 0;
17491745

17501746
ticker_set_handler(&ticker_stub, irq_handler_stub_t::event_handler);
17511747
interface_stub.set_interrupt_call = 0;
@@ -1755,7 +1751,7 @@ static void test_irq_handler_multiple_event_single_dequeue_overflow()
17551751
for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) {
17561752
ticker_insert_event_us(
17571753
&ticker_stub,
1758-
&events[i], timestamps[i], (uint32_t) &events[i]
1754+
&events[i], timestamps[i], (uint32_t) &handler_called
17591755
);
17601756
}
17611757

@@ -1795,13 +1791,12 @@ static void test_irq_handler_multiple_event_single_dequeue()
17951791
10 + TIMESTAMP_MAX_DELTA - 1
17961792
};
17971793

1798-
static size_t handler_called = 0;
1794+
size_t handler_called = 0;
17991795
struct irq_handler_stub_t {
18001796
static void event_handler(uint32_t id) {
1801-
++handler_called;
1797+
++ (*((size_t*) id));
18021798
}
18031799
};
1804-
handler_called = 0;
18051800

18061801
ticker_set_handler(&ticker_stub, irq_handler_stub_t::event_handler);
18071802
interface_stub.set_interrupt_call = 0;
@@ -1811,7 +1806,7 @@ static void test_irq_handler_multiple_event_single_dequeue()
18111806
for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) {
18121807
ticker_insert_event_us(
18131808
&ticker_stub,
1814-
&events[i], timestamps[i], (uint32_t) &events[i]
1809+
&events[i], timestamps[i], (uint32_t) &handler_called
18151810
);
18161811
}
18171812

@@ -1848,7 +1843,7 @@ static void test_irq_handler_multiple_event_single_dequeue()
18481843
*/
18491844
static void test_irq_handler_insert_immediate_in_irq()
18501845
{
1851-
const us_timestamp_t timestamps [] = {
1846+
static const us_timestamp_t timestamps [] = {
18521847
10,
18531848
10 + TIMESTAMP_MAX_DELTA - 1
18541849
};
@@ -1862,7 +1857,7 @@ static void test_irq_handler_insert_immediate_in_irq()
18621857
size_t handler_called;
18631858
};
18641859

1865-
static ctrl_block_t ctrl_block = { 0 };
1860+
ctrl_block_t ctrl_block = { 0 };
18661861

18671862
struct irq_handler_stub_t {
18681863
static void event_handler(uint32_t id) {
@@ -1924,7 +1919,7 @@ static void test_irq_handler_insert_immediate_in_irq()
19241919
*/
19251920
static void test_irq_handler_insert_non_immediate_in_irq()
19261921
{
1927-
const us_timestamp_t timestamps [] = {
1922+
static const us_timestamp_t timestamps [] = {
19281923
10,
19291924
10 + TIMESTAMP_MAX_DELTA - 1
19301925
};
@@ -1938,7 +1933,7 @@ static void test_irq_handler_insert_non_immediate_in_irq()
19381933
size_t handler_called;
19391934
};
19401935

1941-
static ctrl_block_t ctrl_block = { 0 };
1936+
ctrl_block_t ctrl_block = { 0 };
19421937

19431938
struct irq_handler_stub_t {
19441939
static void event_handler(uint32_t id) {
@@ -2080,9 +2075,8 @@ static utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
20802075
return verbose_test_setup_handler(number_of_cases);
20812076
}
20822077

2083-
static Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
2084-
20852078
int main()
20862079
{
2080+
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
20872081
return !Harness::run(specification);
20882082
}

0 commit comments

Comments
 (0)