upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/unit/Makefile
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-17 01:31:49 +0530
committerYour Name <you@example.com>2026-05-17 01:31:49 +0530
commit347d29658959c7e4b368a15134c183f4ce7a25bc (patch)
tree362b3e40273e3c1435bdd0745de61006041bb803 /tests/unit/Makefile
parent4c47ae188b288e7d24bd9566ab3e6a6805d9484f (diff)
Testing infrastructure: AGENTS.md rules + unit test framework + geohash tests (11/11 pass)
- Add AGENTS.md: full project context + mandatory testing rules for AI sessions - Add tests/unit/ with host-compiled C unit test infrastructure - Clean stubs approach: ESP-IDF type stubs in tests/unit/stubs/, no source modifications - Fix geohash.c bit extraction bug (3-byte span) found by unit tests - test_geohash: 11/11 passing with reference vectors (Munich, NYC, origin, boundaries)
Diffstat (limited to 'tests/unit/Makefile')
-rw-r--r--tests/unit/Makefile66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/unit/Makefile b/tests/unit/Makefile
new file mode 100644
index 0000000..4adc720
--- /dev/null
+++ b/tests/unit/Makefile
@@ -0,0 +1,66 @@
1REPO_ROOT := ../..
2SECP256K1_SRC := $(REPO_ROOT)/nucula_src/components/secp256k1/libsecp256k1
3SECP256K1_INC := $(SECP256K1_SRC)/include
4SECP256K1_PRIV_INC := $(SECP256K1_SRC)/src
5SECP256K1_CFG := $(REPO_ROOT)/nucula_src/components/secp256k1
6CJSON_SRC := $(REPO_ROOT)/../esp/esp-idf/components/json/cJSON
7
8CC := gcc
9CFLAGS := -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-sign-compare \
10 -std=gnu17 -g -O0 \
11 -DTEST_HOST \
12 -DENABLE_MODULE_SCHNORRSIG=1 -DENABLE_MODULE_EXTRAKEYS=1 \
13 -DECMULT_WINDOW_SIZE=8 -DECMULT_GEN_PREC_BITS=4 \
14 -include stubs/esp_err.h \
15 -I stubs \
16 -I $(SECP256K1_INC) \
17 -I $(SECP256K1_CFG) \
18 -I /usr/include/cjson
19
20LDFLAGS := -lmbedcrypto -lcjson
21
22SECP256K1_OBJ := secp256k1.o precomputed_ecmult.o precomputed_ecmult_gen.o
23
24TESTS := test_geohash test_identity test_nostr_event test_cashu test_session
25
26.PHONY: all test clean $(TESTS)
27
28all: test
29
30test: $(TESTS)
31 @echo ""
32 @echo "=== Running all unit tests ==="
33 @failed=0; \
34 for t in $(TESTS); do \
35 echo ""; \
36 echo "--- $$t ---"; \
37 ./$$t || failed=$$((failed + 1)); \
38 done; \
39 echo ""; \
40 if [ $$failed -eq 0 ]; then \
41 echo "=== ALL UNIT TESTS PASSED ==="; \
42 else \
43 echo "=== $$failed test(s) FAILED ==="; \
44 exit 1; \
45 fi
46
47$(SECP256K1_OBJ): %.o: $(SECP256K1_SRC)/src/%.c
48 $(CC) $(CFLAGS) -I $(SECP256K1_PRIV_INC) -c $< -o $@
49
50test_geohash: test_geohash.c $(REPO_ROOT)/main/geohash.c
51 $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
52
53test_identity: test_identity.c $(REPO_ROOT)/main/identity.c $(SECP256K1_OBJ)
54 $(CC) $(CFLAGS) -I $(SECP256K1_PRIV_INC) $< $(REPO_ROOT)/main/identity.c $(SECP256K1_OBJ) -o $@ $(LDFLAGS)
55
56test_nostr_event: test_nostr_event.c $(REPO_ROOT)/main/nostr_event.c $(SECP256K1_OBJ)
57 $(CC) $(CFLAGS) -I $(SECP256K1_PRIV_INC) $< $(REPO_ROOT)/main/nostr_event.c $(SECP256K1_OBJ) -o $@ $(LDFLAGS)
58
59test_cashu: test_cashu.c $(REPO_ROOT)/main/cashu.c
60 $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS)
61
62test_session: test_session.c $(REPO_ROOT)/main/session.c
63 $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/session.c -o $@ $(LDFLAGS)
64
65clean:
66 rm -f $(TESTS) $(SECP256K1_OBJ)