Skip to content

Commit 47684d8

Browse files
committed
Added test config for simulated block devices
Not all devices have enough heap to fit a simulated heap block device, however using a simulated heap block device is preferred if available (reduced flash wear, faster testing). Added MBED_TEST_SIM_BLOCKDEVICE for tests that only need a simulated block device (wear_leveling + resilience), and added support for targets that are known to have enough heap.
1 parent b52575b commit 47684d8

File tree

9 files changed

+79
-15
lines changed

9 files changed

+79
-15
lines changed

features/filesystem/littlefs/TESTS/filesystem_recovery/resilience/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
using namespace utest::v1;
2525

2626
// test configuration
27-
#ifndef MBED_TEST_BLOCKDEVICE
28-
#define MBED_TEST_BLOCKDEVICE HeapBlockDevice
29-
#define MBED_TEST_BLOCKDEVICE_DECL MBED_TEST_BLOCKDEVICE bd(MBED_TEST_BLOCK_COUNT*512, 1, 1, 512)
27+
#ifndef MBED_TEST_SIM_BLOCKDEVICE
28+
#error [NOT_SUPPORTED] Simulation block device required for resilience tests
3029
#endif
3130

32-
#ifndef MBED_TEST_BLOCKDEVICE_DECL
33-
#define MBED_TEST_BLOCKDEVICE_DECL MBED_TEST_BLOCKDEVICE bd
31+
#ifndef MBED_TEST_SIM_BLOCKDEVICE_DECL
32+
#define MBED_TEST_SIM_BLOCKDEVICE_DECL MBED_TEST_SIM_BLOCKDEVICE bd(MBED_TEST_BLOCK_COUNT*512, 1, 1, 512)
3433
#endif
3534

3635
#ifndef MBED_TEST_BLOCK_COUNT
@@ -50,7 +49,7 @@ using namespace utest::v1;
5049
#define STRINGIZE2(x) #x
5150
#define INCLUDE(x) STRINGIZE(x.h)
5251

53-
#include INCLUDE(MBED_TEST_BLOCKDEVICE)
52+
#include INCLUDE(MBED_TEST_SIM_BLOCKDEVICE)
5453

5554

5655
/**
@@ -62,7 +61,7 @@ using namespace utest::v1;
6261
*/
6362
void test_resilience()
6463
{
65-
MBED_TEST_BLOCKDEVICE_DECL;
64+
MBED_TEST_SIM_BLOCKDEVICE_DECL;
6665

6766
// bring up to get block size
6867
bd.init();

features/filesystem/littlefs/TESTS/filesystem_recovery/wear_leveling/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
using namespace utest::v1;
2626

2727
// test configuration
28-
#ifndef MBED_TEST_BLOCKDEVICE
29-
#define MBED_TEST_BLOCKDEVICE HeapBlockDevice
30-
#define MBED_TEST_BLOCKDEVICE_DECL MBED_TEST_BLOCKDEVICE bd(MBED_TEST_BLOCK_COUNT*512, 1, 1, 512)
28+
#ifndef MBED_TEST_SIM_BLOCKDEVICE
29+
#error [NOT_SUPPORTED] Simulation block device required for wear leveling tests
3130
#endif
3231

33-
#ifndef MBED_TEST_BLOCKDEVICE_DECL
34-
#define MBED_TEST_BLOCKDEVICE_DECL MBED_TEST_BLOCKDEVICE bd
32+
#ifndef MBED_TEST_SIM_BLOCKDEVICE_DECL
33+
#define MBED_TEST_SIM_BLOCKDEVICE_DECL MBED_TEST_SIM_BLOCKDEVICE bd(MBED_TEST_BLOCK_COUNT*512, 1, 1, 512)
3534
#endif
3635

3736
#ifndef MBED_TEST_BLOCK_COUNT
@@ -51,12 +50,12 @@ using namespace utest::v1;
5150
#define STRINGIZE2(x) #x
5251
#define INCLUDE(x) STRINGIZE(x.h)
5352

54-
#include INCLUDE(MBED_TEST_BLOCKDEVICE)
53+
#include INCLUDE(MBED_TEST_SIM_BLOCKDEVICE)
5554

5655

5756
static uint32_t test_wear_leveling_size(uint32_t block_count)
5857
{
59-
MBED_TEST_BLOCKDEVICE_DECL;
58+
MBED_TEST_SIM_BLOCKDEVICE_DECL;
6059

6160
// bring up to get block size
6261
bd.init();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"config": {
3+
"sim-blockdevice": {
4+
"help": "Simulated block device, requires sufficient heap",
5+
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
6+
"value": "HeapBlockDevice"
7+
}
8+
}
9+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"config": {
3+
"header-file": {
4+
"help" : "String for including your driver header file",
5+
"value" : "\"EthernetInterface.h\""
6+
},
7+
"object-construction" : {
8+
"value" : "new EthernetInterface()"
9+
},
10+
"connect-statement" : {
11+
"help" : "Must use 'net' variable name",
12+
"value" : "((EthernetInterface *)net)->connect()"
13+
},
14+
"echo-server-addr" : {
15+
"help" : "IP address of echo server",
16+
"value" : "\"195.34.89.241\""
17+
},
18+
"echo-server-port" : {
19+
"help" : "Port of echo server",
20+
"value" : "7"
21+
},
22+
"tcp-echo-prefix" : {
23+
"help" : "Some servers send a prefix before echoed message",
24+
"value" : "\"u-blox AG TCP/UDP test service\\n\""
25+
},
26+
"sim-blockdevice": {
27+
"help": "Simulated block device, requires sufficient heap",
28+
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
29+
"value": "HeapBlockDevice"
30+
}
31+
}
32+
}

tools/test_configs/OdinInterface.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"tcp-echo-prefix" : {
2323
"help" : "Some servers send a prefix before echoed message",
2424
"value" : "\"u-blox AG TCP/UDP test service\\n\""
25+
},
26+
"sim-blockdevice": {
27+
"help": "Simulated block device, requires sufficient heap",
28+
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
29+
"value": "HeapBlockDevice"
2530
}
2631
}
2732
}

