Refactored tests for SD card peripheral

pull/900/head
Przemek Wirkus 2015-01-27 13:44:30 +00:00
parent dcce4d7cde
commit a4bf0cf135
4 changed files with 40 additions and 36 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}