Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-quota2]: src/tests/fs/ffs Add rump versions of quota utilities, t...
details: https://anonhg.NetBSD.org/src/rev/0c310357d7ec
branches: bouyer-quota2
changeset: 761074:0c310357d7ec
user: bouyer <bouyer%NetBSD.org@localhost>
date: Fri Jan 28 18:38:07 2011 +0000
description:
Add rump versions of quota utilities, to be used by tests.
Add a test which figures if we can retrieve quota values from
the kernel.
diffstat:
tests/fs/ffs/Makefile | 11 +++-
tests/fs/ffs/clients/Makefile | 36 ++++++++++++
tests/fs/ffs/clients/quota_rumpops.c | 89 ++++++++++++++++++++++++++++++
tests/fs/ffs/quotas_common.sh | 51 +++++++++++++++++
tests/fs/ffs/t_getquota.sh | 101 +++++++++++++++++++++++++++++++++++
5 files changed, 286 insertions(+), 2 deletions(-)
diffs (truncated from 322 to 300 lines):
diff -r b1367d46a096 -r 0c310357d7ec tests/fs/ffs/Makefile
--- a/tests/fs/ffs/Makefile Fri Jan 28 18:36:06 2011 +0000
+++ b/tests/fs/ffs/Makefile Fri Jan 28 18:38:07 2011 +0000
@@ -1,16 +1,23 @@
-# $NetBSD: Makefile,v 1.14.2.1 2011/01/20 14:25:04 bouyer Exp $
+# $NetBSD: Makefile,v 1.14.2.2 2011/01/28 18:38:07 bouyer Exp $
#
.include <bsd.own.mk>
+SUBDIR= clients
+
TESTSDIR= ${TESTSBASE}/fs/ffs
WARNS= 4
-PROGS= h_quota2_server
+PROGS= h_quota2_server
SRCS.h_quota2_server= h_quota2_server.c
MAN.h_quota2_server= # empty
BINDIR.h_quota2_server= ${TESTSDIR}
+.for name in t_getquota
+TESTS_SH+= ${name}
+TESTS_SH_SRC_${name}= quotas_common.sh ${name}.sh
+.endfor
+
TESTS_C+= t_fifos
TESTS_C+= t_snapshot
TESTS_C+= t_snapshot_log
diff -r b1367d46a096 -r 0c310357d7ec tests/fs/ffs/clients/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/ffs/clients/Makefile Fri Jan 28 18:38:07 2011 +0000
@@ -0,0 +1,36 @@
+# $NetBSD: Makefile,v 1.1.2.1 2011/01/28 18:38:08 bouyer Exp $
+#
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/fs/ffs
+WARNS= 4
+
+PROGS= rump_quota rump_repquota
+
+.PATH: ${NETBSDSRCDIR}/usr.bin/quota
+SRCS.rump_quota= quota.c printquota.c quota_rumpops.c
+SRCS.rump_repquota= printquota.c quota_rumpops.c
+CPPFLAGS.quota.c+= -I${NETBSDSRCDIR}/sys -I${NETBSDSRCDIR}/usr.bin/quota
+CPPFLAGS.printquota.c+= -I${NETBSDSRCDIR}/sys -I${NETBSDSRCDIR}/usr.bin/quota
+
+.PATH: ${NETBSDSRCDIR}/usr.sbin/repquota
+SRCS.rump_repquota+= repquota.c
+CPPFLAGS.repquota.c+= -I${NETBSDSRCDIR}/sys -I${NETBSDSRCDIR}/usr.bin/quota
+
+.PATH: ${NETBSDSRCDIR}/sys/ufs/ufs
+SRCS.rump_quota+= quota2_prop.c
+SRCS.rump_repquota+= quota2_prop.c
+CPPFLAGS.quota2_prop.c+=-I${NETBSDSRCDIR}/sys -I${NETBSDSRCDIR}/usr.bin/quota
+
+DPADD.rump_quota= ${LIBRPCSVC} ${LIBPROP} ${LIBRUMPCLIENT}
+LDADD.rump_quota= -lrpcsvc -lprop -lrumpclient
+MAN.rump_quota= # empty
+BINDIR.rump_quota= ${TESTSDIR}
+
+DPADD.rump_repquota= ${LIBRPCSVC} ${LIBPROP} ${LIBRUMPCLIENT}
+LDADD.rump_repquota= -lrpcsvc -lprop -lrumpclient
+MAN.rump_repquota= # empty
+BINDIR.rump_repquota= ${TESTSDIR}
+
+.include <bsd.test.mk>
diff -r b1367d46a096 -r 0c310357d7ec tests/fs/ffs/clients/quota_rumpops.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/ffs/clients/quota_rumpops.c Fri Jan 28 18:38:07 2011 +0000
@@ -0,0 +1,89 @@
+/* $NetBSD: quota_rumpops.c,v 1.1.2.1 2011/01/28 18:38:08 bouyer Exp $ */
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: quota_rumpops.c,v 1.1.2.1 2011/01/28 18:38:08 bouyer Exp $");
+#endif /* !lint */
+
+#include <stdio.h>
+#include <err.h>
+#include <sys/types.h>
+#include <sys/quota.h>
+#include <sys/statvfs.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+#include <rump/rumpclient.h>
+
+#ifdef DEBUGJACK
+#define DPRINTF(x) mydprintf x
+static void
+mydprintf(const char *fmt, ...)
+{
+ va_list ap;
+
+ if (ISDUP2D(STDERR_FILENO))
+ return;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
+#else
+#define DPRINTF(x)
+#endif
+
+static void __attribute__((constructor))
+rcinit(void)
+{
+ DPRINTF("rcinit\n");
+ if (rumpclient_init() == -1)
+ err(1, "rump client init");
+}
+
+int __quotactl50(const char *, struct plistref *);
+int
+__quotactl50(const char * mnt, struct plistref *p)
+{
+ int error;
+ error = rump_sys_quotactl(mnt, p);
+ DPRINTF(("quotactl <- %d\n", error));
+ return error;
+}
+
+int
+getvfsstat(struct statvfs *buf, size_t bufsize, int flags)
+{
+ int error;
+
+ error = rump_sys_getvfsstat(buf, bufsize, flags);
+ DPRINTF(("getvfsstat <- %d\n", error));
+ return error;
+}
diff -r b1367d46a096 -r 0c310357d7ec tests/fs/ffs/quotas_common.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/ffs/quotas_common.sh Fri Jan 28 18:38:07 2011 +0000
@@ -0,0 +1,51 @@
+# $NetBSD: quotas_common.sh,v 1.1.2.1 2011/01/28 18:38:07 bouyer Exp $
+
+create_with_quotas()
+{
+ 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}
+ #atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_server \
+ # ${IMG} ${RUMP_SERVER}
+ $(atf_get_srcdir)/h_quota2_server ${IMG} ${RUMP_SERVER} &
+}
+
+# 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}"
+ }"
+ eval "${name}_body() { \
+ ${check_function} " "${@}" "; \
+ }"
+ eval "${name}_cleanup() { \
+ atf_check -s exit:1 -o ignore -e ignore rump.halt; \
+ }"
+ tests="${tests} ${name}"
+}
+
+atf_init_test_cases()
+{
+ IMG=fsimage
+ DIR=target
+ RUMP_SERVER=unix:///tmp/test
+ export RUMP_SERVER
+ for i in ${tests}; do
+ atf_add_test_case $i
+ done
+}
diff -r b1367d46a096 -r 0c310357d7ec tests/fs/ffs/t_getquota.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/ffs/t_getquota.sh Fri Jan 28 18:38:07 2011 +0000
@@ -0,0 +1,101 @@
+# $NetBSD: t_getquota.sh,v 1.1.2.1 2011/01/28 18:38:07 bouyer Exp $
+#
+# Copyright (c) 2011 Manuel Bouyer
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+for e in le be; do
+ for v in 1 2; do
+ for q in "user" "group"; do
+ test_case get_${e}_${v}_${q} get_quota \
+ "get quota with ${q} enabled" ${e} ${v} ${q}
+ done
+ test_case get_${e}_${v}_"both" get_quota \
+ "get quota with both enabled" ${e} ${v} "both"
+ done
+done
+
+get_quota()
+{
+ create_with_quotas $*
+ local q=$3
+ local expect
+ local fail
+
+ case ${q} in
+ user)
+ expect=u
+ fail=g
+ ;;
+ group)
+ expect=g
+ fail=u
+ ;;
+ both)
+ expect="u g"
+ fail=""
+ ;;
+ *)
+ atf_fail "wrong quota type"
+ ;;
+ esac
+
+#check that we can get the expected quota
+ for q in ${expect} ; do
+ atf_check -s exit:0 \
+-o "match:/mnt 0 - - 1 - -" \
+-o "match:Disk quotas for .*: $" \
+ $(atf_get_srcdir)/rump_quota -${q} -v
+ atf_check -s exit:0 \
+-o "match:-- 0 - - 1 - -" \
+ $(atf_get_srcdir)/rump_repquota -${q} /mnt
+ done
+
+#check that we do not get positive reply for non-expected quota
+ for q in ${fail} ; do
+ atf_check -s exit:0 -o "not-match:/mnt" \
+ -o "not-match:Disk quotas for .*: $" \
+ -o "match:Disk quotas for .*: none$" \
Home |
Main Index |
Thread Index |
Old Index