tools/test_configs/Odin_EthernetInterface.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"tcp-echo-prefix" : {
2323
"help" : "Some servers send a prefix before echoed message",
2424
"value" : "\"u-blox AG TCP/UDP test service\\n\""
25+
},
26+
"sim-blockdevice": {
27+
"help": "Simulated block device, requires sufficient heap",
28+
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
29+
"value": "HeapBlockDevice"
2530
}
2631
},
2732
"target_overrides": {

tools/test_configs/RealtekInterface.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"tcp-echo-prefix" : {
2323
"help" : "Some servers send a prefix before echoed message",
2424
"value" : "\"Realtek Ameba TCP/UDP test service\\n\""
25+
},
26+
"sim-blockdevice": {
27+
"help": "Simulated block device, requires sufficient heap",
28+
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
29+
"value": "HeapBlockDevice"
2530
}
2631
}
2732
}

tools/test_configs/config_paths.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"ETHERNET" : "EthernetInterface.json",
3+
"HEAPBLOCKDEVICE": "HeapBlockDevice.json",
4+
"HEAPBLOCKDEVICE_AND_ETHERNET": "HeapBlockDeviceAndEthernetInterface.json",
35
"ODIN_WIFI" : "OdinInterface.json",
46
"ODIN_ETHERNET" : "Odin_EthernetInterface.json",
5-
"REALTEK_WIFI" : "RealtekInterface.json"
7+
"REALTEK_WIFI" : "RealtekInterface.json"
68
}

tools/test_configs/target_configs.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@
66
"REALTEK_RTL8195AM": {
77
"default_test_configuration": "NONE",
88
"test_configurations": ["REALTEK_WIFI"]
9+
},
10+
"K64F": {
11+
"default_test_configuration": "HEAPBLOCKDEVICE_AND_ETHERNET",
12+
"test_configurations": ["HEAPBLOCKDEVICE_AND_ETHERNET"]
13+
},
14+
"NUCLEO_F429ZI": {
15+
"default_test_configuration": "HEAPBLOCKDEVICE_AND_ETHERNET",
16+
"test_configurations": ["HEAPBLOCKDEVICE_AND_ETHERNET"]
917
}
1018
}

0 commit comments

Comments
 (0)