From fae2f1f82143e20901131027da49d24da45fb89f Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 30 Oct 2014 14:55:01 -0700 Subject: [PATCH] Added better separation of tests, moving the FS tests into source/test_fs --- source/main.c | 45 ++++++++++++++++++++++++--------------------- source/output.c | 8 +++++++- source/output.h | 3 +-- source/test_fs.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ source/test_fs.h | 22 ++++++++++++++++++++++ 5 files changed, 99 insertions(+), 24 deletions(-) create mode 100644 source/test_fs.c create mode 100644 source/test_fs.h diff --git a/source/main.c b/source/main.c index c958b44..27d337d 100644 --- a/source/main.c +++ b/source/main.c @@ -3,6 +3,12 @@ #include <3ds.h> #include "output.h" +#include "test_fs.h" + +static int testCounter = 0; +static void (*tests[]) (void) = { + FS_TestAll +}; int main() { @@ -12,38 +18,34 @@ int main() gfxInit(); gfxSet3D(false); - superStr[0] = 0; - - print("fsInit %08X\n", (unsigned int) - fsInit() - ); - - FS_archive sdmcArchive = { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } }; - - print("FSUSER_OpenArchive %08X\n", (unsigned int) - FSUSER_OpenArchive(NULL, &sdmcArchive) - ); + clearScreen(); + print("Press A to begin...\n"); APP_STATUS status; - while ((status=aptGetStatus()) != APP_EXITING) { - switch (status) { - case APP_RUNNING: + while ((status = aptGetStatus()) != APP_EXITING) { + if (status == APP_RUNNING) { drawFrame(); hidScanInput(); if (hidKeysDown() & KEY_B) { break; } else if (hidKeysDown() & KEY_A) { - print("FSUSER_CreateDirectory %08X\n", (unsigned int) - FSUSER_CreateDirectory(NULL, sdmcArchive, FS_makePath(PATH_CHAR, "/new_dir")) - ); + clearScreen(); + + if (testCounter < (sizeof(tests) / sizeof(tests[0]))) { + tests[testCounter](); + testCounter++; + } else { + break; + } + + print("\n"); + print("Press A to continue...\n"); } - break; - case APP_SUSPENDING: + } else if (status == APP_SUSPENDING) { aptReturnToMenu(); - break; - case APP_SLEEPMODE: + } else if (status == APP_SLEEPMODE) { aptWaitStatusEvent(); break; } @@ -51,6 +53,7 @@ int main() gspWaitForEvent(GSPEVENT_VBlank0, false); } + clearScreen(); gfxExit(); hidExit(); aptExit(); diff --git a/source/output.c b/source/output.c index 7f33795..0612553 100644 --- a/source/output.c +++ b/source/output.c @@ -8,7 +8,7 @@ #include "text.h" -char superStr[8192]; +static char superStr[8192]; static int cnt; static int countLines(const char* str) @@ -74,3 +74,9 @@ void print(const char* format, ...) drawFrame(); } + +void clearScreen() +{ + superStr[0] = 0; + drawFrame(); +} diff --git a/source/output.h b/source/output.h index 4b643e2..00c427b 100644 --- a/source/output.h +++ b/source/output.h @@ -1,9 +1,8 @@ #ifndef OUTPUT_H #define OUTPUT_H -extern char superStr[]; - void drawFrame(); void print(const char* format, ...); +void clearScreen(); #endif diff --git a/source/test_fs.c b/source/test_fs.c new file mode 100644 index 0000000..d9e7cfb --- /dev/null +++ b/source/test_fs.c @@ -0,0 +1,45 @@ +#include "test_fs.h" + +#include <3ds.h> + +#include "output.h" + +static FS_archive sdmcArchive; + +void FS_TestAll() +{ + FS_TestInit(); + FS_TestSdmcOpen(); + FS_TestSdmcCreateDir(); + FS_TestSdmcClose(); +} + +void FS_TestInit() +{ + print("fsInit %08X\n", (unsigned int) + fsInit() + ); +} + +void FS_TestSdmcOpen() +{ + sdmcArchive = (FS_archive) { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } }; + + print("FSUSER_OpenArchive %08X\n", (unsigned int) + FSUSER_OpenArchive(NULL, &sdmcArchive) + ); +} + +void FS_TestSdmcCreateDir() +{ + print("FSUSER_CreateDirectory %08X\n", (unsigned int) + FSUSER_CreateDirectory(NULL, sdmcArchive, FS_makePath(PATH_CHAR, "/new_dir")) + ); +} + +void FS_TestSdmcClose() +{ + print("FSUSER_CloseArchive %08X\n", (unsigned int) + FSUSER_CloseArchive(NULL, &sdmcArchive) + ); +} diff --git a/source/test_fs.h b/source/test_fs.h new file mode 100644 index 0000000..95f331e --- /dev/null +++ b/source/test_fs.h @@ -0,0 +1,22 @@ +#ifndef TEST_FS_H +#define TEST_FS_H + +void FS_TestAll(); + + +void FS_TestInit(); + +void FS_TestSdmcOpen(); +// FS_TestSdmcCreateFile(); +void FS_TestSdmcRenameFile(); +void FS_TestSdmcOpenFile(); +void FS_TestSdmcOpenFileDirectly(); +void FS_TestSdmcDeleteFile(); +void FS_TestSdmcCreateDir(); +// FS_TestSdmcRenameDir(); +void FS_TestSdmcOpenDir(); +// FS_TestSdmcDeleteDir(); +// FS_TestSdmcDeleteDirRecursively(); +void FS_TestSdmcClose(); + +#endif