Refactored RTOS_1 test and did some small indent in tests.py

pull/900/head
Przemek Wirkus 2015-01-28 11:38:44 +00:00
parent f1f2505adc
commit 0bafe71fed
2 changed files with 37 additions and 21 deletions

View File

@ -5,11 +5,17 @@
DigitalOut led2(LED2);
#define SIZE 120
#define SIZE 100
namespace {
// Allocate data buffers
uint8_t data_written[SIZE] = { 0 };
uint8_t data_read[SIZE] = { 0 };
}
void sd_thread(void const *argument)
{
const char *FILE_NAME = "/sd/out.txt";
const char *FILE_NAME = "/sd/rtos9_test.txt";
#if defined(TARGET_KL25Z)
SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd");
@ -27,55 +33,53 @@ void sd_thread(void const *argument)
SDFileSystem sd(p11, p12, p13, p14, "sd");
#endif
// Allocate data buffers
uint8_t data_written[SIZE] = { 0 };
uint8_t data_read[SIZE] = { 0 };
{
// fill data_written buffer with random data
FILE *f = fopen(FILE_NAME, "w");
FILE *f = fopen(FILE_NAME, "w+");
if (f) {
// write these data into the file
printf("Writing %d bytes to file:\r\n", SIZE);
printf("Writing %d bytes to file:" NL, SIZE);
for (int i = 0; i < SIZE; i++) {
data_written[i] = rand() % 0xff;
fprintf(f, "%c", data_written[i]);
printf("%02X ", data_written[i]);
if (i && ((i % 20) == 19))
printf("\r\n");
printf(NL);
}
fclose(f);
printf("MBED: Done" NL);
} else {
printf("MBED: Can't open '%s'" NL, FILE_NAME);
TEST_RESULT(false);
return;
}
}
printf("\r\n\r\n");
printf(NL);
{
// read back the data from the file and store them in data_read
FILE *f = fopen(FILE_NAME, "r");
if (f) {
printf("Reading %d bytes from file:\r\n", SIZE);
printf("MBED: Reading %d bytes from file:" NL, SIZE);
for (int i = 0; i < SIZE; i++) {
data_read[i] = fgetc(f);
printf("%02X ", data_read[i]);
if (i && ((i % 20) == 19))
printf("\r\n");
printf(NL);
}
fclose(f);
printf("MBED: Done\r\n");
} else {
printf("MBED: Can't open '%s'" NL, FILE_NAME);
TEST_RESULT(false);
return;
}
}
printf("\r\nDone.\r\n");
// check that the data written == data read
for (int i = 0; i < SIZE; i++) {
if (data_written[i] != data_read[i]) {
printf("MBED: Data index=%d: w[0x%02X] != r[0x%02X]" NL, i, data_written[i], data_read[i]);
TEST_RESULT(false);
return;
}
}
TEST_RESULT(true);
@ -84,7 +88,7 @@ void sd_thread(void const *argument)
int main() {
TEST_TIMEOUT(20);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(SD File write-read);
TEST_DESCRIPTION(SD File write read);
TEST_START("RTOS_9");
Thread t(sd_thread, NULL, osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25));

View File

@ -527,7 +527,7 @@ TESTS = [
"automated": True,
#"host_test": "wait_us_auto"
},
# CMSIS RTOS tests
{
@ -629,14 +629,24 @@ TESTS = [
"duration": 15,
"automated": True,
#"host_test": "wait_us_auto",
"mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"],
"mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812",
"KL25Z", "KL05Z", "K64F", "KL46Z",
"RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE",
"NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8",
"NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC",
"DISCO_F401VC"],
},
{
"id": "RTOS_8", "description": "ISR (Queue)",
"source_dir": join(TEST_DIR, "rtos", "mbed", "isr"),
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB],
"automated": True,
"mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"],
"mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812",
"KL25Z", "KL05Z", "K64F", "KL46Z",
"RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE",
"NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8",
"NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC",
"DISCO_F401VC"],
},
{
"id": "RTOS_9", "description": "SD File write-read",
@ -644,7 +654,9 @@ TESTS = [
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB, FS_LIBRARY],
"automated": True,
"peripherals": ["SD"],
"mcu": ["LPC1768", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE"],
"mcu": ["LPC1768", "LPC11U24", "LPC812", "KL25Z",
"KL05Z", "K64F", "KL46Z", "RZ_A1H",
"DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE"],
},
# Networking Tests