]> Chaos Git - corbenik/corbenik.git/commitdiff
Remove the unit test framework.
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 10 Jan 2017 13:47:35 +0000 (08:47 -0500)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 10 Jan 2017 13:47:35 +0000 (08:47 -0500)
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.

configure.ac
source/Makefile.am
source/menu.c
source/test-framework.c [deleted file]
source/test/basic-sanity.test [deleted file]
source/test/file.test [deleted file]

index 5c0e9fef7e0ec13140a9bc3fa8fc5a2c0be68e4e..9581a7a908d8ca53758cc79811763e356db9853d 100644 (file)
@@ -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
index ad899e4f5f54d6a658afe83a178be3c93c37e590..b8e1e77e7d27a6649a1cb8ea27d2446270d6edd8 100644 (file)
@@ -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 \
index e62febda325d5cc0f4efa824d183542ccbe7d4f8..a7ce9a14abfcc44bf93da6e2c3d70eb5bc741589 100644 (file)
@@ -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 (file)
index f91647f..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <corbconf.h>
-#if defined(UNITTESTS) && UNITTESTS == 1
-
-#include <common.h>
-
-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 (file)
index 95fb3a9..0000000
+++ /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 (file)
index 986b600..0000000
+++ /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");
-}