25
25
26
26
using namespace utest ::v1;
27
27
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
-
34
28
#define BLOCK_COUNT 16
35
29
#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];
40
30
41
31
42
32
// Simple test which read/writes blocks on a sliced block device
43
33
void test_slicing () {
44
34
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];
45
37
46
38
// Test with first slice of block device
47
39
SlicingBlockDevice slice1 (&bd, 0 , (BLOCK_COUNT/2 )*BLOCK_SIZE);
@@ -123,6 +115,8 @@ void test_slicing() {
123
115
TEST_ASSERT_EQUAL (0xff & rand (), read_block[i]);
124
116
}
125
117
118
+ delete[] write_block;
119
+ delete[] read_block;
126
120
err = slice2.deinit ();
127
121
TEST_ASSERT_EQUAL (0 , err);
128
122
}
@@ -131,6 +125,8 @@ void test_slicing() {
131
125
void test_chaining () {
132
126
HeapBlockDevice bd1 ((BLOCK_COUNT/2 )*BLOCK_SIZE, BLOCK_SIZE);
133
127
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];
134
130
135
131
// Test with chain of block device
136
132
BlockDevice *bds[] = {&bd1, &bd2};
@@ -174,26 +170,12 @@ void test_chaining() {
174
170
TEST_ASSERT_EQUAL (0xff & rand (), read_block[i]);
175
171
}
176
172
173
+ delete[] write_block;
174
+ delete[] read_block;
177
175
err = chain.deinit ();
178
176
TEST_ASSERT_EQUAL (0 , err);
179
177
}
180
178
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) */
197
179
198
180
// Test setup
199
181
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) {
202
184
}
203
185
204
186
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 ),
207
189
};
208
190
209
191
Specification specification (test_setup, cases);
0 commit comments