Add a unit test.
This also changes the Jenkinsfile so the tests run on Jenkins.
Change-Id: Ib7fbc226e81a574e7068f5d1eba8491cdb523f17
diff --git a/makefile b/makefile
index 26607eb..269e14e 100644
--- a/makefile
+++ b/makefile
@@ -2,23 +2,43 @@
CXX = c++
LDFLAGS =
-CXXFLAGS = -I.
+CXXFLAGS = -I. -std=c++17
+MKDIR_P = mkdir -p
EXE = exe/hello-world-ng
+TEST = t/greeting-test
mod_OBJ = mod/greeting.o
hello_world_ng_OBJ = exe/hello-world-ng.o
+greeting_test_OBJ = t/greeting-test.o
OBJ = $(hello_world_ng_OBJ) $(mod_OBJ)
all: $(EXE)
+test: $(TEST)
+ @for x in $^; do \
+ echo $$x; \
+ $$x; \
+ done
+
+test-junit: $(TEST)
+ $(MKDIR_P) test-results/t
+ @for x in $^; do \
+ echo $$x -r junit -o test-results/$$x.xml --success; \
+ $$x -r junit -o test-results/$$x.xml --success || :; \
+ done
+
clean:
$(RM) $(OBJ)
$(RM) $(EXE)
+ $(RM) -r test-results
exe/hello-world-ng: $(hello_world_ng_OBJ) $(mod_OBJ)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+t/greeting-test: $(greeting_test_OBJ) $(mod_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<