]> git.mdlowis.com Git - projs/atf.git/commitdiff
Restructured repo and combined .c file with header to ease integration with new projects
authorMike Lowis <mike.lowis@gentex.com>
Fri, 26 Aug 2016 18:16:59 +0000 (14:16 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Fri, 26 Aug 2016 18:16:59 +0000 (14:16 -0400)
Makefile
atf.h [moved from source/atf.c with 68% similarity]
source/atf.h [deleted file]
tests.c [moved from tests/main.c with 69% similarity]
tests/test_signals.c [deleted file]

index a30c21e77aa4e2a477d9fb82d9036b45decd4af2..619de45dd1caf10907415bcb5349729fa7722486 100644 (file)
--- a/Makefile
+++ b/Makefile
-#------------------------------------------------------------------------------
-# Build Configuration
-#------------------------------------------------------------------------------
-# Update these variables according to your requirements.
-
-# version
 VERSION = 0.0.1
-
-# tools
-CC = c99
-LD = ${CC}
-AR = ar
-
-# flags
-INCS     = -Isource/ -Itests/
-CPPFLAGS = -D_XOPEN_SOURCE=700
-CFLAGS   = ${INCS} ${CPPFLAGS}
-LDFLAGS  = ${LIBS}
-ARFLAGS  = rcs
-
-# commands
-COMPILE = @echo CC $@; ${CC} ${CFLAGS} -c -o $@ $<
-LINK    = @echo LD $@; ${LD} -o $@ $^ ${LDFLAGS}
-ARCHIVE = @echo AR $@; ${AR} ${ARFLAGS} $@ $^
-CLEAN   = @rm -f
-
-#------------------------------------------------------------------------------
-# Build-Specific Macros
-#------------------------------------------------------------------------------
-# Library macros
-LIBNAME = atf
-LIB     = lib${LIBNAME}.a
-DEPS    = ${OBJS:.o=.d}
-OBJS    = source/atf.o
-
-# Test binary macros
-TEST_BIN  = test${LIBNAME}
-TEST_DEPS = ${TEST_OBJS:.o=.d}
-TEST_OBJS = tests/main.o tests/test_signals.o
-
-# Distribution dir and tarball settings
-DISTDIR   = ${LIBNAME}-${VERSION}
+DISTDIR   = atf-${VERSION}
 DISTTAR   = ${DISTDIR}.tar
 DISTGZ    = ${DISTTAR}.gz
-DISTFILES = config.mk LICENSE.md Makefile README.md source tests
-
-# load user-specific settings
--include config.mk
-
-#------------------------------------------------------------------------------
-# Phony Targets
-#------------------------------------------------------------------------------
-.PHONY: all options tests
+DISTFILES = atf.h LICENSE.md Makefile README.md tests.c
 
-all: options ${LIB} tests
-
-options:
-       @echo "Toolchain Configuration:"
-       @echo "  CC       = ${CC}"
-       @echo "  CFLAGS   = ${CFLAGS}"
-       @echo "  LD       = ${LD}"
-       @echo "  LDFLAGS  = ${LDFLAGS}"
-       @echo "  AR       = ${AR}"
-       @echo "  ARFLAGS  = ${ARFLAGS}"
-
-tests: ${TEST_BIN}
-       -./${TEST_BIN}
-       @echo "Note: It is expected that exactly 2 of the tests will fail."
-
-dist: clean
-       @echo DIST ${DISTGZ}
-       @mkdir -p ${DISTDIR}
-       @cp -R ${DISTFILES} ${DISTDIR}
-       @tar -cf ${DISTTAR} ${DISTDIR}
-       @gzip ${DISTTAR}
-       @rm -rf ${DISTDIR}
+tests: tests.c
+       $(CC) -I. -o $@ $^
+       -./$@
 
 clean:
-       ${CLEAN} ${LIB} ${TEST_BIN} ${OBJS} ${TEST_OBJS}
-       ${CLEAN} ${OBJS:.o=.gcno} ${OBJS:.o=.gcda}
-       ${CLEAN} ${TEST_OBJS:.o=.gcno} ${TEST_OBJS:.o=.gcda}
-       ${CLEAN} ${DEPS} ${TEST_DEPS}
-       ${CLEAN} ${DISTTAR} ${DISTGZ}
-
-#------------------------------------------------------------------------------
-# Target-Specific Rules
-#------------------------------------------------------------------------------
-.c.o:
-       ${COMPILE}
-
-${LIB}: ${OBJS}
-       ${ARCHIVE}
-
-${TEST_BIN}: ${TEST_OBJS} ${LIB}
-       ${LINK}
-
-# load dependency files
--include ${DEPS}
--include ${TEST_DEPS}
+       $(RM) tests $(DISTGZ)
 
+dist: clean
+       mkdir -p ${DISTDIR}
+       cp -R ${DISTFILES} ${DISTDIR}
+       tar -cf ${DISTTAR} ${DISTDIR}
+       gzip ${DISTTAR}
+       rm -rf ${DISTDIR}
similarity index 68%
rename from source/atf.c
rename to atf.h
index e1017e8a2f53cc3081209a168acc9bccec389c1f..fccdd09432b13bb627e0af0e0d19afe57fb8c3ab 100755 (executable)
+++ b/atf.h
@@ -1,11 +1,48 @@
 /**
-  @file atf.c
-  @brief See header for details
+  @file atf.h
+  @brief Aardvark Test Framework main interface file.
   $Revision$
   $HeadURL$
 */
-#include "atf.h"
+#ifndef TEST_H
+#define TEST_H
+
 #include <stddef.h>
+#include <stdbool.h>
+
+extern char* Curr_Test;
+
+void atf_init(int argc, char** argv);
+
+void atf_test_start(char* file, unsigned int line, char* name);
+
+bool atf_test_assert(bool success, char* expr_str, char* file, int line);
+
+void atf_test_fail(char* expr, char* file, int line);
+
+int atf_print_results(void);
+
+#define CHECK(expr) \
+    if(atf_test_assert((expr), #expr, __FILE__, __LINE__)) break
+
+#define TEST_SUITE(name) \
+    void name(void)
+
+#define TEST(desc) \
+    for(atf_test_start(__FILE__,__LINE__,#desc); Curr_Test != NULL; Curr_Test = NULL)
+
+#define RUN_TEST_SUITE(name) \
+    name();
+
+#define RUN_EXTERN_TEST_SUITE(name) \
+    do { extern TEST_SUITE(name); RUN_TEST_SUITE(name); } while(0)
+
+#define PRINT_TEST_RESULTS \
+    atf_print_results
+
+/* Function Definitions
+ *****************************************************************************/
+#ifdef INCLUDE_DEFS
 #include <stdio.h>
 #include <stdlib.h>
 #ifndef NO_SIGNALS
@@ -58,10 +95,6 @@ void atf_init(int argc, char** argv) {
 #endif
 }
 
-void atf_run_suite(suite_t suite) {
-    suite();
-}
-
 void atf_test_start(char* file, unsigned int line, char* name) {
     Curr_File = file;
     Curr_Line = line;
@@ -92,3 +125,7 @@ int atf_print_results(void) {
     return Failed;
 }
 
+#undef INCLUDE_DEFS
+#endif
+
+#endif /* TEST_H */
diff --git a/source/atf.h b/source/atf.h
deleted file mode 100755 (executable)
index 0e2d2f1..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
-  @file atf.h
-  @brief Aardvark Test Framework main interface file.
-  $Revision$
-  $HeadURL$
-*/
-#ifndef TEST_H
-#define TEST_H
-
-#include <stddef.h>
-#include <stdbool.h>
-
-typedef void (*suite_t)(void);
-
-extern char* Curr_Test;
-
-void atf_init(int argc, char** argv);
-
-void atf_run_suite(suite_t suite);
-
-void atf_test_start(char* file, unsigned int line, char* name);
-
-bool atf_test_assert(bool success, char* expr_str, char* file, int line);
-
-void atf_test_fail(char* expr, char* file, int line);
-
-int atf_print_results(void);
-
-#define CHECK(expr) \
-    if(atf_test_assert((expr), #expr, __FILE__, __LINE__)) break
-
-#define TEST_SUITE(name) void name(void)
-
-#define TEST(desc) \
-    for(atf_test_start(__FILE__,__LINE__,#desc); Curr_Test != NULL; Curr_Test = NULL)
-
-#define RUN_EXTERN_TEST_SUITE(name) \
-    do { extern TEST_SUITE(name); atf_run_suite(&name); } while(0)
-
-#define RUN_TEST_SUITE(name) \
-    atf_run_suite(&name)
-
-#define PRINT_TEST_RESULTS atf_print_results
-
-#endif /* TEST_H */
similarity index 69%
rename from tests/main.c
rename to tests.c
index 393827209919e634cd773667395877da79495e63..807e8e0e362add51f7522dcdc106176523222930 100644 (file)
+++ b/tests.c
@@ -1,4 +1,5 @@
-#include "atf.h"
+#define INCLUDE_DEFS
+#include <atf.h>
 
 TEST_SUITE(Local_Suite) {
     TEST(Passing_Test) {
@@ -16,3 +17,9 @@ int main(int argc, char** argv) {
     RUN_EXTERN_TEST_SUITE(External_Suite);
     return atf_print_results();
 }
+
+TEST_SUITE(External_Suite) {
+    TEST(Should_handle_SIGABRT) {
+        raise(SIGABRT);
+    }
+}
diff --git a/tests/test_signals.c b/tests/test_signals.c
deleted file mode 100644 (file)
index 7b8cacf..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "atf.h"
-#include <signal.h>
-
-TEST_SUITE(External_Suite) {
-    TEST(Should_handle_SIGABRT) {
-        raise(SIGABRT);
-    }
-}