Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Make parts of the quota tests useable for more than quotas:



details:   https://anonhg.NetBSD.org/src/rev/4d4d3a3d62c0
branches:  trunk
changeset: 772858:4d4d3a3d62c0
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Jan 18 20:51:23 2012 +0000

description:
Make parts of the quota tests useable for more than quotas:
- rename h_quota2_server to h_ffs_server, there's nothing about quotas
  in there.
- extract non-quota parts of quotas_common.sh to ffs_common.sh

diffstat:

 distrib/sets/lists/tests/mi    |    8 +-
 tests/fs/ffs/Makefile          |   12 ++--
 tests/fs/ffs/ffs_common.sh     |   99 +++++++++++++++++++++++++++++++++++
 tests/fs/ffs/h_ffs_server.c    |  115 +++++++++++++++++++++++++++++++++++++++++
 tests/fs/ffs/h_quota2_server.c |  115 -----------------------------------------
 tests/fs/ffs/quotas_common.sh  |   91 +-------------------------------
 tests/fs/ffs/t_clearquota.sh   |    6 +-
 tests/fs/ffs/t_getquota.sh     |    8 +-
 tests/fs/ffs/t_miscquota.sh    |   14 ++--
 tests/fs/ffs/t_quotalimit.sh   |   26 ++++----
 tests/fs/ffs/t_setquota.sh     |   14 ++--
 11 files changed, 261 insertions(+), 247 deletions(-)

diffs (truncated from 776 to 300 lines):

diff -r d6a245fcfa7c -r 4d4d3a3d62c0 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Wed Jan 18 20:37:20 2012 +0000
+++ b/distrib/sets/lists/tests/mi       Wed Jan 18 20:51:23 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.433 2011/12/27 17:13:10 pgoyette Exp $
+# $NetBSD: mi,v 1.434 2012/01/18 20:51:23 bouyer Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -227,7 +227,8 @@
 ./usr/libdata/debug/usr/tests/dev/sysmon                                       tests-fs-debug
 ./usr/libdata/debug/usr/tests/dev/sysmon/t_swwdog.debug                        tests-fs-debug          debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs                                   tests-fs-debug
-./usr/libdata/debug/usr/tests/fs/ffs/h_quota2_server.debug             tests-fs-debug          debug,atf
+./usr/libdata/debug/usr/tests/fs/ffs/h_ffs_server.debug                        tests-fs-debug          debug,atf
+./usr/libdata/debug/usr/tests/fs/ffs/h_quota2_server.debug             tests-obsolete          obsolete
 ./usr/libdata/debug/usr/tests/fs/ffs/h_quota2_tests.debug              tests-fs-debug          debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs/t_fifos.debug                     tests-fs-debug          debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs/t_mount.debug                     tests-fs-debug          debug,atf
@@ -1410,7 +1411,8 @@
 ./usr/tests/fs/h_funcs.subr                    tests-fs-tests          atf
 ./usr/tests/fs/ffs                             tests-fs-tests
 ./usr/tests/fs/ffs/Atffile                     tests-fs-tests          atf
-./usr/tests/fs/ffs/h_quota2_server             tests-fs-tests          atf
+./usr/tests/fs/ffs/h_ffs_server                        tests-fs-tests          atf
+./usr/tests/fs/ffs/h_quota2_server             tests-obsolete          obsolete
 ./usr/tests/fs/ffs/h_quota2_tests              tests-fs-tests          atf
 ./usr/tests/fs/ffs/rump_edquota                        tests-obsolete          obsolete
 ./usr/tests/fs/ffs/rump_quota                  tests-obsolete          obsolete
diff -r d6a245fcfa7c -r 4d4d3a3d62c0 tests/fs/ffs/Makefile
--- a/tests/fs/ffs/Makefile     Wed Jan 18 20:37:20 2012 +0000
+++ b/tests/fs/ffs/Makefile     Wed Jan 18 20:51:23 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.16 2011/03/09 20:13:47 tron Exp $
+#      $NetBSD: Makefile,v 1.17 2012/01/18 20:51:23 bouyer Exp $
 #
 
 .include <bsd.own.mk>
