From 396662bf7cc2e809de1bc762fa9fd1c9b5f7a7f5 Mon Sep 17 00:00:00 2001 From: Leon Krieg Date: Mon, 30 Sep 2024 17:20:11 +0200 Subject: [PATCH] Add file structure for automatic unit-testing --- Makefile | 5 +++++ docs/README.md | 11 +++++++++-- tests/bus/test-i2c.c | 1 + tests/bus/test-mosfet.c | 1 + tests/bus/test-pwm.c | 1 + tests/bus/test-usart.c | 1 + tests/common/test-math.c | 1 + tests/common/test-memory.c | 1 + tests/common/test-parser.c | 1 + tests/main.c | 10 ++++++++++ 10 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/bus/test-i2c.c create mode 100644 tests/bus/test-mosfet.c create mode 100644 tests/bus/test-pwm.c create mode 100644 tests/bus/test-usart.c create mode 100644 tests/common/test-math.c create mode 100644 tests/common/test-memory.c create mode 100644 tests/common/test-parser.c create mode 100644 tests/main.c diff --git a/Makefile b/Makefile index 03429fb..54c2073 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,11 @@ distclean: clean $(E) "[REM] $(BINDIR)" $(Q) $(RMR) $(BINDIR) +.PHONY: check +check: + $(E) "[CHK] Not implemented." + $(Q) true + .PHONY: listen listen: opt/tools/serial-listen $(E) "[RUN] $<" diff --git a/docs/README.md b/docs/README.md index 3c497f1..4434727 100644 --- a/docs/README.md +++ b/docs/README.md @@ -36,6 +36,13 @@ of these commands: make clean make distclean +Isolated unit tests allow you to verify all testable +components are behaving as expected. Please note that most +tests will be added later down the road, when the project +has reached a more mature state. + + make check + You can listen on the serial debug interface by running the command below. This will also initialize all optional submodules on first invocation. @@ -64,8 +71,8 @@ Issue the SET command to update the target settings: Settings are stored in EEPROM and are persistent until a new SET command is issued. Keywords are not case-sensitive. Both -arguments may contain a decimal point followed by a sequence -of digits. +arguments may contain an optional decimal point followed by +a sequence of digits. ### Webinterface Example diff --git a/tests/bus/test-i2c.c b/tests/bus/test-i2c.c new file mode 100644 index 0000000..68036ed --- /dev/null +++ b/tests/bus/test-i2c.c @@ -0,0 +1 @@ +static void *TODO; diff --git a/tests/bus/test-mosfet.c b/tests/bus/test-mosfet.c new file mode 100644 index 0000000..68036ed --- /dev/null +++ b/tests/bus/test-mosfet.c @@ -0,0 +1 @@ +static void *TODO; diff --git a/tests/bus/test-pwm.c b/tests/bus/test-pwm.c new file mode 100644 index 0000000..68036ed --- /dev/null +++ b/tests/bus/test-pwm.c @@ -0,0 +1 @@ +static void *TODO; diff --git a/tests/bus/test-usart.c b/tests/bus/test-usart.c new file mode 100644 index 0000000..68036ed --- /dev/null +++ b/tests/bus/test-usart.c @@ -0,0 +1 @@ +static void *TODO; diff --git a/tests/common/test-math.c b/tests/common/test-math.c new file mode 100644 index 0000000..68036ed --- /dev/null +++ b/tests/common/test-math.c @@ -0,0 +1 @@ +static void *TODO; diff --git a/tests/common/test-memory.c b/tests/common/test-memory.c new file mode 100644 index 0000000..68036ed --- /dev/null +++ b/tests/common/test-memory.c @@ -0,0 +1 @@ +static void *TODO; diff --git a/tests/common/test-parser.c b/tests/common/test-parser.c new file mode 100644 index 0000000..68036ed --- /dev/null +++ b/tests/common/test-parser.c @@ -0,0 +1 @@ +static void *TODO; diff --git a/tests/main.c b/tests/main.c new file mode 100644 index 0000000..b4fa8fe --- /dev/null +++ b/tests/main.c @@ -0,0 +1,10 @@ +// TODO: Automatic unit-testing. + +int main(void) +{ + // 1. Write unit-tests. + // 2. Run them. + // 3. Profit! + + return 0; +}