summaryrefslogtreecommitdiffstats
path: root/regress/libexec
diff options
context:
space:
mode:
authorjan <jan@openbsd.org>2019-12-22 07:43:32 +0000
committerjan <jan@openbsd.org>2019-12-22 07:43:32 +0000
commit3ed8d5540dd9a705dcaede2ca43bfe768e3a71e5 (patch)
tree29d583c19ca4573cf842cdee147afd97003934ff /regress/libexec
parenthave parseb64file be non-destructive, so we can write the (diff)
downloadwireguard-openbsd-3ed8d5540dd9a705dcaede2ca43bfe768e3a71e5.tar.xz
wireguard-openbsd-3ed8d5540dd9a705dcaede2ca43bfe768e3a71e5.zip
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.