summaryrefslogtreecommitdiff
path: root/regress/libexec
diff options
context:
space:
mode:
authorjan <jan@cvs.openbsd.org>2019-12-22 07:43:34 +0000
committerjan <jan@cvs.openbsd.org>2019-12-22 07:43:34 +0000
commitc1b2a3557be203fb5f4384700a22af10d3059645 (patch)
tree765da30f12ef48d2fedef5e7cc6be4b7af09323f /regress/libexec
parent9fb0c9b4e97aae9d85545977b2231e653b15ffc6 (diff)
Add regression test for ftpd(8).
OK bluhm@
Diffstat (limited to 'regress/libexec')
-rw-r--r--regress/libexec/Makefile3
-rw-r--r--regress/libexec/ftpd/Makefile53
-rw-r--r--regress/libexec/ftpd/README18
3 files changed, 73 insertions, 1 deletions
diff --git a/regress/libexec/Makefile b/regress/libexec/Makefile
index ed46c660f60..a1cd2b3d02e 100644
--- a/regress/libexec/Makefile
+++ b/regress/libexec/Makefile
@@ -1,7 +1,8 @@
-# $OpenBSD: Makefile,v 1.3 2003/12/26 14:13:26 miod Exp $
+# $OpenBSD: Makefile,v 1.4 2019/12/22 07:43:32 jan Exp $
.include <bsd.own.mk>
+SUBDIR+= ftpd
.if !defined(NOPIC)
SUBDIR+= ld.so
.endif
diff --git a/regress/libexec/ftpd/Makefile b/regress/libexec/ftpd/Makefile
new file mode 100644
index 00000000000..cf051dd8eb1
--- /dev/null
+++ b/regress/libexec/ftpd/Makefile
@@ -0,0 +1,53 @@
+# $OpenBSD: Makefile,v 1.1 2019/12/22 07:43:33 jan Exp $
+
+.PHONY: setup-ftpd
+
+REGRESS_TARGETS = run-ftpd-get
+REGRESS_TARGETS += run-ftpd-ls
+REGRESS_ROOT_TARGETS = ${REGRESS_TARGETS}
+REGRESS_CLEANUP = cleanup-ftpd
+REGRESS_SETUP = setup-ftpd
+CLEANFILES = ftpd.regress
+
+TCPSERVER = /usr/local/bin/tcpserver
+FTPD ?= /usr/libexec/ftpd
+
+.if ! (make(clean) || make(cleandir) || make(obj))
+FTPDIR != getent passwd ftp | cut -d: -f6
+.endif
+
+.if ! exists(${TCPSERVER})
+regress:
+ @echo package ucspi-tcp is required for this regress
+ @echo SKIPPED
+.endif
+
+setup-ftpd:
+ @echo '\n======== $@ ========'
+ ${SUDO} pkill tcpserver || true
+ ${SUDO} pkill ftpd || true
+ # start ftpd
+ ${SUDO} ${TCPSERVER} 127.0.0.1 21 ${KTRACE} ${FTPD} -A & \
+ timeout=$$(($$(date +%s) + 5)); \
+ while fstat -p $$! | ! grep -q 'tcp .* 127.0.0.1:21$$'; \
+ do test $$(date +%s) -lt $$timeout || exit 1; done
+ # prepare test files
+ ${SUDO} dd if=/dev/random of="${FTPDIR}/ftpd.regress" count=1 bs=1m
+ ${SUDO} chown ftp:ftp "${FTPDIR}/ftpd.regress"
+
+run-ftpd-get:
+ @echo '\n======== $@ ========'
+ ftp -a ftp://127.0.0.1/ftpd.regress
+ cmp ${FTPDIR}/ftpd.regress ftpd.regress
+ rm ftpd.regress
+
+run-ftpd-ls:
+ @echo '\n======== $@ ========'
+ echo ls | ftp -a 127.0.0.1 | grep -q 'ftpd.regress'
+
+cleanup-ftpd:
+ ${SUDO} pkill tcpserver || true
+ ${SUDO} pkill ftpd || true
+ ${SUDO} rm -f ${FTPDIR}/ftpd.regress
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ftpd/README b/regress/libexec/ftpd/README
new file mode 100644
index 00000000000..580d6673709
--- /dev/null
+++ b/regress/libexec/ftpd/README
@@ -0,0 +1,18 @@
+Run ftpd regression tests. The framework runs a client and an ftpd.
+
+SUDO=doas
+As ftpd needs root privileges, either run the tests as root or set
+this variable and run make as a regular user. Only the code that
+requires it is run as root.
+
+KTRACE=ktrace
+Set this variable if you want a ktrace output from ftpd. Note that
+ktrace is invoked after SUDO as SUDO would disable it.
+
+FTPD=/usr/libexec/ftpd
+Start an alternative ftpd program that is not in the path.
+
+Requirements:
+
+The test needs the port net/ucspi-tcp and the user "ftp" for anonymous
+logins.