Blame


1 a07c01e0 2022-11-08 thomas REGRESS_TARGETS=test_repo_read test_repo_write test_repo_write_empty
2 f2900386 2022-10-31 thomas NOOBJ=Yes
3 f2900386 2022-10-31 thomas
4 f2900386 2022-10-31 thomas .PHONY: ensure_root prepare_test_repo check_test_repo start_gotd
5 f2900386 2022-10-31 thomas
6 f2900386 2022-10-31 thomas GOTD_TEST_ROOT=/tmp
7 f2900386 2022-10-31 thomas GOTD_DEVUSER?=gotdev
8 a0934206 2022-10-31 thomas GOTD_DEVUSER_HOME!=userinfo $(GOTD_DEVUSER) | awk '/^dir/ {print $$2}'
9 f2900386 2022-10-31 thomas GOTD_TEST_REPO!?=mktemp -d "$(GOTD_TEST_ROOT)/gotd-test-repo-XXXXXXXXX"
10 f2900386 2022-10-31 thomas GOTD_TEST_REPO_URL=ssh://${GOTD_DEVUSER}@127.0.0.1/test-repo
11 f2900386 2022-10-31 thomas
12 f2900386 2022-10-31 thomas GOTD_TEST_USER?=${LOGNAME}
13 a0934206 2022-10-31 thomas GOTD_TEST_USER_HOME!=userinfo $(GOTD_TEST_USER) | awk '/^dir/ {print $$2}'
14 f2900386 2022-10-31 thomas
15 f2900386 2022-10-31 thomas # gotd.conf parameters
16 f2900386 2022-10-31 thomas GOTD_USER?=got
17 f2900386 2022-10-31 thomas GOTD_GROUP?=gotsh
18 f2900386 2022-10-31 thomas GOTD_SOCK=${GOTD_DEVUSER_HOME}/gotd.sock
19 f2900386 2022-10-31 thomas
20 f2900386 2022-10-31 thomas GOTD_START_CMD=../../gotd/obj/gotd -vv -f $(PWD)/gotd.conf
21 f2900386 2022-10-31 thomas GOTD_STOP_CMD=../../gotctl/obj/gotctl -f $(GOTD_SOCK) stop
22 f2900386 2022-10-31 thomas GOTD_TRAP=trap "$(GOTD_STOP_CMD)" HUP INT QUIT PIPE TERM
23 f2900386 2022-10-31 thomas
24 f2900386 2022-10-31 thomas GOTD_TEST_ENV=GOTD_TEST_ROOT=$(GOTD_TEST_ROOT) \
25 f2900386 2022-10-31 thomas GOTD_TEST_REPO_URL=$(GOTD_TEST_REPO_URL) \
26 f2900386 2022-10-31 thomas GOTD_TEST_REPO=$(GOTD_TEST_REPO) \
27 f2900386 2022-10-31 thomas GOTD_SOCK=$(GOTD_SOCK) \
28 a07c01e0 2022-11-08 thomas GOTD_DEVUSER=$(GOTD_DEVUSER) \
29 f2900386 2022-10-31 thomas HOME=$(GOTD_TEST_USER_HOME) \
30 f2900386 2022-10-31 thomas PATH=$(GOTD_TEST_USER_HOME)/bin:$(PATH)
31 f2900386 2022-10-31 thomas
32 f2900386 2022-10-31 thomas ensure_root:
33 f2900386 2022-10-31 thomas @if [[ `id -u` -ne 0 ]]; then \
34 f2900386 2022-10-31 thomas echo gotd test suite must be run by root >&2; \
35 f2900386 2022-10-31 thomas false; \
36 f2900386 2022-10-31 thomas fi
37 f2900386 2022-10-31 thomas
38 f2900386 2022-10-31 thomas start_gotd: ensure_root
39 f2900386 2022-10-31 thomas @echo 'unix_socket "$(GOTD_SOCK)"' > $(PWD)/gotd.conf
40 f2900386 2022-10-31 thomas @echo "unix_group $(GOTD_GROUP)" >> $(PWD)/gotd.conf
41 f2900386 2022-10-31 thomas @echo "user $(GOTD_USER)" >> $(PWD)/gotd.conf
42 f2900386 2022-10-31 thomas @echo 'repository "test-repo" {' >> $(PWD)/gotd.conf
43 f2900386 2022-10-31 thomas @echo ' path "$(GOTD_TEST_REPO)"' >> $(PWD)/gotd.conf
44 f2900386 2022-10-31 thomas @echo "}" >> $(PWD)/gotd.conf
45 f2900386 2022-10-31 thomas @$(GOTD_TRAP); $(GOTD_START_CMD)
46 f2900386 2022-10-31 thomas @$(GOTD_TRAP); sleep .5
47 f2900386 2022-10-31 thomas
48 f2900386 2022-10-31 thomas prepare_test_repo: ensure_root
49 f2900386 2022-10-31 thomas @chown ${GOTD_USER} "${GOTD_TEST_REPO}"
50 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./prepare_test_repo.sh'
51 f2900386 2022-10-31 thomas
52 a07c01e0 2022-11-08 thomas prepare_test_repo_empty: ensure_root
53 a07c01e0 2022-11-08 thomas @chown ${GOTD_USER} "${GOTD_TEST_REPO}"
54 a07c01e0 2022-11-08 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./prepare_test_repo.sh 1'
55 a07c01e0 2022-11-08 thomas
56 f2900386 2022-10-31 thomas test_repo_read: prepare_test_repo start_gotd
57 f2900386 2022-10-31 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
58 f2900386 2022-10-31 thomas 'env $(GOTD_TEST_ENV) sh ./repo_read.sh'
59 f2900386 2022-10-31 thomas @$(GOTD_STOP_CMD) 2>/dev/null
60 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
61 f2900386 2022-10-31 thomas
62 f2900386 2022-10-31 thomas test_repo_write: prepare_test_repo start_gotd
63 f2900386 2022-10-31 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
64 f2900386 2022-10-31 thomas 'env $(GOTD_TEST_ENV) sh ./repo_write.sh'
65 f2900386 2022-10-31 thomas @$(GOTD_STOP_CMD) 2>/dev/null
66 f2900386 2022-10-31 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
67 a07c01e0 2022-11-08 thomas
68 a07c01e0 2022-11-08 thomas test_repo_write_empty: prepare_test_repo_empty start_gotd
69 a07c01e0 2022-11-08 thomas @-$(GOTD_TRAP); su ${GOTD_TEST_USER} -c \
70 a07c01e0 2022-11-08 thomas 'env $(GOTD_TEST_ENV) sh ./repo_write_empty.sh'
71 a07c01e0 2022-11-08 thomas @$(GOTD_STOP_CMD) 2>/dev/null
72 a07c01e0 2022-11-08 thomas @su -m ${GOTD_USER} -c 'env $(GOTD_TEST_ENV) sh ./check_test_repo.sh'
73 f2900386 2022-10-31 thomas
74 f2900386 2022-10-31 thomas .include <bsd.regress.mk>