From a4bf0cf135adcccc7dd69cd2bc7908e7baaa2be8 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 27 Jan 2015 13:44:30 +0000 Subject: [PATCH] Refactored tests for SD card peripheral --- libraries/tests/mbed/sd/main.cpp | 10 ++++++--- libraries/tests/mbed/sd_perf_fatfs/main.cpp | 22 +++++++++---------- libraries/tests/mbed/sd_perf_fhandle/main.cpp | 22 +++++++++---------- libraries/tests/mbed/sd_perf_stdio/main.cpp | 22 +++++++++---------- 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/libraries/tests/mbed/sd/main.cpp b/libraries/tests/mbed/sd/main.cpp index 82d83456ae..0bac9c4aa4 100644 --- a/libraries/tests/mbed/sd/main.cpp +++ b/libraries/tests/mbed/sd/main.cpp @@ -61,8 +61,12 @@ const char *sd_file_path = "/sd/out.txt"; const int DATA_SIZE = 256; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD File System); + TEST_START("MBED_A12"); + uint8_t data_written[DATA_SIZE] = { 0 }; bool result = false; @@ -103,5 +107,5 @@ int main() } result = write_result && read_result; - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_fatfs/main.cpp b/libraries/tests/mbed/sd_perf_fatfs/main.cpp index beb2ef25b1..555022de61 100644 --- a/libraries/tests/mbed/sd_perf_fatfs/main.cpp +++ b/libraries/tests/mbed/sd_perf_fatfs/main.cpp @@ -55,16 +55,14 @@ SDFileSystem sd(SDMOSI, SDMISO, SDSCLK, SDSSEL, "sd"); SDFileSystem sd(p11, p12, p13, p14, "sd"); #endif -namespace -{ +namespace { char buffer[1024]; const int KIB_RW = 128; Timer timer; const char *bin_filename = "0:testfile.bin"; } -bool test_sf_file_write_fatfs(const char *filename, const int kib_rw) -{ +bool test_sf_file_write_fatfs(const char *filename, const int kib_rw) { FIL file; bool result = true; FRESULT res = f_open(&file, filename, FA_WRITE | FA_CREATE_ALWAYS); @@ -96,8 +94,7 @@ bool test_sf_file_write_fatfs(const char *filename, const int kib_rw) return result; } -bool test_sf_file_read_fatfs(const char *filename, const int kib_rw) -{ +bool test_sf_file_read_fatfs(const char *filename, const int kib_rw) { FIL file; bool result = true; FRESULT res = f_open(&file, filename, FA_READ | FA_OPEN_EXISTING); @@ -123,13 +120,16 @@ bool test_sf_file_read_fatfs(const char *filename, const int kib_rw) return result; } -char RandomChar() -{ +char RandomChar() { return rand() % 100; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD FatFS RW Speed); + TEST_START("PERF_3"); + // Test header printf("\r\n"); printf("SD Card FatFS Performance Test\r\n"); @@ -156,5 +156,5 @@ int main() } break; } - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_fhandle/main.cpp b/libraries/tests/mbed/sd_perf_fhandle/main.cpp index 375f29a91a..292530366f 100644 --- a/libraries/tests/mbed/sd_perf_fhandle/main.cpp +++ b/libraries/tests/mbed/sd_perf_fhandle/main.cpp @@ -55,16 +55,14 @@ SDFileSystem sd(SDMOSI, SDMISO, SDSCLK, SDSSEL, "sd"); SDFileSystem sd(p11, p12, p13, p14, "sd"); #endif -namespace -{ +namespace { char buffer[1024]; const int KIB_RW = 128; Timer timer; const char *bin_filename = "testfile.bin"; } -bool test_sf_file_write_fhandle(const char *filename, const int kib_rw) -{ +bool test_sf_file_write_fhandle(const char *filename, const int kib_rw) { bool result = true; FileHandle* file = sd.open(filename, O_WRONLY | O_CREAT | O_TRUNC); if (file != NULL) { @@ -94,8 +92,7 @@ bool test_sf_file_write_fhandle(const char *filename, const int kib_rw) return result; } -bool test_sf_file_read_fhandle(const char *filename, const int kib_rw) -{ +bool test_sf_file_read_fhandle(const char *filename, const int kib_rw) { bool result = true; FileHandle* file = sd.open(filename, O_RDONLY); if (file) { @@ -118,13 +115,16 @@ bool test_sf_file_read_fhandle(const char *filename, const int kib_rw) return result; } -char RandomChar() -{ +char RandomChar() { return rand() % 100; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD FileHandle RW Speed); + TEST_START("PERF_2"); + // Test header printf("\r\n"); printf("SD Card FileHandle Performance Test\r\n"); @@ -151,5 +151,5 @@ int main() } break; } - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_stdio/main.cpp b/libraries/tests/mbed/sd_perf_stdio/main.cpp index 598dba143c..05246cf83e 100644 --- a/libraries/tests/mbed/sd_perf_stdio/main.cpp +++ b/libraries/tests/mbed/sd_perf_stdio/main.cpp @@ -55,16 +55,14 @@ SDFileSystem sd(SDMOSI, SDMISO, SDSCLK, SDSSEL, "sd"); SDFileSystem sd(p11, p12, p13, p14, "sd"); #endif -namespace -{ +namespace { char buffer[1024]; const int KIB_RW = 128; Timer timer; const char *bin_filename = "/sd/testfile.bin"; } -bool test_sf_file_write_stdio(const char *filename, const int kib_rw) -{ +bool test_sf_file_write_stdio(const char *filename, const int kib_rw) { bool result = true; FILE* file = fopen(filename, "w"); if (file != NULL) { @@ -94,8 +92,7 @@ bool test_sf_file_write_stdio(const char *filename, const int kib_rw) return result; } -bool test_sf_file_read_stdio(const char *filename, const int kib_rw) -{ +bool test_sf_file_read_stdio(const char *filename, const int kib_rw) { bool result = true; FILE* file = fopen(filename, "r"); if (file) { @@ -118,13 +115,16 @@ bool test_sf_file_read_stdio(const char *filename, const int kib_rw) return result; } -char RandomChar() -{ +char RandomChar() { return rand() % 100; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD stdio RW Speed); + TEST_START("PERF_1"); + // Test header printf("\r\n"); printf("SD Card Stdio Performance Test\r\n"); @@ -151,5 +151,5 @@ int main() } break; } - notify_completion(result); + TEST_RESULT(result); }