commit 6b3c4186aca24812436ed72d08adce8149351cc8
parent 04d3eebaceb4f0938023d15f2a7c77ad50076f1c
Author: Jan Pobrislo <ccx@te2000.cz>
Date: Mon, 23 Dec 2024 17:10:01 +0000
Basic testing support using Greatest library
Diffstat:
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/Makefile b/src/Makefile
@@ -1,7 +1,7 @@
all: tools
.PHONY: all
-miniroon_tool_names:=read verify
+miniroon_tool_names:=read verify test
tools:=$(patsubst %,build/miniroon-%,$(miniroon_tool_names))
tools: $(tools)
@@ -18,6 +18,10 @@ clean:
rm -r $(tools) build
.PHONY: clean
+test: build/miniroon-test
+ ./build/miniroon-test -v
+.PHONY: test
+
## pattern rules:
%_perfhash.c %_perfhash.h: %_perfhash.txt ../genhash
diff --git a/src/cmd_test.c b/src/cmd_test.c
@@ -0,0 +1,29 @@
+#include <assert.h>
+
+#include "greatest.h"
+
+/* Declare a local suite. */
+SUITE(suite);
+
+
+TEST expect_equal(void) {
+ int i = 10;
+ ASSERT_EQ(10, i);
+ PASS();
+}
+
+/* Primary test suite. */
+SUITE(suite) {
+ RUN_TEST(expect_equal);
+}
+
+/* Add definitions that need to be in the test runner's main file. */
+GREATEST_MAIN_DEFS();
+
+int main(int argc, char **argv) {
+ GREATEST_MAIN_BEGIN(); /* command-line arguments, initialization. */
+
+ RUN_SUITE(suite);
+
+ GREATEST_MAIN_END(); /* display results */
+}