@@ -6,10 +6,10 @@
 TESTSDIR=      ${TESTSBASE}/fs/ffs
 WARNS=         4
 
-PROGS=                 h_quota2_server h_quota2_tests
-SRCS.h_quota2_server=  h_quota2_server.c
-MAN.h_quota2_server=   # empty
-BINDIR.h_quota2_server=        ${TESTSDIR}
+PROGS=                 h_ffs_server h_quota2_tests
+SRCS.h_ffs_server=     h_ffs_server.c
+MAN.h_ffs_server=      # empty
+BINDIR.h_ffs_server=   ${TESTSDIR}
 
 SRCS.h_quota2_tests=   h_quota2_tests.c
 MAN.h_quota2_tests=    # empty
@@ -17,7 +17,7 @@
 
 .for name in t_getquota t_setquota t_quotalimit t_clearquota t_miscquota
 TESTS_SH+=     ${name}
-TESTS_SH_SRC_${name}=  quotas_common.sh ${name}.sh
+TESTS_SH_SRC_${name}=  ffs_common.sh quotas_common.sh ${name}.sh
 .endfor
 
 TESTS_C+=      t_fifos
diff -r d6a245fcfa7c -r 4d4d3a3d62c0 tests/fs/ffs/ffs_common.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/ffs/ffs_common.sh        Wed Jan 18 20:51:23 2012 +0000
@@ -0,0 +1,99 @@
+# $NetBSD: ffs_common.sh,v 1.1 2012/01/18 20:51:23 bouyer Exp $ 
+
+create_ffs()
+{
+       local endian=$1; shift
+       local vers=$1; shift
+       local type=$1; shift
+       local op;
+       if [ ${type} = "both" ]; then
+               op="-q user -q group"
+       else
+               op="-q ${type}"
+       fi
+       atf_check -o ignore -e ignore newfs ${op} \
+               -B ${endian} -O ${vers} -s 4000 -F ${IMG}
+}
+
+create_ffs_server()
+{      
+       local sarg=$1; shift
+       create_ffs $*
+       atf_check -o ignore -e ignore $(atf_get_srcdir)/h_ffs_server \
+               ${sarg} ${IMG} ${RUMP_SERVER}
+}
+
+rump_shutdown()
+{
+       for s in ${RUMP_SOCKETS_LIST}; do
+               atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt;
+       done
+# check that the quota inode creation didn't corrupt the filesystem
+       atf_check -s exit:0 -o "match:already clean" \
+               -o "match:Phase 6 - Check Quotas" \
+               fsck_ffs -nf -F ${IMG}
+}
+
+# from tests/ipf/h_common.sh via tests/sbin/resize_ffs
+test_case()
+{
+       local name="${1}"; shift
+       local check_function="${1}"; shift
+       local descr="${1}"; shift
+       
+       atf_test_case "${name}" cleanup
+
+       eval "${name}_head() { \
+               atf_set "descr" "${descr}"
+               atf_set "timeout" "60"
+       }"
+       eval "${name}_body() { \
+               RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
+               export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
+               ${check_function} " "${@}" "; \
+       }"
+       eval "${name}_cleanup() { \
+               for s in \${RUMP_SOCKETS_LIST}; do \
+                       export RUMP_SERVER=unix://\${s}; \
+                       atf_check -s exit:1 -o ignore -e ignore rump.halt; \
+               done; \
+       }"
+       tests="${tests} ${name}"
+}
+
+test_case_root()
+{
+       local name="${1}"; shift
+       local check_function="${1}"; shift
+       local descr="${1}"; shift
+       
+       atf_test_case "${name}" cleanup
+
+       eval "${name}_head() { \
+               atf_set "descr" "${descr}"
+               atf_set "require.user" "root"
+               atf_set "timeout" "60"
+       }"
+       eval "${name}_body() { \
+               RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
+               export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
+               ${check_function} " "${@}" "; \
+       }"
+       eval "${name}_cleanup() { \
+               for s in \${RUMP_SOCKETS_LIST}; do \
+                       export RUMP_SERVER=unix://\${s}; \
+                       atf_check -s exit:1 -o ignore -e ignore rump.halt; \
+               done; \
+       }"
+       tests="${tests} ${name}"
+}
+
+atf_init_test_cases()
+{
+       IMG=fsimage
+       DIR=target
+       RUMP_SOCKET=test;
+       for i in ${tests}; do
+               atf_add_test_case $i
+       done
+}
diff -r d6a245fcfa7c -r 4d4d3a3d62c0 tests/fs/ffs/h_ffs_server.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/ffs/h_ffs_server.c       Wed Jan 18 20:51:23 2012 +0000
@@ -0,0 +1,115 @@
+/*     $NetBSD: h_ffs_server.c,v 1.1 2012/01/18 20:51:23 bouyer Exp $  */
+
+/*
+ * rump server for advanced quota tests
+ */
+
+#include "../common/h_fsmacros.h"
+
+#include <err.h>
+#include <semaphore.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <ufs/ufs/ufsmount.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "../../h_macros.h"
+
+int background = 0;
+
+static void
+usage(void)
+{
+       fprintf(stderr, "usage: %s [-b] [-l] diskimage bindurl\n",
+           getprogname());
+       exit(1);
+}
+
+static void
+die(const char *reason, int error)
+{
+
+       warnx("%s: %s", reason, strerror(error));
+       if (background)
+               rump_daemonize_done(error);
+       exit(1);
+}
+
+static sem_t sigsem;
+static void
+sigreboot(int sig)
+{
+
+       sem_post(&sigsem);
+}
+
+int 
+main(int argc, char **argv)
+{
+       int error;
+       struct ufs_args uargs;
+       const char *filename;
+       const char *serverurl;
+       int log = 0;
+       int ch;
+
+       while ((ch = getopt(argc, argv, "bl")) != -1) {
+               switch(ch) {
+               case 'b':
+                       background = 1;
+                       break;
+               case 'l':
+                       log = 1;
+                       break;
+               default:
+                       usage();
+               }
+       }
+       argc -= optind;
+       argv += optind;
+
+       if (argc != 2)
+               usage();
+
+       filename = argv[0];
+       serverurl = argv[1];
+
+       if (background) {
+               error = rump_daemonize_begin();
+               if (error)
+                       errx(1, "rump daemonize: %s", strerror(error));
+       }
+
+       error = rump_init();
+       if (error)
+               die("rump init failed", error);
+
+       if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1)
+               atf_tc_fail_errno("mount point create");
+       rump_pub_etfs_register("/diskdev", filename, RUMP_ETFS_BLK);
+       uargs.fspec = __UNCONST("/diskdev");
+       if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, (log) ? MNT_LOG : 0,
+           &uargs, sizeof(uargs)) == -1)
+               die("mount ffs", errno);
+
+       error = rump_init_server(serverurl);
+       if (error)
+               die("rump server init failed", error);
+       if (background)
+               rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS);
+
+       sem_init(&sigsem, 0, 0);
+       signal(SIGTERM, sigreboot);
+       signal(SIGINT, sigreboot);
+       sem_wait(&sigsem);
+
+       rump_sys_reboot(0, NULL);
+       /*NOTREACHED*/
+       return 0;
+}
diff -r d6a245fcfa7c -r 4d4d3a3d62c0 tests/fs/ffs/h_quota2_server.c
--- a/tests/fs/ffs/h_quota2_server.c    Wed Jan 18 20:37:20 2012 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*     $NetBSD: h_quota2_server.c,v 1.2 2011/03/06 17:08:40 bouyer Exp $       */
-
-/*
- * rump server for advanced quota tests
- */
-
-#include "../common/h_fsmacros.h"
-
-#include <err.h>
-#include <semaphore.h>
-#include <sys/types.h>
-#include <sys/mount.h>



Home | Main Index | Thread Index | Old Index