aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2021-02-27 20:31:17 +1300
committerDavid Phillips <david@yeah.nah.nz>2021-02-27 20:32:40 +1300
commite843e9da835f058e09810cfeba7c60d0b270e7b3 (patch)
tree37345174f2d1e6741da4016267ec27c5139b50c3
parentd84f7a93151aad059d6780362dea1776ff8ea358 (diff)
downloadaltimeter-e843e9da835f058e09810cfeba7c60d0b270e7b3.tar.xz
Move unity-test-runner to submodule
-rw-r--r--.gitmodules3
-rw-r--r--Makefile13
-rw-r--r--linker_list.lds8
-rw-r--r--test_runner.c21
-rw-r--r--test_runner.h32
m---------unity-test-runner0
6 files changed, 10 insertions, 67 deletions
diff --git a/.gitmodules b/.gitmodules
index 5c07d44..81baad2 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,3 +4,6 @@
[submodule "unity"]
path = unity
url = https://github.com/ThrowTheSwitch/Unity/
+[submodule "unity-test-runner"]
+ path = unity-test-runner
+ url = nah.nz:/srv/git/public/unity-test-runner
diff --git a/Makefile b/Makefile
index 05c24bc..6ba3a4f 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,8 @@ SIM_ELF = build/altimeter_sim.elf
# options for native (i.e. unit test)
UNITY_SRC ?= unity/src
-CFLAGS += -Wall -Wextra -I$(UNITY_SRC) -g3
+TEST_RUNNER ?= unity-test-runner
+CFLAGS += -Wall -Wextra -I$(UNITY_SRC) -I$(TEST_RUNNER) -g3
LDFLAGS += -lm
# options for cross-compile
@@ -30,7 +31,7 @@ AVR_COMMON_LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
AVR_LDFLAGS += $(AVR_COMMON_LDFLAGS) -mmcu=$(MCU)
SIM_LDFLAGS += $(AVR_COMMON_LDFLAGS) -mmcu=$(SIM_MCU)
-$(shell mkdir -p build/{real,sim,native{,/$(UNITY_SRC)}})
+$(shell mkdir -p build/{real,sim,native{,/$(UNITY_SRC),/$(TEST_RUNNER)}})
all: build/altimeter_sim.elf build/altimeter.hex test size
@@ -56,7 +57,7 @@ NATIVE_DIR = $(BUILD_DIR)/native
TEST_OBJ = \
$(NATIVE_DIR)/$(UNITY_SRC)/unity.o \
- $(NATIVE_DIR)/test_runner.o \
+ $(NATIVE_DIR)/$(TEST_RUNNER)/test_runner.o \
$(NATIVE_DIR)/test_util.o \
$(NATIVE_DIR)/test_data_manager.o \
$(NATIVE_DIR)/data_manager.o \
@@ -80,11 +81,11 @@ SIM_OBJ = \
ALL_OBJ = $(TEST_OBJ) $(REAL_OBJ) $(SIM_OBJ)
ALL_SOURCE = $(ALL_OBJ:.o=.c)
-test: build/native/test_runner
+test: build/native/unity-test-runner/test_runner
./$^
-build/native/test_runner: $(TEST_OBJ)
- $(CC) $(LDFLAGS) -Wl,-T,linker_list.lds -o $@ $^
+build/native/unity-test-runner/test_runner: $(TEST_OBJ)
+ $(CC) $(LDFLAGS) -Wl,-T,$(TEST_RUNNER)/linker_list.lds -o $@ $^
# ELF for real hardware. No mock/sim hardware included (except barometer,
# haven't written that code yet)
diff --git a/linker_list.lds b/linker_list.lds
deleted file mode 100644
index bb70bd8..0000000
--- a/linker_list.lds
+++ /dev/null
@@ -1,8 +0,0 @@
-SECTIONS {
- __test_runner_list_start = .;
- .test_runner_list : {
- KEEP(*(SORT(.test_runner_list*)));
- }
- __test_runner_list_end = .;
-}
-INSERT BEFORE .bss;
diff --git a/test_runner.c b/test_runner.c
deleted file mode 100644
index 7887118..0000000
--- a/test_runner.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdio.h>
-
-#include "test_runner.h"
-#include "unity.h"
-
-/* unity requires these, even if empty */
-void setUp(){};
-void tearDown(){};
-
-int main(void)
-{
- struct test_fn *tests = list_head(struct test_fn, test_list);
- size_t count = list_entry_count(struct test_fn, test_list);
- printf("Suite has %zd tests\n", count);
- UNITY_BEGIN();
- for (size_t i = 0; i < count; i++) {
- UnitySetTestFile(tests[i].file);
- UnityDefaultTestRun(tests[i].fn, tests[i].name, tests[i].line);
- }
- return UNITY_END();
-}
diff --git a/test_runner.h b/test_runner.h
deleted file mode 100644
index 5b891b0..0000000
--- a/test_runner.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-/* Linker-generated lists derived from U-Boot source `include/linker_lists.h`
- * with minor modification to store function pointers */
-#define list_head(entry_type, list_name) \
- ({ static char head[0] __attribute__((__aligned__(4), unused, section(".test_runner_list_2_"#list_name"_1")));(entry_type*)&head; })
-
-#define list_tail(entry_type, list_name) \
- ({ static char tail[0] __attribute__((__aligned__(4), unused, section(".test_runner_list_2_"#list_name"_3")));(entry_type*)&tail; })
-
-#define list_entry_count(entry_type, list_name) \
- ({ \
- entry_type* head = list_head(entry_type, list_name); \
- entry_type* tail = list_tail(entry_type, list_name); \
- (size_t)(tail - head); \
- })
-
-#define list_entry(entry_type, list_name, entry_name) \
- entry_type _test_runner_list_2_##list_name_2_##entry_name __attribute__((__aligned__(4), unused, section(".test_runner_list_2_"#list_name"_2_"#entry_name)))
-
-#define RUNNER_DECLARE_TEST(test_name) \
- void test_name(void);\
- list_entry(struct test_fn, test_list, test_name) = { .name = #test_name, .file = __FILE__, .line = __LINE__, .fn = test_name}; \
- void test_name(void)
-
-struct test_fn {
- const char *name;
- const char *file;
- int line;
- void (*fn)();
-};
-
diff --git a/unity-test-runner b/unity-test-runner
new file mode 160000
+Subproject 1c1b4e3b6c95169ac05aa4831870a1a5949b248