Blame


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