summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-10-16 14:11:28 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-10-16 14:11:36 -0400
commitfb575049567ba037cf30f43d99a67fd1981b59a4 (patch)
tree38d36f7541e576355f33b44c8f2677b42f4e2a9f
parent6d53452ebc24287a72eedb9a2cc3f9e21c55362c (diff)
pke-at-test: first-pass using pktst
-rw-r--r--Makefile19
-rw-r--r--tests/pke-at-test-dummy.cpp42
-rw-r--r--tests/pke-at-test-dummy.h8
-rw-r--r--tests/pke-at-test-main.cpp18
4 files changed, 82 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index edf856e..15ca077 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,9 @@ PROJ=pke-at
-include config.mk
+.PHONY: default
+default: options .WAIT bin/pke-at bin/pke-at-test
+
FLAGS_DEBUG = -O0 -g -DDEBUG
FLAGS_RELEASE_DEBUG = -O2 -g -DDEBUG
FLAGS_RELEASE = -O2 -s -DNDEBUG
@@ -58,9 +61,6 @@ $(foreach f,$(FILES_BIN_SAFE), \
) \
)
-.PHONY: default
-default: options .WAIT bin/pke-at
-
.PHONY: prepare
prepare: ## Set up the current directory to build
mkdir -p bin
@@ -77,9 +77,13 @@ options: prepare .WAIT
@echo "CXX = $(CXX)"
obj/pke-at-storage-sql.o : $(FILES_BIN_GCH)
-obj/%.o : src/%.c | prepare
+obj/%.o : src/%.c | prepare
$(cc-command)
-obj/%.o : src/%.cpp | prepare
+obj/%.o : src/%.cpp | prepare
+ $(cxx-command)
+obj/%.o : tests/%.c | prepare
+ $(cc-command)
+obj/%.o : tests/%.cpp | prepare
$(cxx-command)
bin/pke-at: ## Builds the pke-at executable
@@ -92,6 +96,11 @@ bin/pke-at: obj/pke-at-storage-sql.o
bin/pke-at: obj/pke-at.o
$(CXX) -v -std=c++23 $(BUILD_MODE_FLAGS) $(INCS) -Wl,--whole-archive $^ $(LDFLAGS) -Wl,--no-whole-archive $(CXXFLAGS) -o $@
+bin/pke-at-test: ## Builds the pke-at-test executable
+bin/pke-at-test: obj/pke-at-test-dummy.o
+bin/pke-at-test: obj/pke-at-test-main.o
+ $(CXX) -v -std=c++23 $(BUILD_MODE_FLAGS) $(INCS) -Wl,--whole-archive $^ $(LDFLAGS) -Wl,--no-whole-archive $(CXXFLAGS) -o $@
+
.PHONY: clean
clean:
rm -rf bin
diff --git a/tests/pke-at-test-dummy.cpp b/tests/pke-at-test-dummy.cpp
new file mode 100644
index 0000000..341aba5
--- /dev/null
+++ b/tests/pke-at-test-dummy.cpp
@@ -0,0 +1,42 @@
+
+#include "./pke-at-test-dummy.h"
+#include "pke/pk.h"
+
+int dummy_test_001() {
+ PK_TEST_ASSERT_EQ_RET(14, 9 + 5);
+ return 0;
+}
+
+int dummy_test_002() {
+ // PK_TEST_ASSERT_EQ_RET(15, 9 + 5);
+ PK_TEST_ASSERT_EQ_RET(14, 9 + 5);
+ return 0;
+}
+
+struct pk_test_group *pke_at_test_get_dummy() {
+ static pk_test_group g{};
+
+ static const unsigned char n_tests = 2;
+ static pk_test tests[n_tests] = {
+ {
+ .title = "dummy_test_001",
+ .func = dummy_test_001,
+ .expected_result = 0,
+ },
+ {
+ .title = "dummy_test_002",
+ .func = dummy_test_002,
+ .expected_result = 0,
+ },
+ };
+
+ g.title = "dummy-tests";
+ g.group_setup = nullptr;
+ g.group_teardown = nullptr;
+ g.test_setup = nullptr;
+ g.test_teardown = nullptr;
+ g.tests = tests;
+ g.n_tests = n_tests;
+
+ return &g;
+}
diff --git a/tests/pke-at-test-dummy.h b/tests/pke-at-test-dummy.h
new file mode 100644
index 0000000..ebd887d
--- /dev/null
+++ b/tests/pke-at-test-dummy.h
@@ -0,0 +1,8 @@
+#ifndef PKE_AT_PKE_AT_TEST_DUMMY_H
+#define PKE_AT_PKE_AT_TEST_DUMMY_H
+
+#include <pke/pk.h>
+
+struct pk_test_group *pke_at_test_get_dummy();
+
+#endif /* PKE_AT_PKE_AT_TEST_DUMMY_H */
diff --git a/tests/pke-at-test-main.cpp b/tests/pke-at-test-main.cpp
new file mode 100644
index 0000000..367bbf4
--- /dev/null
+++ b/tests/pke-at-test-main.cpp
@@ -0,0 +1,18 @@
+
+#include "./pke-at-test-dummy.h"
+
+#include <pke/pk.h>
+
+int main(int argc, char *argv[])
+{
+ (void)argc;
+ (void)argv;
+
+ pk_test_group_get *fns[] = {
+ pke_at_test_get_dummy
+ };
+
+ pk_test_run_test_groups(fns, 1);
+
+ return 0;
+}