Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/fs Move tests psshfs from fs/puffs to fs/psshfs. The ...
details: https://anonhg.NetBSD.org/src/rev/593bd831716a
branches: trunk
changeset: 756082:593bd831716a
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Jul 06 14:06:21 2010 +0000
description:
Move tests psshfs from fs/puffs to fs/psshfs. The former is going
to be populated by tests which actually test puffs soon.
jmmv ok
diffstat:
tests/fs/Makefile | 4 +-
tests/fs/psshfs/Atffile | 6 +
tests/fs/psshfs/Makefile | 18 +++
tests/fs/psshfs/h_have_puffs.c | 58 +++++++++++
tests/fs/psshfs/ssh_config.in | 14 ++
tests/fs/psshfs/ssh_host_key | 15 ++
tests/fs/psshfs/ssh_host_key.pub | 1 +
tests/fs/psshfs/sshd_config.in | 40 +++++++
tests/fs/psshfs/t_psshfs.sh | 205 +++++++++++++++++++++++++++++++++++++++
tests/fs/puffs/Makefile | 18 ---
tests/fs/puffs/h_have_puffs.c | 58 -----------
tests/fs/puffs/ssh_config.in | 14 --
tests/fs/puffs/ssh_host_key | 15 --
tests/fs/puffs/ssh_host_key.pub | 1 -
tests/fs/puffs/sshd_config.in | 40 -------
tests/fs/puffs/t_psshfs.sh | 205 ---------------------------------------
16 files changed, 359 insertions(+), 353 deletions(-)
diffs (truncated from 784 to 300 lines):
diff -r b66709458a51 -r 593bd831716a tests/fs/Makefile
--- a/tests/fs/Makefile Tue Jul 06 13:56:40 2010 +0000
+++ b/tests/fs/Makefile Tue Jul 06 14:06:21 2010 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.12 2010/07/05 12:53:58 njoly Exp $
+# $NetBSD: Makefile,v 1.13 2010/07/06 14:06:21 pooka Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/fs
-SUBDIR+= ffs kernfs lfs msdosfs nullfs ptyfs puffs tmpfs umapfs union
+SUBDIR+= ffs kernfs lfs msdosfs nullfs psshfs ptyfs tmpfs umapfs union
SUBDIR+= vfs
FILES= h_funcs.subr
diff -r b66709458a51 -r 593bd831716a tests/fs/psshfs/Atffile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/psshfs/Atffile Tue Jul 06 14:06:21 2010 +0000
@@ -0,0 +1,6 @@
+Content-Type: application/X-atf-atffile; version="1"
+X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2010/07/06 14:06:22 pooka Exp $"
+
+prop: test-suite = "NetBSD"
+
+tp-glob: t_*
diff -r b66709458a51 -r 593bd831716a tests/fs/psshfs/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/psshfs/Makefile Tue Jul 06 14:06:21 2010 +0000
@@ -0,0 +1,18 @@
+# $NetBSD: Makefile,v 1.1 2010/07/06 14:06:22 pooka Exp $
+
+TESTSDIR= ${TESTSBASE}/fs/puffs
+
+PROGS= h_have_puffs
+SRCS.h_have_puffs= h_have_puffs.c
+MAN.h_have_puffs= # empty
+BINDIR.h_have_puffs= ${TESTSDIR}
+
+TESTS_SH= t_psshfs
+
+FILESDIR= ${TESTSDIR}
+FILES= ssh_config.in
+FILES+= ssh_host_key
+FILES+= ssh_host_key.pub
+FILES+= sshd_config.in
+
+.include <bsd.test.mk>
diff -r b66709458a51 -r 593bd831716a tests/fs/psshfs/h_have_puffs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/psshfs/h_have_puffs.c Tue Jul 06 14:06:21 2010 +0000
@@ -0,0 +1,58 @@
+/* $NetBSD: h_have_puffs.c,v 1.1 2010/07/06 14:06:22 pooka Exp $ */
+/*
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+ int exitcode, fd;
+
+ fd = open("/dev/puffs", O_RDWR);
+ if (fd != -1) {
+ printf("yes\n");
+ close(fd);
+ exitcode = EXIT_SUCCESS;
+ } else {
+ if (errno == ENXIO) {
+ printf("enxio\n");
+ exitcode = EXIT_SUCCESS;
+ } else if (errno == EACCES) {
+ printf("eacces\n");
+ exitcode = EXIT_SUCCESS;
+ } else {
+ printf("failed\n");
+ exitcode = EXIT_FAILURE;
+ }
+ }
+
+ return exitcode;
+}
diff -r b66709458a51 -r 593bd831716a tests/fs/psshfs/ssh_config.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/psshfs/ssh_config.in Tue Jul 06 14:06:21 2010 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: ssh_config.in,v 1.1 2010/07/06 14:06:22 pooka Exp $
+
+# Basic settings.
+Port 10000
+Protocol 2
+
+# The temporary key used for login.
+IdentityFile @WORKDIR@/ssh_user_key
+
+# Prevent the client from complaining about unknown host keys.
+GlobalKnownHostsFile @WORKDIR@/known_hosts
+
+# Do not attempt password authentication in case keys fail.
+IdentitiesOnly yes
diff -r b66709458a51 -r 593bd831716a tests/fs/psshfs/ssh_host_key
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/psshfs/ssh_host_key Tue Jul 06 14:06:21 2010 +0000
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQDJnMpSG1lGmApk8F7ZH7TGtjjP/WUs+vqHyFsyS2lilJzereen
+a/ME6S0d0HTOeCdKldjbtDpfNXbh+XnJMlJMEgEs4Mg1jluuEV0GOJoMt7cGzku2
+gAYGx++2+wqYw6Y+M8Tb1M4AO+PcxD/3BkdUyIKO63v6STl2VQn1BzsTQwIBIwKB
+gAuFTWPHDGpvFols0jhK9GMgWwSSIwnidLdNRwowMehgQ3pwVmFWoCwqlN0h2sn4
+PMJu9nL0WxtiJAzprzARgQuPI25t9LiKTF7scC/cNUiHPplUjvoDXA9ccY1eIf4R
+e6wwZz1jfCWen0eRsvMyoYvFmEH8hILAk1bY9heymOGLAkEA/WhC49n+gtloVMow
+iKQOO6+u3ouxTOTQ3sV2wCaLaO2pEbHP2//5SlUJLp6QrjC7bg9Kr+f56+zT2he9
+f6GCwwJBAMus3XizmZdJyJLnkCJRiT0/3Kf57fhWKRdnFkuRLyjET9MEWavRdJmr
+bx/lxmILi1iKwXiFEDM6MqYfmNImJYECQQCtw9YYlXtSaTGZOi/oqwJyEhGCqO6b
+II85q/moVPHhjQY4BOZNttbT4on0FPV+wlSjPa+OkHDcSp/mAaaDZ2+bAkEAujel
+6rLVkaKLfv+ZuPoXE22WivMityo0Mqdk12ArHfVQS+a4YpOdzlOYzLTSosi56o19
+sAShGOTAl+Jf1hQ/iwJAKpPviX5w292H/m5T0m4l0NRdQ3pRujOLMSVmY+/HFZTW
+GJMYLr1eBKNfLsKzJgB88GzuF2O/O8hNi3XSiOP+9w==
+-----END RSA PRIVATE KEY-----
diff -r b66709458a51 -r 593bd831716a tests/fs/psshfs/ssh_host_key.pub
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/psshfs/ssh_host_key.pub Tue Jul 06 14:06:21 2010 +0000
@@ -0,0 +1,1 @@
+ssh-rsa
AAAAB3NzaC1yc2EAAAABIwAAAIEAyZzKUhtZRpgKZPBe2R+0xrY4z/1lLPr6h8hbMktpYpSc3q3np2vzBOktHdB0zngnSpXY27Q6XzV24fl5yTJSTBIBLODINY5brhFdBjiaDLe3Bs5LtoAGBsfvtvsKmMOmPjPE29TOADvj3MQ/9wZHVMiCjut7+kk5dlUJ9Qc7E0M=
test%test.example.net@localhost
diff -r b66709458a51 -r 593bd831716a tests/fs/psshfs/sshd_config.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/psshfs/sshd_config.in Tue Jul 06 14:06:21 2010 +0000
@@ -0,0 +1,40 @@
+# $NetBSD: sshd_config.in,v 1.1 2010/07/06 14:06:22 pooka Exp $
+
+# Basic settings.
+Port 10000
+Protocol 2
+
+# Provide information to the user in case something goes wrong.
+LogLevel DEBUG1
+
+# The host key. It lives in the work directory because we need to set
+# very strict permissions on it and cannot modify the copy on the source
+# directory.
+HostKey @WORKDIR@/ssh_host_key
+
+# The authorized keys file we set up during the test to allow the client
+# to safely log in. We need to disable strict modes because ATF_WORKDIR
+# usually lives in /tmp, which has 1777 permissions and are not liked by
+# sshd.
+AuthorizedKeysFile @WORKDIR@/authorized_keys
+StrictModes no
+
+# Some settings to allow user runs of sshd.
+PidFile @WORKDIR@/sshd.pid.2
+Subsystem sftp @WORKDIR@/sftp-server
+UsePam no
+UsePrivilegeSeparation no
+
+# The root user should also be able to run the tests.
+PermitRootLogin yes
+
+# Be restrictive about access to the temporary server. Only allow key-based
+# authentication.
+ChallengeResponseAuthentication no
+GSSAPIAuthentication no
+HostbasedAuthentication no
+KerberosAuthentication no
+MaxAuthTries 1
+MaxStartups 1
+PasswordAuthentication no
+PubkeyAuthentication yes
diff -r b66709458a51 -r 593bd831716a tests/fs/psshfs/t_psshfs.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/psshfs/t_psshfs.sh Tue Jul 06 14:06:21 2010 +0000
@@ -0,0 +1,205 @@
+# $NetBSD: t_psshfs.sh,v 1.1 2010/07/06 14:06:22 pooka Exp $
+#
+# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+# -------------------------------------------------------------------------
+# Auxiliary functions.
+# -------------------------------------------------------------------------
+
+#
+# Skips the calling test case if puffs is not supported in the kernel
+# or if the calling user does not have the necessary permissions to mount
+# file systems.
+#
+require_puffs() {
+ case "$($(atf_get_srcdir)/h_have_puffs)" in
+ eacces)
+ atf_skip "Cannot open /dev/puffs for read/write access"
+ ;;
+ enxio)
+ atf_skip "puffs support not built into the kernel"
+ ;;
+ failed)
+ atf_skip "Unknown error trying to access /dev/puffs"
+ ;;
+ yes)
+ ;;
+ *)
+ atf_fail "Unknown value returned by h_have_puffs"
+ ;;
+ esac
+
+ if [ $(id -u) -ne 0 -a $(sysctl -n vfs.generic.usermount) -eq 0 ]
+ then
+ atf_skip "Regular users cannot mount file systems" \
+ "(vfs.generic.usermount is set to 0)"
+ fi
+}
+
+#
+# Starts a SSH server and sets up the client to access it.
+# Authentication is allowed and done using an RSA key exclusively, which
+# is generated on the fly as part of the test case.
+# XXX: Ideally, all the tests in this test program should be able to share
+# the generated key, because creating it can be a very slow process on some
+# machines.
+#
+start_ssh() {
+ echo "Setting up SSH server configuration"
+ sed -e "s,@SRCDIR@,$(atf_get_srcdir),g" -e "s,@WORKDIR@,$(pwd),g" \
+ $(atf_get_srcdir)/sshd_config.in >sshd_config || \
+ atf_fail "Failed to create sshd_config"
+ atf_check -s eq:0 -o empty -e empty cp /usr/libexec/sftp-server .
+ atf_check -s eq:0 -o empty -e empty \
+ cp $(atf_get_srcdir)/ssh_host_key .
+ atf_check -s eq:0 -o empty -e empty \
+ cp $(atf_get_srcdir)/ssh_host_key.pub .
+ atf_check -s eq:0 -o empty -e empty chmod 400 ssh_host_key
+ atf_check -s eq:0 -o empty -e empty chmod 444 ssh_host_key.pub
+
+ /usr/sbin/sshd -e -D -f ./sshd_config >sshd.log 2>&1 &
+ echo $! >sshd.pid
+ echo "SSH server started (pid $(cat sshd.pid))"
+
+ echo "Setting up SSH client configuration"
+ atf_check -s eq:0 -o empty -e empty \
+ ssh-keygen -f ssh_user_key -t rsa -b 1024 -N "" -q
+ atf_check -s eq:0 -o empty -e empty \
+ cp ssh_user_key.pub authorized_keys
+ echo "[localhost]:10000,[127.0.0.1]:10000,[::1]:10000" \
+ "$(cat $(atf_get_srcdir)/ssh_host_key.pub)" >known_hosts || \
+ atf_fail "Failed to create known_hosts"
+ atf_check -s eq:0 -o empty -e empty chmod 600 authorized_keys
+ sed -e "s,@SRCDIR@,$(atf_get_srcdir),g" -e "s,@WORKDIR@,$(pwd),g" \
+ $(atf_get_srcdir)/ssh_config.in >ssh_config || \
+ atf_fail "Failed to create ssh_config"
+}
+
Home |
Main Index |
Thread Index |
Old Index