]> git.mdlowis.com Git - archive/carl.git/commitdiff
Added support for unit tests
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 7 Jun 2015 18:48:53 +0000 (14:48 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 7 Jun 2015 18:48:53 +0000 (14:48 -0400)
.gitignore
.gitmodules
build.rb
modules/atf [new submodule]
source/exits.c [new file with mode: 0644]
source/libc.h
source/main.c
tests/main.c [new file with mode: 0644]
tests/refcount.c [new file with mode: 0644]

index 891ec23a29d91f90cdd12af091018b3d335236c7..be55fce347f67146f116782210cf8748b02d67cf 100644 (file)
@@ -31,3 +31,5 @@
 # Debug files
 *.dSYM/
 .rsconscache
+test_libc
+test_libc.exe
index 3806bc394f8a81a611723f272ca9e7915b1735a0..48ebd4b01f8b65c4db5a2de579bb68a771573880 100644 (file)
@@ -1,3 +1,6 @@
 [submodule "modules/build-system"]
     path = modules/build-system
     url = https://github.com/mikedlowis/build-system.git
+[submodule "modules/atf"]
+       path = modules/atf
+       url = https://github.com/mikedlowis/atf.git
index ab729b0861e6b1630f6d285f35a6fa9b263ac3c0..bbd4644623acbc479430ccaabe8eab18fa6b2df1 100755 (executable)
--- a/build.rb
+++ b/build.rb
@@ -7,7 +7,7 @@ require './modules/build-system/setup'
 # Define the default compiler environment
 main_env = BuildEnv.new do |env|
   env["CFLAGS"]  += ['-O3', '-Wall', '-Wextra', '--std=c99', '--pedantic']
-  env["CPPPATH"] += Dir['source/']
+  env["CPPPATH"] += Dir['source/', 'modules/atf/source']
 end
 
 #------------------------------------------------------------------------------
@@ -21,5 +21,7 @@ main_env.Library('libc.a', FileList['source/**/*.c'])
 #------------------------------------------------------------------------------
 if Opts[:profile].include? "test"
   # Do nothing for now
+  main_env.Program('test_libc', Dir["tests/**/*.c", "modules/atf/source/*.c"] + ['./libc.a'])
+  main_env.Command('Unit Tests', 'test_libc', "CMD" => './test_libc')
 end
 
diff --git a/modules/atf b/modules/atf
new file mode 160000 (submodule)
index 0000000..1105e4a
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 1105e4a88bbda546991da0314ba6060f9f624dba
diff --git a/source/exits.c b/source/exits.c
new file mode 100644 (file)
index 0000000..f4d461f
--- /dev/null
@@ -0,0 +1,15 @@
+#include "libc.h"
+
+char* errstr = nil;
+
+static int exitcode(void)
+{
+    return errstr ? 1 : errno;
+}
+
+void exits(char* estr)
+{
+    errstr = estr;
+    exit(exitcode());
+}
+
index 911a28d1b717cc5b464d4bde63e61d9a01bbc0a7..06f5d27e059a5cf16731060829528673e6050353 100644 (file)
@@ -386,6 +386,7 @@ bool isupperrune(Rune ch);
  */
 #include <stdio.h>
 
+#if 0
 #define Bsize      8*1024
 #define Bungetsize 4        /* space for ungetc */
 #define Bmagic     0x314159
@@ -432,6 +433,7 @@ int ioungetc(iobuf*);
 int ioungetrune(iobuf*);
 long iowrite(iobuf*, void*, long);
 int iovprint(iobuf*, char*, va_list);
+#endif
 
 /*
  * New Features
index 1930b05e2be27f62296c7d7f29fe09b03b1bdd19..8b70bcc4219d2756a0de577d2292e464a437e94c 100644 (file)
@@ -1,20 +1,6 @@
 #define NO_MAIN_WRAPPER
 #include "libc.h"
 
-char* errstr = nil;
-
-static int exitcode(void)
-{
-    return errstr ? 1 : errno;
-}
-
-void exits(char* estr)
-{
-    if (estr)
-        errstr = estr;
-    exit(exitcode());
-}
-
 int main(int argc, char** argv)
 {
     user_main(argc, argv);
diff --git a/tests/main.c b/tests/main.c
new file mode 100644 (file)
index 0000000..cdaf8df
--- /dev/null
@@ -0,0 +1,10 @@
+#include "atf.h"
+#include "libc.h"
+
+void main(int argc, char** argv)
+{
+    (void)argc;
+    (void)argv;
+    RUN_EXTERN_TEST_SUITE(RefCount);
+    exit(PRINT_TEST_RESULTS());
+}
diff --git a/tests/refcount.c b/tests/refcount.c
new file mode 100644 (file)
index 0000000..9d82c4f
--- /dev/null
@@ -0,0 +1,11 @@
+// Unit Test Framework Includes
+#include "atf.h"
+
+// File To Test
+#include "libc.h"
+
+//-----------------------------------------------------------------------------
+// Begin Unit Tests
+//-----------------------------------------------------------------------------
+TEST_SUITE(RefCount) {
+}