Skip to content

Commit 704c94d

Browse files
committed
bd: Remove constraints on device for block device tests
1 parent 09b3afb commit 704c94d

File tree

1 file changed

+10
-28
lines changed
  • features/TESTS/filesystem/util_block_device

1 file changed

+10
-28
lines changed

features/TESTS/filesystem/util_block_device/main.cpp

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,15 @@
2525

2626
using namespace utest::v1;
2727

28-
/* It is not possible to build a KL25Z image with IAR including the file system if
29-
* stack tracking statistics are enabled. If this is the case, build dummy
30-
* tests.
31-
*/
32-
#if ! defined(TOOLCHAIN_IAR) && ! defined(TARGET_KL25Z) && ! defined(MBED_STACK_STATS_ENABLED)
33-
3428
#define BLOCK_COUNT 16
3529
#define BLOCK_SIZE 512
36-
#define UTIL_BLOCK_DEVICE_TEST_01 test_slicing
37-
#define UTIL_BLOCK_DEVICE_TEST_02 test_chaining
38-
uint8_t write_block[BLOCK_SIZE];
39-
uint8_t read_block[BLOCK_SIZE];
4030

4131

4232
// Simple test which read/writes blocks on a sliced block device
4333
void test_slicing() {
4434
HeapBlockDevice bd(BLOCK_COUNT*BLOCK_SIZE, BLOCK_SIZE);
35+
uint8_t *write_block = new uint8_t[BLOCK_SIZE];
36+
uint8_t *read_block = new uint8_t[BLOCK_SIZE];
4537

4638
// Test with first slice of block device
4739
SlicingBlockDevice slice1(&bd, 0, (BLOCK_COUNT/2)*BLOCK_SIZE);
@@ -123,6 +115,8 @@ void test_slicing() {
123115
TEST_ASSERT_EQUAL(0xff & rand(), read_block[i]);
124116
}
125117

118+
delete[] write_block;
119+
delete[] read_block;
126120
err = slice2.deinit();
127121
TEST_ASSERT_EQUAL(0, err);
128122
}
@@ -131,6 +125,8 @@ void test_slicing() {
131125
void test_chaining() {
132126
HeapBlockDevice bd1((BLOCK_COUNT/2)*BLOCK_SIZE, BLOCK_SIZE);
133127
HeapBlockDevice bd2((BLOCK_COUNT/2)*BLOCK_SIZE, BLOCK_SIZE);
128+
uint8_t *write_block = new uint8_t[BLOCK_SIZE];
129+
uint8_t *read_block = new uint8_t[BLOCK_SIZE];
134130

135131
// Test with chain of block device
136132
BlockDevice *bds[] = {&bd1, &bd2};
@@ -174,26 +170,12 @@ void test_chaining() {
174170
TEST_ASSERT_EQUAL(0xff & rand(), read_block[i]);
175171
}
176172

173+
delete[] write_block;
174+
delete[] read_block;
177175
err = chain.deinit();
178176
TEST_ASSERT_EQUAL(0, err);
179177
}
180178

181-
#else /* ! defined(TOOLCHAIN_IAR) && ! defined(TARGET_KL25Z) && ! defined(MBED_STACK_STATS_ENABLED) */
182-
183-
#define UTIL_BLOCK_DEVICE_TEST_01 util_block_device_test_dummy
184-
#define UTIL_BLOCK_DEVICE_TEST_02 util_block_device_test_dummy
185-
186-
/** @brief util_block_device_test_dummy Dummy test case for testing when KL25Z being built with stack statistics enabled.
187-
*
188-
* @return success always
189-
*/
190-
static control_t util_block_device_test_dummy()
191-
{
192-
printf("Null test\n");
193-
return CaseNext;
194-
}
195-
196-
#endif /* ! defined(TOOLCHAIN_IAR) && ! defined(TARGET_KL25Z) && ! defined(MBED_STACK_STATS_ENABLED) */
197179

198180
// Test setup
199181
utest::v1::status_t test_setup(const size_t number_of_cases) {
@@ -202,8 +184,8 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
202184
}
203185

204186
Case cases[] = {
205-
Case("Testing slicing of a block device", UTIL_BLOCK_DEVICE_TEST_01),
206-
Case("Testing chaining of block devices", UTIL_BLOCK_DEVICE_TEST_02),
187+
Case("Testing slicing of a block device", test_slicing),
188+
Case("Testing chaining of block devices", test_chaining),
207189
};
208190

209191
Specification specification(test_setup, cases);

0 commit comments

Comments
 (0)