From 1d1df66413f858a744ae53a9210303cd5d1ddba1 Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 16 Jun 2007 02:04:44 +0000 Subject: MFp4: Add regression tests for tmpfs. Obtained from: NetBSD via p4 Submitted by: Howard Su --- tools/regression/tmpfs/Makefile | 39 +++++ tools/regression/tmpfs/h_funcs.subr | 191 +++++++++++++++++++++++ tools/regression/tmpfs/h_tools.c | 283 +++++++++++++++++++++++++++++++++++ tools/regression/tmpfs/t_create | 98 ++++++++++++ tools/regression/tmpfs/t_dots | 63 ++++++++ tools/regression/tmpfs/t_exec | 62 ++++++++ tools/regression/tmpfs/t_id_gen | 75 ++++++++++ tools/regression/tmpfs/t_link | 108 +++++++++++++ tools/regression/tmpfs/t_mkdir | 110 ++++++++++++++ tools/regression/tmpfs/t_mount | 85 +++++++++++ tools/regression/tmpfs/t_pipes | 62 ++++++++ tools/regression/tmpfs/t_read_write | 81 ++++++++++ tools/regression/tmpfs/t_readdir | 93 ++++++++++++ tools/regression/tmpfs/t_remove | 83 ++++++++++ tools/regression/tmpfs/t_rename | 150 +++++++++++++++++++ tools/regression/tmpfs/t_rmdir | 114 ++++++++++++++ tools/regression/tmpfs/t_setattr | 115 ++++++++++++++ tools/regression/tmpfs/t_sizes | 99 ++++++++++++ tools/regression/tmpfs/t_sockets | 63 ++++++++ tools/regression/tmpfs/t_statvfs | 62 ++++++++ tools/regression/tmpfs/t_symlink | 88 +++++++++++ tools/regression/tmpfs/t_times | 114 ++++++++++++++ tools/regression/tmpfs/t_trail_slash | 61 ++++++++ tools/regression/tmpfs/t_truncate | 64 ++++++++ tools/regression/tmpfs/t_vnd | 95 ++++++++++++ tools/regression/tmpfs/t_vnode_leak | 63 ++++++++ 26 files changed, 2521 insertions(+) create mode 100644 tools/regression/tmpfs/Makefile create mode 100644 tools/regression/tmpfs/h_funcs.subr create mode 100644 tools/regression/tmpfs/h_tools.c create mode 100644 tools/regression/tmpfs/t_create create mode 100644 tools/regression/tmpfs/t_dots create mode 100644 tools/regression/tmpfs/t_exec create mode 100644 tools/regression/tmpfs/t_id_gen create mode 100644 tools/regression/tmpfs/t_link create mode 100644 tools/regression/tmpfs/t_mkdir create mode 100644 tools/regression/tmpfs/t_mount create mode 100644 tools/regression/tmpfs/t_pipes create mode 100644 tools/regression/tmpfs/t_read_write create mode 100644 tools/regression/tmpfs/t_readdir create mode 100644 tools/regression/tmpfs/t_remove create mode 100644 tools/regression/tmpfs/t_rename create mode 100644 tools/regression/tmpfs/t_rmdir create mode 100644 tools/regression/tmpfs/t_setattr create mode 100644 tools/regression/tmpfs/t_sizes create mode 100644 tools/regression/tmpfs/t_sockets create mode 100644 tools/regression/tmpfs/t_statvfs create mode 100644 tools/regression/tmpfs/t_symlink create mode 100644 tools/regression/tmpfs/t_times create mode 100644 tools/regression/tmpfs/t_trail_slash create mode 100644 tools/regression/tmpfs/t_truncate create mode 100644 tools/regression/tmpfs/t_vnd create mode 100644 tools/regression/tmpfs/t_vnode_leak (limited to 'tools') diff --git a/tools/regression/tmpfs/Makefile b/tools/regression/tmpfs/Makefile new file mode 100644 index 0000000..7f21fa7 --- /dev/null +++ b/tools/regression/tmpfs/Makefile @@ -0,0 +1,39 @@ +# $NetBSD: Makefile,v 1.4 2006/11/09 15:25:37 jmmv Exp $ +# $FreeBSD$ + +tests= t_mount +tests+= t_statvfs +tests+= t_mkdir +tests+= t_vnode_leak +tests+= t_setattr +tests+= t_rmdir +tests+= t_id_gen +tests+= t_trail_slash +tests+= t_dots +tests+= t_create +tests+= t_remove +tests+= t_link +tests+= t_rename +tests+= t_read_write +tests+= t_exec +tests+= t_truncate +tests+= t_sizes +tests+= t_times +tests+= t_symlink +tests+= t_pipes +tests+= t_sockets +tests+= t_readdir +tests+= t_vnd + +regress: ${tests} +.for t in ${tests} + @SUBRDIR=${.CURDIR} /bin/sh ${.CURDIR}/${t} ${TEST_ARGS} +.endfor + +PROG= h_tools +NO_MAN= # defined +WARNS= 4 + +t_sizes t_sockets t_statvfs: h_tools + +.include diff --git a/tools/regression/tmpfs/h_funcs.subr b/tools/regression/tmpfs/h_funcs.subr new file mode 100644 index 0000000..22c9de3 --- /dev/null +++ b/tools/regression/tmpfs/h_funcs.subr @@ -0,0 +1,191 @@ +#!/bin/sh +# +# $NetBSD: h_funcs.subr,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Helper functions for tests written in shell script. +# + +Prog_Name=${0##*/} +Src_Dir=$(pwd) +Unprived_User= +Verbose=2 +Work_Dir=$(pwd)/tmp + +# ------------------------------------------------------------------------- + +# die +# +# Called by tests when a command fails unexpectedly. Terminates +# execution and tries to clean up the mount point. +# +die() { + if [ -d ${Work_Dir} ]; then + cd ${Src_Dir} + umount ${Work_Dir} + rmdir ${Work_Dir} + fi + [ ${Verbose} -eq 2 ] && err "Test ended unexpectedly" + [ ${Verbose} -eq 1 ] && echo " failed." + exit 1 +} + +# ------------------------------------------------------------------------- + +# err message +# +# Shows the given error message and terminates the program. +# +err() { + echo "${Prog_Name}: $*" 1>&2 + exit 1 +} + +# ------------------------------------------------------------------------- + +# test_mount [args] +# +# Mounts tmpfs over ${Work_Dir} and changes the current directory +# to the mount point. Optional arguments may be passed to the +# mount command. +# +test_mount() { + mkdir ${Work_Dir} || die + if [ $# -gt 0 ]; then + mount -t tmpfs "$@" tmpfs ${Work_Dir} || die + else + mount -t tmpfs tmpfs ${Work_Dir} || die + fi + cd ${Work_Dir} +} + +# ------------------------------------------------------------------------- + +# test_name message +# +# Prints a message about what a test is going to do. +# +test_name() { + [ ${Verbose} -gt 1 ] && echo " $*..." +} + +# ------------------------------------------------------------------------- + +# test_unmount +# +# Unmounts the file system mounted by test_mount. +# +test_unmount() { + cd - + umount ${Work_Dir} || die + rmdir ${Work_Dir} || die +} + +# ------------------------------------------------------------------------- + +# kqueue_monitor expected_nevents file1 [.. fileN] +# +# Monitors the commands given through stdin (one per line) using +# kqueue and stores the events raised in a log that can be later +# verified with kqueue_check. +# +kqueue_monitor() { + nev=${1}; shift + test_name "Running kqueue-monitored commands and expecting" \ + "${nev} events" + ${Src_Dir}/h_tools kqueue ${*} >kqueue.log || return 1 + got=$(wc -l kqueue.log | awk '{ print $1 }') + test ${got} -eq ${nev} +} + +# ------------------------------------------------------------------------- + +# kqueue_check file event +# +# Checks if kqueue raised the given event when monitoring the +# given file. +# +kqueue_check() { + grep "^${1} - ${2}$" kqueue.log >/dev/null +} + +# ------------------------------------------------------------------------- + +main() { + local args + + [ $(id -un) = root ] || err "Must be run as root" + + args=$(getopt u:v:w: $*) + if [ $? -ne 0 ]; then + echo "Usage: ${Prog_Name} [-u unprived_user] [-v level] " \ + "[-w root_dir]" 1>&2 + return 1 + fi + set -- ${args} + while [ $# -gt 0 ]; do + case "$1" in + -u) + Unprived_User="$2"; shift + ;; + -v) + Verbose="$2"; shift + ;; + -w) + Work_Dir="$2"; shift + ;; + --) + shift; break + ;; + esac + shift + done + + [ ${Verbose} -eq 1 ] && echo -n "${Prog_Name}:" + [ ${Verbose} -eq 2 ] && echo "${Prog_Name}: Running tests" + test_run + [ ${Verbose} -eq 1 ] && echo " ok." + [ ${Verbose} -eq 2 ] && echo "${Prog_Name}: All tests were successful" + + return 0 +} + +main "$@" diff --git a/tools/regression/tmpfs/h_tools.c b/tools/regression/tmpfs/h_tools.c new file mode 100644 index 0000000..9d89401 --- /dev/null +++ b/tools/regression/tmpfs/h_tools.c @@ -0,0 +1,283 @@ +/* $NetBSD: h_tools.c,v 1.7 2006/11/09 16:20:06 jmmv Exp $ */ + +/*- + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julio M. Merino Vidal, developed as part of Google's Summer of Code + * 2005 program. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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. + * + * $FreeBSD$ + */ + +/* + * Helper tools for several tests. These are kept in a single file due + * to the limitations of bsd.prog.mk to build a single program in a + * given directory. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/* --------------------------------------------------------------------- */ + +static int getfh_main(int, char **); +static int kqueue_main(int, char **); +static int rename_main(int, char **); +static int sockets_main(int, char **); +static int statvfs_main(int, char **); + +/* --------------------------------------------------------------------- */ + +int +getfh_main(int argc, char **argv) +{ + int error; + fhandle_t fh; + + if (argc < 2) + return EXIT_FAILURE; + + error = getfh(argv[1], &fh); + if (error == 0) + err(EXIT_FAILURE, "can not getfh"); + + error = write(STDOUT_FILENO, &fh, sizeof(fh)); + if (error == -1) { + perror("write"); + return EXIT_FAILURE; + } + + return 0; +} + +/* --------------------------------------------------------------------- */ + +int +kqueue_main(int argc, char **argv) +{ + char *line; + int i, kq; + size_t len; + struct kevent *changes, event; + + if (argc < 2) + return EXIT_FAILURE; + + argc--; + argv++; + + changes = malloc(sizeof(struct kevent) * (argc - 1)); + if (changes == NULL) + errx(EXIT_FAILURE, "not enough memory"); + + for (i = 0; i < argc; i++) { + int fd; + + fd = open(argv[i], O_RDONLY); + if (fd == -1) + err(EXIT_FAILURE, "cannot open %s", argv[i]); + + EV_SET(&changes[i], fd, EVFILT_VNODE, + EV_ADD | EV_ENABLE | EV_ONESHOT, + NOTE_ATTRIB | NOTE_DELETE | NOTE_EXTEND | NOTE_LINK | + NOTE_RENAME | NOTE_REVOKE | NOTE_WRITE, + 0, 0); + } + + kq = kqueue(); + if (kq == -1) + err(EXIT_FAILURE, "kqueue"); + + while ((line = fgetln(stdin, &len)) != NULL) { + int ec, nev; + struct timespec to; + + to.tv_sec = 0; + to.tv_nsec = 100000; + + (void)kevent(kq, changes, argc, &event, 1, &to); + + assert(len > 0); + assert(line[len - 1] == '\n'); + line[len - 1] = '\0'; + ec = system(line); + if (ec != EXIT_SUCCESS) + errx(ec, "%s returned %d", line, ec); + + do { + nev = kevent(kq, changes, argc, &event, 1, &to); + if (nev == -1) + err(EXIT_FAILURE, "kevent"); + else if (nev > 0) { + for (i = 0; i < argc; i++) + if (event.ident == changes[i].ident) + break; + + if (event.fflags & NOTE_ATTRIB) + printf("%s - NOTE_ATTRIB\n", argv[i]); + if (event.fflags & NOTE_DELETE) + printf("%s - NOTE_DELETE\n", argv[i]); + if (event.fflags & NOTE_EXTEND) + printf("%s - NOTE_EXTEND\n", argv[i]); + if (event.fflags & NOTE_LINK) + printf("%s - NOTE_LINK\n", argv[i]); + if (event.fflags & NOTE_RENAME) + printf("%s - NOTE_RENAME\n", argv[i]); + if (event.fflags & NOTE_REVOKE) + printf("%s - NOTE_REVOKE\n", argv[i]); + if (event.fflags & NOTE_WRITE) + printf("%s - NOTE_WRITE\n", argv[i]); + } + } while (nev > 0); + } + + for (i = 0; i < argc; i++) + close(changes[i].ident); + free(changes); + + return EXIT_SUCCESS; +} + +/* --------------------------------------------------------------------- */ + +int +rename_main(int argc, char **argv) +{ + + if (argc < 3) + return EXIT_FAILURE; + + return rename(argv[1], argv[2]); +} + +/* --------------------------------------------------------------------- */ + +int +sockets_main(int argc, char **argv) +{ + int error, fd; + struct sockaddr_un addr; + + if (argc < 2) + return EXIT_FAILURE; + + fd = socket(PF_LOCAL, SOCK_STREAM, 0); + if (fd == -1) { + perror("socket"); + return EXIT_FAILURE; + } + + (void)strlcpy(addr.sun_path, argv[1], sizeof(addr.sun_path)); + addr.sun_family = PF_UNIX; + + error = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); + if (error == -1) { + perror("connect"); + return EXIT_FAILURE; + } + + close(fd); + + return EXIT_SUCCESS; +} + +/* --------------------------------------------------------------------- */ + +int +statvfs_main(int argc, char **argv) +{ + int error; + struct statfs buf; + + if (argc < 2) + return EXIT_FAILURE; + + memset(&buf, 0, sizeof(buf)); + buf.f_version = STATFS_VERSION; + error = statfs(argv[1], &buf); + if (error != 0) { + perror("statvfs"); + return EXIT_FAILURE; + } + + (void)printf("f_bsize=%llu\n", buf.f_bsize); + (void)printf("f_blocks=%llu\n", buf.f_blocks); + (void)printf("f_bfree=%llu\n", buf.f_bfree); + (void)printf("f_files=%llu\n", buf.f_files); + + return EXIT_SUCCESS; +} + +/* --------------------------------------------------------------------- */ + +int +main(int argc, char **argv) +{ + int error; + + if (argc < 2) + return EXIT_FAILURE; + + argc -= 1; + argv += 1; + + if (strcmp(argv[0], "getfh") == 0) + error = getfh_main(argc, argv); + else if (strcmp(argv[0], "kqueue") == 0) + error = kqueue_main(argc, argv); + else if (strcmp(argv[0], "rename") == 0) + error = rename_main(argc, argv); + else if (strcmp(argv[0], "sockets") == 0) + error = sockets_main(argc, argv); + else if (strcmp(argv[0], "statvfs") == 0) + error = statvfs_main(argc, argv); + else + error = EXIT_FAILURE; + + return error; +} diff --git a/tools/regression/tmpfs/t_create b/tools/regression/tmpfs/t_create new file mode 100644 index 0000000..39ea4f4 --- /dev/null +++ b/tools/regression/tmpfs/t_create @@ -0,0 +1,98 @@ +#!/bin/sh +# +# $NetBSD: t_create,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the create operation works. +# + +test_run() { + test_mount + + test_name "Files can be created" + umask 022 || die + test -f a && die + touch a || die + test -f a || die + test_name "New files get proper attributes" + eval $(stat -s . | sed -e 's|st_|dst_|g') + eval $(stat -s a) + test ${st_flags} -eq 0 || die + test ${st_size} -eq 0 || die + test ${st_uid} -eq $(id -u) || die + test ${st_gid} -eq ${dst_gid} || die + test ${st_mode} = 0100644 || die + + if [ -n "${Unprived_User}" ]; then + test_name "New files by users get proper attributes" + + mkdir b c || die + + chown ${Unprived_User}:0 b || die + eval $(stat -s b) + [ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die + [ ${st_gid} -eq 0 ] || die + + chown ${Unprived_User}:100 c || die + eval $(stat -s c) + [ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die + [ ${st_gid} -eq 100 ] || die + + su ${Unprived_User} -c 'touch b/a' + eval $(stat -s b/a) + [ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die + [ ${st_gid} -eq 0 ] || die + + su ${Unprived_User} -c 'touch c/a' + eval $(stat -s c/a) + [ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die + [ ${st_gid} -eq 100 ] || die + fi + + mkdir dir || die + echo 'touch dir/a' | kqueue_monitor 1 dir || die + test_name "Creating a file raises NOTE_WRITE on the parent directory" + kqueue_check dir NOTE_WRITE || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_dots b/tools/regression/tmpfs/t_dots new file mode 100644 index 0000000..80d721a --- /dev/null +++ b/tools/regression/tmpfs/t_dots @@ -0,0 +1,63 @@ +#!/bin/sh +# +# $NetBSD: t_dots,v 1.4 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that '.' and '..' lookups work. +# + +test_run() { + test_mount + + test_name "'.' and '..' entries of a directory work." + mkdir a + test -d ./a || die + test -d a/../a || die + + test_name "'.' and '..' entries of nested directories work." + mkdir a/b + test -d a/b/../b || die + test -d a/b/../../a || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_exec b/tools/regression/tmpfs/t_exec new file mode 100644 index 0000000..cb1e239 --- /dev/null +++ b/tools/regression/tmpfs/t_exec @@ -0,0 +1,62 @@ +#!/bin/sh +# +# $NetBSD: t_exec,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that binary files can be executed from within the file system +# (i.e., whether getpages works). +# + +test_run() { + test_mount + + test_name "Copy of existing binary program" + cp /bin/cp . || die + test_name "Data written is correct" + [ $(md5 cp | cut -d ' ' -f 4) = $(md5 /bin/cp | cut -d ' ' -f 4) ] || \ + die + test_name "Execution of binary program" + ./cp cp foo || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_id_gen b/tools/regression/tmpfs/t_id_gen new file mode 100644 index 0000000..c478330 --- /dev/null +++ b/tools/regression/tmpfs/t_id_gen @@ -0,0 +1,75 @@ +#!/bin/sh +# +# $NetBSD: t_id_gen,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that node identifiers and generation numbers are assigned +# correctly. +# + +test_run() { + test_mount + + test_name "Creation of directory" + mkdir a || die + test_name "Node ID should be 3" + eval $(stat -s a | sed -e 's|st_|ost_|g') || die + ofhsum=$(${Src_Dir}/h_tools getfh a | md5) || die + [ ${ost_ino} -eq 3 ] || die + + test_name "Deletion of directory" + rmdir a || die + + test_name "Creation of directory (reuse node)" + mkdir b || die + test_name "Node ID should be 3" + eval $(stat -s b) || die + fhsum=$(${Src_Dir}/h_tools getfh b | md5) || die + [ ${st_ino} -eq 3 ] || die + + #Failed Case + #test_name "File handle is different (thanks to generation)" + #[ ${ofhsum} != ${fhsum} ] || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_link b/tools/regression/tmpfs/t_link new file mode 100644 index 0000000..bf57ec5 --- /dev/null +++ b/tools/regression/tmpfs/t_link @@ -0,0 +1,108 @@ +#!/bin/sh +# +# $NetBSD: t_link,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the link operation works. +# + +test_run() { + test_mount + + test_name "Link operation works" + touch a || die + touch z || die + eval $(stat -s a | sed -e 's|st_|sta_|g') + eval $(stat -s z | sed -e 's|st_|stz_|g') + test ${sta_ino} != ${stz_ino} || die + test ${sta_nlink} -eq 1 || die + ln a b || die + test_name "Link count is correct after links are created" + eval $(stat -s a | sed -e 's|st_|sta_|g') + eval $(stat -s b | sed -e 's|st_|stb_|g') + test ${sta_ino} = ${stb_ino} || die + test ${sta_nlink} -eq 2 || die + test ${stb_nlink} -eq 2 || die + test_name "Link count is correct after links are deleted" + rm a || die + eval $(stat -s b | sed -e 's|st_|stb_|g') + test ${stb_nlink} -eq 1 || die + rm b || die + + test_name "Link operation works in subdirectories" + touch a || die + mkdir c || die + ln a c/b || die + test_name "Link count is correct after links are created" + eval $(stat -s a | sed -e 's|st_|sta_|g') + eval $(stat -s c/b | sed -e 's|st_|stb_|g') + test ${sta_ino} = ${stb_ino} || die + test ${sta_nlink} -eq 2 || die + test ${stb_nlink} -eq 2 || die + test_name "Link count is correct after links are deleted" + rm a || die + eval $(stat -s c/b | sed -e 's|st_|stb_|g') + test ${stb_nlink} -eq 1 || die + rm c/b || die + rmdir c || die + + mkdir dir || die + touch dir/a || die + echo 'ln dir/a dir/b' | kqueue_monitor 2 dir dir/a || die + test_name "Creating a link raises NOTE_LINK on the source file" + kqueue_check dir/a NOTE_LINK || die + test_name "Creating a link raises NOTE_WRITE on the parent directory" + kqueue_check dir NOTE_WRITE || die + + echo 'rm dir/a' | kqueue_monitor 2 dir dir/b || die + # XXX According to the (short) kqueue(2) documentation, the following + # should raise a NOTE_LINK but FFS raises a NOTE_DELETE... + test_name "Deleting a link raises NOTE_DELETE on one other link" + kqueue_check dir/b NOTE_DELETE || die + test_name "Deleting a link raises NOTE_WRITE on the parent directory" + kqueue_check dir NOTE_WRITE || die + rm dir/b || die + rmdir dir || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_mkdir b/tools/regression/tmpfs/t_mkdir new file mode 100644 index 0000000..7a91961 --- /dev/null +++ b/tools/regression/tmpfs/t_mkdir @@ -0,0 +1,110 @@ +#!/bin/sh +# +# $NetBSD: t_mkdir,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that mkdir works by creating some nested directories. It also +# checks, in part, the lookup operation. +# + +test_run() { + test_mount + + test_name "Directories can be created" + mkdir a + test_name "Link count is updated after directory creation" + eval $(stat -s ${Work_Dir}) + [ ${st_nlink} = 3 ] || die + + test_name "Create many directories" + for d in $(jot 100); do + test -d ${d} && die + mkdir ${d} + test -d ${d} || die + done + eval $(stat -s ${Work_Dir}) + [ ${st_nlink} = 103 ] || die + + test_name "Nested directories can be created" + test -d a/b/c/d/e && die + mkdir -p a/b/c/d/e || die + test -d a/b/c/d/e || die + + if [ -n "${Unprived_User}" ]; then + test_name "New directories by users get proper attributes" + mkdir b c || die + + chown ${Unprived_User}:0 b || die + eval $(stat -s b) + [ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die + [ ${st_gid} -eq 0 ] || die + + chown ${Unprived_User}:100 c || die + eval $(stat -s c) + [ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die + [ ${st_gid} -eq 100 ] || die + + su ${Unprived_User} -c 'mkdir b/a' + eval $(stat -s b/a) + [ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die + [ ${st_gid} -eq 0 ] || die + + su ${Unprived_User} -c 'mkdir c/a' + eval $(stat -s c/a) + [ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die + [ ${st_gid} -eq 100 ] || die + fi + + mkdir dir || die + echo 'mkdir dir/a' | kqueue_monitor 2 dir || die + test_name "Creating a directory raises NOTE_LINK on the parent" \ + "directory" + kqueue_check dir NOTE_LINK || die + test_name "Creating a directory raises NOTE_WRITE on the parent" \ + "directory" + kqueue_check dir NOTE_WRITE || die + rmdir dir/a || die + rmdir dir || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_mount b/tools/regression/tmpfs/t_mount new file mode 100644 index 0000000..cad7e70 --- /dev/null +++ b/tools/regression/tmpfs/t_mount @@ -0,0 +1,85 @@ +#!/bin/sh +# +# $NetBSD: t_mount,v 1.7 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that an execution of mount and umount works correctly without +# causing errors and that the root node gets correct attributes. +# Also verifies command line parsing from mount_tmpfs. +# + +test_run() { + test_name "File-system can be mounted" + test_mount + test_name "Root directory has two links" + eval $(stat -s ${Work_Dir}) + [ ${st_nlink} = 2 ] || die + test_name "File-system can be unmounted" + test_unmount + + test_name "File-system mount options work" + test_mount -o ro + mount | grep ${Work_Dir} | grep -q read-only || die + test_unmount + + test_name "Root directory attributes are set correctly" + test_mount -o "uid=1000,gid=100,mode=755" + eval $(stat -s ${Work_Dir}) + [ ${st_uid} = 1000 ] || die + [ ${st_gid} = 100 ] || die + [ ${st_mode} = 040755 ] || die + test_unmount + + test_name "Negative values are correctly handled" + test_mount -o "size=-10" + test_unmount + + test_name "Extremely large values are correctly handled" + test_mount -o size=9223372036854775807 + test_unmount + mount -t tmpfs -o size=9223372036854775808 tmpfs ${Work_Dir} \ + 2>/dev/null && die + mount -t tmpfs -o size=9223372036854775808g tmpfs ${Work_Dir} \ + 2>/dev/null && die + rmdir ${Work_Dir} +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_pipes b/tools/regression/tmpfs/t_pipes new file mode 100644 index 0000000..00da567 --- /dev/null +++ b/tools/regression/tmpfs/t_pipes @@ -0,0 +1,62 @@ +#!/bin/sh +# +# $NetBSD: t_pipes,v 1.5 2006/12/07 10:00:39 pooka Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that pipes created inside tmpfs work. +# + +test_run() { + test_mount + + umask 022 || die + + test_name "Creation of named pipe" + mkfifo pipe || die + + test_name "Writing to pipe and waiting for response" + echo -n foo >pipe & + [ "$(cat pipe)" = foo ] || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_read_write b/tools/regression/tmpfs/t_read_write new file mode 100644 index 0000000..42759e0 --- /dev/null +++ b/tools/regression/tmpfs/t_read_write @@ -0,0 +1,81 @@ +#!/bin/sh +# +# $NetBSD: t_read_write,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the read and write operations work. +# + +test_run() { + test_mount + + test_name "Write to new file works" + echo foo >a || die + test_name "Data written is correct" + [ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || die + + test_name "Append to existing file works" + echo bar >>a || die + test_name "Data written is correct" + [ $(md5 a | cut -d ' ' -f 4) = f47c75614087a8dd938ba4acff252494 ] || die + + test_name "Write to long file (bigger than a page) works" + jot 10000 >b || die + test_name "Data written is correct" + [ $(md5 b | cut -d ' ' -f 4) = 72d4ff27a28afbc066d5804999d5a504 ] || die + + dd if=/dev/zero of=c bs=1k count=10 >/dev/null 2>&1 || die + echo 'dd if=/dev/zero of=c seek=2 bs=1k count=1 conv=notrunc' \ + '>/dev/null 2>&1' | kqueue_monitor 1 c || die + test_name "Writing to a file raises NOTE_WRITE" + kqueue_check c NOTE_WRITE || die + + echo foo >d + echo 'echo bar >>d' | kqueue_monitor 2 d || die + test_name "Appending to a file raises NOTE_EXTEND" + kqueue_check d NOTE_EXTEND || die + test_name "Appending to a file raises NOTE_WRITE" + kqueue_check d NOTE_WRITE || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_readdir b/tools/regression/tmpfs/t_readdir new file mode 100644 index 0000000..73cb578 --- /dev/null +++ b/tools/regression/tmpfs/t_readdir @@ -0,0 +1,93 @@ +#!/bin/sh +# +# $NetBSD: t_readdir,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the readdir operation works. +# + +test_run() { + test_mount + + test_name "Directory has '.' and '..' entries" + /bin/ls -a | grep '^\.$' >/dev/null || die + /bin/ls -a | grep '^\..$' >/dev/null || die + + test_name "Creation of files of all possible types" + mkdir dir || die + touch reg || die + ln -s reg lnk || die + mknod b blk 0 0 || die + mknod c chr 0 0 || die + mkfifo fifo || die + ${Src_Dir}/h_tools sockets sock || die + + test_name "Read of directory" + ls >/dev/null || die + rm -rf * || die + + # Catch a bug caused by incorrect invalidation of readdir caching + # variables. + test_name "Populate directory" + touch $(jot 10) || die + test_name "Clean it" + rm * || die + test_name "Repopulate directory" + touch $(jot 20) || die + test_name "Listing should return all entries" + ls >/dev/null || die + + test_name "Creation of many files" + mkdir a || die + for f in $(jot 500); do + touch a/$f || die + done + + test_name "Removal of all files using a wildcard" + rm a/* || die + + test_name "Removal of should-be-empty directory" + rmdir a || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_remove b/tools/regression/tmpfs/t_remove new file mode 100644 index 0000000..80b8986 --- /dev/null +++ b/tools/regression/tmpfs/t_remove @@ -0,0 +1,83 @@ +#!/bin/sh +# +# $NetBSD: t_remove,v 1.7.2.1 2007/01/04 20:29:50 bouyer Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the remove operation works. +# + +test_run() { + test_mount + + test_name "Files can be removed" + test -f a && die + touch a || die + test -f a || die + rm a || die + test -f a && die + + test_name "Files with uchg flags cannot be removed" + touch a || die + chflags uchg a || die + #Not valid case in FreeBSD + #rm -f a 2>/dev/null && die + chflags nouchg a || die + rm a || die + test -f a && die + + test_name "The node . cannot be unlinked" + mkdir a || die + unlink a/. 2>/dev/null && die + rmdir a + + mkdir dir || die + touch dir/a || die + echo 'rm dir/a' | kqueue_monitor 2 dir dir/a || die + test_name "Deleting a file raises NOTE_DELETE on it" + kqueue_check dir/a NOTE_DELETE || die + test_name "Deleting a file raises NOTE_WRITE on the parent directory" + kqueue_check dir NOTE_WRITE || die + rmdir dir || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_rename b/tools/regression/tmpfs/t_rename new file mode 100644 index 0000000..867a393 --- /dev/null +++ b/tools/regression/tmpfs/t_rename @@ -0,0 +1,150 @@ +#!/bin/sh +# +# $NetBSD: t_rename,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the rename operation works (either by renaming entries or +# by moving them). +# + +test_run() { + test_mount + + test_name "'.' and '..' entries cannot be renamed" + mkdir a || die + mv a/. c 2>/dev/null && die + mv a/.. c 2>/dev/null && die + rmdir a || die + + test_name "Cross device renames do not work" + mkdir a || die + ${Src_Dir}/h_tools rename a /var/tmp/a && die + rmdir a || die + + test_name "Directories can be renamed" + mkdir a || die + mv a c || die + test -d a && die + test -d c || die + rmdir c || die + + test_name "The '..' entry is updated after moves" + mkdir a || die + mkdir b || die + mv b a || die + test -d a/b/../b || die + test -d a/b/../../a || die + eval $(stat -s a/b) + [ ${st_nlink} = 2 ] || die + eval $(stat -s a) + [ ${st_nlink} = 3 ] || die + rmdir a/b || die + rmdir a || die + + test_name "The '..' entry is correct after renames" + mkdir a || die + mkdir b || die + mv b a || die + mv a c || die + test -d c/b/../b || die + test -d c/b/../../c || die + rmdir c/b || die + rmdir c || die + + test_name "The '..' entry is correct after multiple moves" + mkdir a || die + mkdir b || die + mv b a || die + mv a c || die + mv c/b d || die + test -d d/../c || die + rmdir d || die + rmdir c || die + + test_name "Rename works if the target file exists" + touch a || die + touch b || die + mv a b || die + test -f a && die + test -f b || die + rm b + + mkdir dir || die + touch dir/a + echo 'mv dir/a dir/b' | kqueue_monitor 2 dir dir/a || die + test_name "Renaming a file raises NOTE_RENAME on the old file" + kqueue_check dir/a NOTE_RENAME || die + test_name "Renaming a file raises NOTE_WRITE on the parent directory" + kqueue_check dir NOTE_WRITE || die + rm dir/b || die + rmdir dir || die + + mkdir dir || die + touch dir/a + touch dir/b + echo 'mv dir/a dir/b' | kqueue_monitor 3 dir dir/a dir/b || die + test_name "Renaming a file raises NOTE_RENAME on the old file" + kqueue_check dir/a NOTE_RENAME || die + test_name "Renaming a file raises NOTE_WRITE on the parent directory" + kqueue_check dir NOTE_WRITE || die + test_name "Renaming a file raises NOTE_DELETE on the target file" + kqueue_check dir/b NOTE_DELETE || die + rm dir/b || die + rmdir dir || die + + mkdir dir1 || die + mkdir dir2 || die + touch dir1/a + echo 'mv dir1/a dir2/a' | kqueue_monitor 3 dir1 dir1/a dir2 || die + test_name "Moving a file raises NOTE_RENAME on the old file" + kqueue_check dir1/a NOTE_RENAME || die + test_name "Moving a file raises NOTE_WRITE on the source directory" + kqueue_check dir1 NOTE_WRITE || die + test_name "Moving a file raises NOTE_WRITE on the target directory" + kqueue_check dir2 NOTE_WRITE || die + rm dir2/a || die + rmdir dir1 || die + rmdir dir2 || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_rmdir b/tools/regression/tmpfs/t_rmdir new file mode 100644 index 0000000..0cb92d8 --- /dev/null +++ b/tools/regression/tmpfs/t_rmdir @@ -0,0 +1,114 @@ +#!/bin/sh +# +# $NetBSD: t_rmdir,v 1.6 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that rmdir works by creating and removing directories. Also +# checks multiple error conditions. +# + +test_run() { + test_mount + + test_name "The mount point cannot be removed" + rmdir 2>/dev/null && die + + test_name "Non-existing directories cannot be removed" + rmdir non-existent 2>/dev/null && die + + test_name "Removal of a single directory works" + mkdir a || die + eval $(stat -s ${Work_Dir}) + [ ${st_nlink} = 3 ] || die + rmdir a || die + eval $(stat -s ${Work_Dir}) + [ ${st_nlink} = 2 ] || die + + test_name "Removal of nested directories works" + mkdir -p a/b/c || die + rmdir a/b/c || die + rmdir a/b || die + rmdir a || die + + test_name "'.' and '..' directories cannot be removed" + mkdir a || die + rmdir a/. 2>/dev/null && die + rmdir a/.. 2>/dev/null && die + rmdir a || die + + test_name "Non-empty directories cannot be removed" + mkdir a || die + mkdir a/b || die + mkdir a/c || die + rmdir a 2>/dev/null && die + rmdir a/b || die + rmdir a/c || die + rmdir a || die + + test_name "Root directory has two links after all removes" + eval $(stat -s ${Work_Dir}) + [ ${st_nlink} = 2 ] || die + + test_name "Removal of current directory" + mkdir a || die + # Catch a bug that would panic the system when accessing the + # current directory after being deleted: vop_open cannot assume + # that open files are still linked to a directory. + ( cd a && rmdir ../a && ls >/dev/null 2>&1 ) && die + test -e a && die + + mkdir dir || die + mkdir dir/a || die + echo 'rmdir dir/a' | kqueue_monitor 3 dir dir/a || die + test_name "Deleting a directory raises NOTE_DELETE on it" + kqueue_check dir/a NOTE_DELETE || die + test_name "Deleting a directory raises NOTE_LINK on the parent" \ + "directory" + kqueue_check dir NOTE_LINK || die + test_name "Deleting a directory raises NOTE_WRITE on the parent" \ + "directory" + kqueue_check dir NOTE_WRITE || die + rmdir dir || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_setattr b/tools/regression/tmpfs/t_setattr new file mode 100644 index 0000000..b38ad88e --- /dev/null +++ b/tools/regression/tmpfs/t_setattr @@ -0,0 +1,115 @@ +#!/bin/sh +# +# $NetBSD: t_setattr,v 1.6 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the setattr vnode operation works, using several commands +# that require this function. +# + +test_run() { + test_mount + + test_name "File owner can be changed on its own" + mkdir own || die + eval $(stat -s own | sed -e 's|st_|ost_|g') + chown 1234 own || die + eval $(stat -s own) + [ ${st_uid} -eq 1234 ] || die + [ ${st_gid} -eq ${ost_gid} ] || die + + mkdir ownq || die + echo 'chown 1234 ownq' | kqueue_monitor 1 ownq || die + test_name "Changing a file's owner raises NOTE_ATTRIB on it" + kqueue_check ownq NOTE_ATTRIB || die + + test_name "File group can be changed on its own" + mkdir grp || die + eval $(stat -s grp | sed -e 's|st_|ost_|g') + chgrp 5678 grp || die + eval $(stat -s grp) + [ ${st_uid} -eq ${ost_uid} ] || die + [ ${st_gid} -eq 5678 ] || die + + mkdir grpq || die + echo 'chgrp 1234 grpq' | kqueue_monitor 1 grpq || die + test_name "Changing a file's group raises NOTE_ATTRIB on it" + kqueue_check grpq NOTE_ATTRIB || die + + test_name "File owner and group can be changed at once" + mkdir owngrp || die + chown 1234:5678 owngrp || die + eval $(stat -s owngrp) + [ ${st_uid} -eq 1234 ] || die + [ ${st_gid} -eq 5678 ] || die + + mkdir owngrpp || die + echo 'chown 1234:5678 owngrpp' | kqueue_monitor 1 owngrpp || die + test_name "Changing a file's owner and group raises NOTE_ATTRIB on it" + kqueue_check owngrpp NOTE_ATTRIB || die + + test_name "File mode can be changed" + mkdir mode || die + chmod 0000 mode || die + eval $(stat -s mode) + [ ${st_mode} -eq 40000 ] || die + + mkdir modeq || die + echo 'chmod 0000 modeq' | kqueue_monitor 1 modeq || die + test_name "Updating a file's mode raises NOTE_ATTRIB on it" + kqueue_check modeq NOTE_ATTRIB || die + + test_name "File times can be changed" + mkdir times || die + TZ=GMT touch -t 200501010101 times || die + eval $(stat -s times) + [ ${st_atime} = ${st_mtime} ] || die + [ ${st_atime} = 1104541260 ] || die + + mkdir timesq || die + echo 'touch timesq' | kqueue_monitor 1 timesq || die + test_name "Updating a file's times raises NOTE_ATTRIB on it" + kqueue_check timesq NOTE_ATTRIB || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_sizes b/tools/regression/tmpfs/t_sizes new file mode 100644 index 0000000..890ac15 --- /dev/null +++ b/tools/regression/tmpfs/t_sizes @@ -0,0 +1,99 @@ +#!/bin/sh +# +# $NetBSD: t_sizes,v 1.6 2007/03/11 10:09:17 pooka Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the file system controls memory usage correctly. +# + +test_run() { + test_mount -o size=10485760 + + pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 2) + + test_name "Get status of clean filesystem" + eval $(${Src_Dir}/h_tools statvfs . | sed -e 's|^f_|cf_|') + cf_bused=$((${cf_blocks} - ${cf_bfree})) + + test_name "Creation of small file" + echo a >a || die + test_name "statvfs(2) reports correct block accounting" + eval $(${Src_Dir}/h_tools statvfs .) + f_bused=$((${f_blocks} - ${f_bfree})) + [ ${f_bused} -gt 1 ] || die + rm a || die + + test_name "Creation of big file" + dd if=/dev/zero of=a bs=1m count=5 >/dev/null 2>&1 || die + test_name "statvfs(2) reports correct block accounting" + eval $(${Src_Dir}/h_tools statvfs .) + f_bused=$((${f_blocks} - ${f_bfree})) + [ ${f_bused} -ne ${cf_bused} ] || die + [ ${f_bused} -gt $((5 * 1024 * 1024 / ${pagesize})) ] || die + of_bused=${f_bused} + rm a || die + eval $(${Src_Dir}/h_tools statvfs .) + f_bused=$((${f_blocks} - ${f_bfree})) + [ ${f_bused} -lt ${of_bused} ] || die + + test_name "Creation of big file that overflows the filesystem" + of_bused=${f_bused} + dd if=/dev/zero of=a bs=1m count=15 >/dev/null 2>&1 && die + rm a || die + test_name "statvfs(2) reports correct block accounting" + eval $(${Src_Dir}/h_tools statvfs .) + f_bused=$((${f_blocks} - ${f_bfree})) + [ ${f_bused} -ge ${of_bused} -a ${f_bused} -le $((${of_bused} + 1)) ] \ + || die + + test_name "Write to middle of a file does not change size" + dd if=/dev/zero of=a bs=1024 count=10 >/dev/null 2>&1 || die + sync + dd if=/dev/zero of=a bs=1024 conv=notrunc seek=1 count=1 \ + >/dev/null 2>&1 || die + sync + eval $(stat -s a) + [ ${st_size} -eq 10240 ] || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_sockets b/tools/regression/tmpfs/t_sockets new file mode 100644 index 0000000..6d8e58d --- /dev/null +++ b/tools/regression/tmpfs/t_sockets @@ -0,0 +1,63 @@ +#!/bin/sh +# +# $NetBSD: t_sockets,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that sockets can be created using socket/bind. +# + +test_run() { + test_mount + + test_name "Sockets can be created" + ${Src_Dir}/h_tools sockets a + rm a || die + + mkdir dir || die + echo "${Src_Dir}/h_tools sockets dir/a" | kqueue_monitor 1 dir || die + test_name "Creating a socket raises NOTE_WRITE on the parent" \ + "directory" + kqueue_check dir NOTE_WRITE || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_statvfs b/tools/regression/tmpfs/t_statvfs new file mode 100644 index 0000000..937e72d --- /dev/null +++ b/tools/regression/tmpfs/t_statvfs @@ -0,0 +1,62 @@ +#!/bin/sh +# +# $NetBSD: t_statvfs,v 1.4 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the statvfs system call works properly (returning the +# correct values) over a tmpfs mount point. +# + +test_run() { + test_mount -o size=10485760 + + test_name "statvfs(2) returns correct values" + pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 2) + eval $(${Src_Dir}/h_tools statvfs .) + [ ${pagesize} -eq ${f_bsize} ] || die + [ $((${f_bsize} * ${f_blocks})) -ge $((10 * 1024 * 1024)) ] || die + [ $((${f_bsize} * ${f_blocks})) -le \ + $((10 * 1024 * 1024 + ${pagesize})) ] || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_symlink b/tools/regression/tmpfs/t_symlink new file mode 100644 index 0000000..6a5638a --- /dev/null +++ b/tools/regression/tmpfs/t_symlink @@ -0,0 +1,88 @@ +#!/bin/sh +# +# $NetBSD: t_symlink,v 1.6 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the symlink and readlink operations work. +# + +test_run() { + test_mount + + test_name "Creation of an empty file" + touch a || die + test_name "Creation of a symlink pointing to it" + ln -s a b || die + test_name "Symlink points to correct file" + [ $(md5 b | cut -d ' ' -f 4) = d41d8cd98f00b204e9800998ecf8427e ] || die + + test_name "Changing original file" + echo foo >a || die + test_name "Symlink reflects the changes" + [ $(md5 b | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || die + + test_name "Creation of symlink to a known system file" + ln -s /bin/cp cp || die + test_name "Trying to see if it works" + ./cp b c || die + [ -f c ] || die + + test_name "Symlinking directories works" + mkdir d || die + [ -f d/foo ] && die + [ -f e/foo ] && die + ln -s d e || die + touch d/foo || die + [ -f d/foo ] || die + [ -f e/foo ] || die + + mkdir dir || die + echo 'ln -s non-existent dir/a' | kqueue_monitor 1 dir || die + test_name "Creating a symlink raises NOTE_WRITE on the parent" \ + "directory" + kqueue_check dir NOTE_WRITE || die + rm dir/a || die + rmdir dir || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_times b/tools/regression/tmpfs/t_times new file mode 100644 index 0000000..06055b9 --- /dev/null +++ b/tools/regression/tmpfs/t_times @@ -0,0 +1,114 @@ +#!/bin/sh +# +# $NetBSD: t_times,v 1.6 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that node times are properly handled. +# + +test_run() { + test_mount + + test_name "Creation of empty file" + touch a || die + eval $(stat -s a | sed -e 's|st_|ost_|g') || die + [ ${ost_birthtime} -eq ${ost_atime} ] || die + [ ${ost_birthtime} -eq ${ost_ctime} ] || die + [ ${ost_birthtime} -eq ${ost_mtime} ] || die + + test_name "Read of empty file" + sleep 1 + cat a >/dev/null || die + eval $(stat -s a) || die + [ ${st_atime} -gt ${ost_atime} ] || die + [ ${st_ctime} -eq ${ost_ctime} ] || die + [ ${st_mtime} -eq ${ost_mtime} ] || die + + test_name "Write to (and extension of) empty file" + sleep 1 + echo foo >a || die + eval $(stat -s a) || die + [ ${st_atime} -gt ${ost_atime} ] || die + [ ${st_ctime} -gt ${ost_ctime} ] || die + [ ${st_mtime} -gt ${ost_mtime} ] || die + + test_name "Creation of non-empty file" + echo foo >b || die + eval $(stat -s b | sed -e 's|st_|ost_|g') || die + + test_name "Read of non-empty file" + sleep 1 + cat b >/dev/null || die + eval $(stat -s b) || die + [ ${st_atime} -gt ${ost_atime} ] || die + [ ${st_ctime} -eq ${ost_ctime} ] || die + [ ${st_mtime} -eq ${ost_mtime} ] || die + + test_name "Creation of non-empty file" + echo foo >c || die + eval $(stat -s c | sed -e 's|st_|ost_|g') || die + + test_name "New link to non-empty file" + sleep 1 + ln c d || die + eval $(stat -s c) || die + [ ${st_atime} -eq ${ost_atime} ] || die + [ ${st_ctime} -gt ${ost_ctime} ] || die + [ ${st_mtime} -eq ${ost_mtime} ] || die + + test_name "File renaming does not change times" + mkdir e || die + echo foo >e/a || die + eval $(stat -s e | sed -e 's|st_|dost_|g') || die + eval $(stat -s e/a | sed -e 's|st_|ost_|g') || die + sleep 1 + mv e/a e/b || die + eval $(stat -s e | sed -e 's|st_|dst_|g') || die + eval $(stat -s e/b) || die + [ ${st_atime} -eq ${ost_atime} ] || die + [ ${st_ctime} -gt ${ost_ctime} ] || die + [ ${st_mtime} -eq ${ost_mtime} ] || die + [ ${dst_mtime} -gt ${dost_mtime} ] || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_trail_slash b/tools/regression/tmpfs/t_trail_slash new file mode 100644 index 0000000..028dd21 --- /dev/null +++ b/tools/regression/tmpfs/t_trail_slash @@ -0,0 +1,61 @@ +#!/bin/sh +# +# $NetBSD: t_trail_slash,v 1.4 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that trailing slashes are not stored in directory names and that +# they do not cause crashes. +# + +test_run() { + test_mount + + test_name "Trailing slashes are not taken into account" + mkdir a/ || die + touch a/b || die + [ -f a/b ] || die + rm a/b || die + rmdir a/ || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_truncate b/tools/regression/tmpfs/t_truncate new file mode 100644 index 0000000..c5ff811 --- /dev/null +++ b/tools/regression/tmpfs/t_truncate @@ -0,0 +1,64 @@ +#!/bin/sh +# +# $NetBSD: t_truncate,v 1.4 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that the truncate operations work. +# + +test_run() { + test_mount + + test_name "Write to new file works" + jot 10000 >a || die + test_name "Truncate the file to smaller size works" + echo foo >a || die + [ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || die + + test_name "Truncate to zero size" + >a || die + test_name "Truncate to zero size, second try" + >a || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_vnd b/tools/regression/tmpfs/t_vnd new file mode 100644 index 0000000..54e51ba --- /dev/null +++ b/tools/regression/tmpfs/t_vnd @@ -0,0 +1,95 @@ +#!/bin/sh +# +# $NetBSD: t_vnd,v 1.1 2006/11/09 15:25:37 jmmv Exp $ +# +# Copyright (c) 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that vnd works with files stored in tmpfs. +# + +die_mounted() { + umount mnt + die_configured +} + +die_configured() { + mdconfig -d -u 3 + die +} + +test_run() { + test_mount + + test_name "Creation of disk image" + dd if=/dev/zero of=disk.img bs=1m count=10 >/dev/null 2>&1 || die + + test_name "Configuration of vnd" + mdconfig -a -f disk.img -u 3 -x 32 -y 2 ||die + + test_name "Labelling the md" + bsdlabel -m i386 -w /dev/md3 || die_configured + + test_name "Formatting of disk image" + newfs -n -U -m 0 -O 1 /dev/md3a >/dev/null 2>&1 || die_configured + + test_name "Mounting of disk image" + mkdir mnt || die + mount /dev/md3a mnt || die_configured + + test_name "Creation of several files" + for f in $(jot 100); do + jot 1000 >mnt/$f || die_mounted + done + + test_name "Verification of created files" + for f in $(jot 100); do + [ $(md5 mnt/$f | cut -d ' ' -f 4) = \ + 53d025127ae99ab79e8502aae2d9bea6 ] || die_mounted + done + + test_name "Unmounting of disk image" + umount mnt || die_configured + + test_name "Deconfiguration of vnd" + mdconfig -d -u 3 || die + + test_unmount +} + +. ${SUBRDIR}/h_funcs.subr diff --git a/tools/regression/tmpfs/t_vnode_leak b/tools/regression/tmpfs/t_vnode_leak new file mode 100644 index 0000000..7f6b2f9 --- /dev/null +++ b/tools/regression/tmpfs/t_vnode_leak @@ -0,0 +1,63 @@ +#!/bin/sh +# +# $NetBSD: t_vnode_leak,v 1.5 2006/11/09 16:20:06 jmmv Exp $ +# +# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal, developed as part of Google's Summer of Code +# 2005 program. +# +# 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# 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. +# +# $FreeBSD$ +# + +# +# Verifies that vnodes are not leaked and that their reclaim operation works +# as expected: i.e., when all free vnodes are exhausted, unused ones have to +# be recycled, which is what the reclaim operation does. +# + +test_run() { + oldvnodes=$(sysctl kern.maxvnodes | awk '{ print $2; }') + sysctl -w kern.maxvnodes=2000 >/dev/null || die + + test_name "vnodes are properly reclaimed" + test_mount -o size=$(((4000 + 2) * 4096)) + for f in $(jot 4000); do + mkdir ${f} + done + test_unmount + + sysctl -w kern.maxvnodes=${oldvnodes} >/dev/null || die +} + +. ${SUBRDIR}/h_funcs.subr -- cgit v1.1