From: chaoskagami Date: Tue, 10 Jan 2017 13:47:35 +0000 (-0500) Subject: Remove the unit test framework. X-Git-Tag: v0.3.1~33 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=a8c4866a9968849e98f7db98d81af9dd02ee30a3;p=corbenik%2Fcorbenik.git Remove the unit test framework. Pretty much all of it is sanity tests for things that are now using newlib (or WILL be) The test suite right now is a terrible piece of crap, so remove it. --- diff --git a/configure.ac b/configure.ac index 5c0e9fe..9581a7a 100644 --- a/configure.ac +++ b/configure.ac @@ -17,15 +17,8 @@ LT_INIT AC_ARG_ENABLE([chainloader], AS_HELP_STRING([--disable-chainloader], [Disable chainloading of external programs])) -AC_ARG_ENABLE([unittests], - AS_HELP_STRING([--enable-unittests], [Include unit tests in resultant binary.])) - AC_PREFIX_DEFAULT([/corbenik]) -UNITTESTS=0 -test "$enable_unittests" = "yes" && UNITTESTS=1 -AC_DEFINE_UNQUOTED([UNITTESTS], [$UNITTESTS]) - CHAINLOADER=1 test "$enable_chainloader" = "no" && CHAINLOADER=0 AC_DEFINE_UNQUOTED([CHAINLOADER], [$CHAINLOADER]) @@ -34,6 +27,8 @@ AC_CONFIG_FILES([Makefile source/Makefile external/Makefile include/Makefile]) AC_CONFIG_SUBDIRS([external/libctr9]) +AC_OUTPUT + echo " Corbenik $VERSION ======================== @@ -52,7 +47,5 @@ ldflags: ${LDFLAGS} ocflags: ${OCFLAGS} Chainloader: ${CHAINLOADER} -Unit tests: ${UNITTESTS} " -AC_OUTPUT diff --git a/source/Makefile.am b/source/Makefile.am index ad899e4..b8e1e77 100644 --- a/source/Makefile.am +++ b/source/Makefile.am @@ -21,7 +21,7 @@ inc_dir = $(top_srcdir)/include corbenik_SOURCES = \ start.s corbenik.c \ - menu.c menu-backend.c interrupt.c arm11.c test-framework.c interpreter.c input.c patcher.c chainloader.c \ + menu.c menu-backend.c interrupt.c arm11.c interpreter.c input.c patcher.c chainloader.c \ patch/reboot.c patch/svc.c patch/module.c patch/emunand.c \ std/fs.c std/draw.c std/memory.c std/abort.c \ firm/util.c firm/keys.c firm/firmlaunch.c firm/version.c firm/firm.c firm/decryptor.c \ diff --git a/source/menu.c b/source/menu.c index e62febd..a7ce9a1 100644 --- a/source/menu.c +++ b/source/menu.c @@ -15,10 +15,6 @@ static int current_menu_index_patches = 0; void chainload_menu(); #endif -#if defined(UNITTESTS) && UNITTESTS == 1 -void run_test_harness(); -#endif - #ifndef REL #define REL "master" #endif @@ -175,11 +171,6 @@ static struct options_s main_s[] = { { "Chainload", "Boot another ARM9 payload file.", option, 0, chainload_menu, NULL, 0, 0 }, -#endif -#if defined(UNITTESTS) && UNITTESTS == 1 - { "Unit tests", - "Runs through a number of sanity and regression tests to check for defects.", - option, 0, run_test_harness, NULL, 0, 0 }, #endif { "Boot Firmware", "Patches the firmware, and boots it.", diff --git a/source/test-framework.c b/source/test-framework.c deleted file mode 100644 index f91647f..0000000 --- a/source/test-framework.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#if defined(UNITTESTS) && UNITTESTS == 1 - -#include - -uint32_t total; -uint32_t pass; -uint32_t fail; -uint32_t skip; - -void test(int value, const char* name) { - fprintf(stderr, "%s: ", name); - - switch(value) { - case 0: - fprintf(stderr, "pass\n"); - ++pass; - break; - case 1: - fprintf(stderr, "fail\n"); - ++fail; - break; - default: - fprintf(stderr, "skip\n"); - ++skip; - break; - } - ++total; -} - -int assert_null(void* ptr) { - if (ptr == NULL) - return 0; - return 1; -} - -int assert_nonnull(void* ptr) { - if (ptr != NULL) - return 0; - return 1; -} - -int assert_int(int input, int value) { - if (input != value) - return 1; - return 0; -} - -int assert_u32(uint32_t input, uint32_t value) { - if (input != value) - return 1; - return 0; -} - -int assert_array_eq(uint8_t* input, uint8_t* test, uint32_t len) { - for (uint32_t i=0; i < len; i++) { - if (input[i] != test[i]) - return 1; - } - return 0; -} - -// We do NOT want the test harness optimized whatsoever. - -void __attribute__((optimize("O0"))) run_test_harness() { - total = pass = fail = skip = 0; - - #include "test/basic-sanity.test" - #include "test/file.test" -// #include "test/firmware.test" -// #include "test/vm.test" -// #include "test/vm-patch.test" - - fprintf(stderr, "= Tests =\n" - "Total: %lu\n" - "Pass: %lu\n" - "Fail: %lu\n" - "Skip: %lu\n", - total, pass, fail, skip); -} - -#endif diff --git a/source/test/basic-sanity.test b/source/test/basic-sanity.test deleted file mode 100644 index 95fb3a9..0000000 --- a/source/test/basic-sanity.test +++ /dev/null @@ -1,15 +0,0 @@ -{ - uint8_t memory0[8] = "reverse"; - uint8_t memory1[8] = "forward"; - uint8_t memory_out[8] = "forward"; - - // Test for inequivalence. - test(assert_int(!memcmp(memory0, memory1, 8), 0), "Inverted memcmp"); - - // Test for equivalence. - test(assert_int(memcmp(memory1, memory_out, 8), 0), "memcmp"); - - // Test sanity of memcpy. - memcpy(memory1, memory0, 8); - test(assert_int(memcmp(memory0, memory1, 8), 0), "memcpy"); -} diff --git a/source/test/file.test b/source/test/file.test deleted file mode 100644 index 986b600..0000000 --- a/source/test/file.test +++ /dev/null @@ -1,37 +0,0 @@ -{ - FILE* file_handle = NULL; - char filename[] = "/lolidontexistwowlol"; - - // Test; open nonexistent file for read. - file_handle = fopen(filename, "r"); - - test(assert_null(file_handle), "Nonexistent file"); - - // Test; open nonexistent file for write. - file_handle = fopen(filename, "w"); - - test(assert_nonnull(file_handle), "Open for writing"); - - // Test; write string. Close file, check length, compare equality. - char data_str[] = "LOOK AT THIS STRING; It Should be equal."; - char data_str2[] = " "; - - test(assert_u32(fwrite(data_str, 1, sizeof(data_str), file_handle), sizeof(data_str)), "fwrite return"); - fclose(file_handle); - - file_handle = fopen(filename, "r"); - test(assert_nonnull(file_handle), "Open for read"); - - test(assert_u32(fread(data_str2, 1, sizeof(data_str), file_handle), sizeof(data_str)), "fread return"); - - test(assert_int(memcmp(data_str, data_str2, sizeof(data_str)), 0), "read data"); - - fclose(file_handle); - - // Test removal. - - f_unlink(filename); - - file_handle = fopen(filename, "r"); - test(assert_null(file_handle), "Remove file"); -}