diff options
Diffstat (limited to 'tests/unit/Makefile')
| -rw-r--r-- | tests/unit/Makefile | 66 |
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 @@ | |||
| 1 | REPO_ROOT := ../.. | ||
| 2 | SECP256K1_SRC := $(REPO_ROOT)/nucula_src/components/secp256k1/libsecp256k1 | ||
| 3 | SECP256K1_INC := $(SECP256K1_SRC)/include | ||
| 4 | SECP256K1_PRIV_INC := $(SECP256K1_SRC)/src | ||
| 5 | SECP256K1_CFG := $(REPO_ROOT)/nucula_src/components/secp256k1 | ||
| 6 | CJSON_SRC := $(REPO_ROOT)/../esp/esp-idf/components/json/cJSON | ||
| 7 | |||
| 8 | CC := gcc | ||
| 9 | CFLAGS := -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 | |||
| 20 | LDFLAGS := -lmbedcrypto -lcjson | ||
| 21 | |||
| 22 | SECP256K1_OBJ := secp256k1.o precomputed_ecmult.o precomputed_ecmult_gen.o | ||
| 23 | |||
| 24 | TESTS := test_geohash test_identity test_nostr_event test_cashu test_session | ||
| 25 | |||
| 26 | .PHONY: all test clean $(TESTS) | ||
| 27 | |||
| 28 | all: test | ||
| 29 | |||
| 30 | test: $(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 | |||
| 50 | test_geohash: test_geohash.c $(REPO_ROOT)/main/geohash.c | ||
| 51 | $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) | ||
| 52 | |||
| 53 | test_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 | |||
| 56 | test_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 | |||
| 59 | test_cashu: test_cashu.c $(REPO_ROOT)/main/cashu.c | ||
| 60 | $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS) | ||
| 61 | |||
| 62 | test_session: test_session.c $(REPO_ROOT)/main/session.c | ||
| 63 | $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/session.c -o $@ $(LDFLAGS) | ||
| 64 | |||
| 65 | clean: | ||
| 66 | rm -f $(TESTS) $(SECP256K1_OBJ) | ||