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
This commit is contained in:
bouyer 2012-01-18 20:51:23 +00:00
parent bb133a10ef
commit 9427679519
10 changed files with 147 additions and 133 deletions

View File

@ -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

View File

@ -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 @@ BINDIR.h_quota2_tests= ${TESTSDIR}
.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

View File

@ -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
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: h_quota2_server.c,v 1.2 2011/03/06 17:08:40 bouyer Exp $ */
/* $NetBSD: h_ffs_server.c,v 1.1 2012/01/18 20:51:23 bouyer Exp $ */
/*
* rump server for advanced quota tests

View File

@ -1,29 +1,6 @@
# $NetBSD: quotas_common.sh,v 1.3 2011/03/12 13:43:58 bouyer Exp $
# $NetBSD: quotas_common.sh,v 1.4 2012/01/18 20:51:23 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}
}
create_with_quotas_server()
{
local sarg=$1; shift
create_with_quotas $*
atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_server \
${sarg} ${IMG} ${RUMP_SERVER}
}
rump_shutdown()
rump_quota_shutdown()
{
for s in ${RUMP_SOCKETS_LIST}; do
atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt;
@ -33,67 +10,3 @@ rump_shutdown()
-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
}

View File

@ -1,4 +1,4 @@
# $NetBSD: t_clearquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $
# $NetBSD: t_clearquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
@ -40,7 +40,7 @@ done
clear_quota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local fail
@ -87,5 +87,5 @@ clear_quota()
-o "match:Disk quotas for .*: none$" \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
done
rump_shutdown
rump_quota_shutdown
}

View File

@ -1,4 +1,4 @@
# $NetBSD: t_getquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $
# $NetBSD: t_getquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
@ -38,7 +38,7 @@ done
get_quota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local fail
@ -83,12 +83,12 @@ get_quota()
-o "not-match:-- 0 - - 1 - -" \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt
done
rump_shutdown
rump_quota_shutdown
}
quota_walk_list()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect

View File

@ -1,4 +1,4 @@
# $NetBSD: t_miscquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $
# $NetBSD: t_miscquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
@ -55,7 +55,7 @@ test_case log_unlink_remount quota_log \
quota_walk_list()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
@ -84,13 +84,13 @@ quota_walk_list()
# do a repquota
atf_check -s exit:0 -o 'match:<integer>0x64000' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -x -${expect} /mnt
rump_shutdown
rump_quota_shutdown
}
quota_snap()
{
local flag=$1; shift
create_with_quotas $*
create_ffs $*
local q=$3
local expect
@ -124,13 +124,13 @@ quota_snap()
-o 'match:- - 7days 5 - - 7days' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -av
#shutdown and check filesystem
rump_shutdown
rump_quota_shutdown
}
quota_log()
{
local srv2args=$1; shift
create_with_quotas $*
create_ffs $*
local q=$3
local expect
@ -160,5 +160,5 @@ quota_log()
atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_tests \
${srv2args} -b 5 ${IMG} ${RUMP_SERVER}
#shutdown and check filesystem
rump_shutdown
rump_quota_shutdown
}

View File

@ -1,4 +1,4 @@
# $NetBSD: t_quotalimit.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $
# $NetBSD: t_quotalimit.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
@ -54,7 +54,7 @@ done
limit_quota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local id=1
@ -96,12 +96,12 @@ limit_quota()
-o match:'daemon \+- 3 2 3 2:0 2 4 6' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
done
rump_shutdown
rump_quota_shutdown
}
limit_softquota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local id=1
@ -143,12 +143,12 @@ limit_softquota()
-o match:'daemon \+- 2 2 3 none 2 4 6' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
done
rump_shutdown
rump_quota_shutdown
}
limit_iquota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local id=1
@ -190,12 +190,12 @@ limit_iquota()
-o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
done
rump_shutdown
rump_quota_shutdown
}
limit_softiquota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local id=1
@ -237,12 +237,12 @@ limit_softiquota()
-o match:'daemon -\+ 2 2048 3072 5 4 6 none' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
done
rump_shutdown
rump_quota_shutdown
}
inherit_defaultquota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local id=1
@ -289,12 +289,12 @@ inherit_defaultquota()
-o match:'daemon \+- 3 2 3 2:0 2 4 6' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
done
rump_shutdown
rump_quota_shutdown
}
inherit_defaultiquota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local id=1
@ -341,5 +341,5 @@ inherit_defaultiquota()
-o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
done
rump_shutdown
rump_quota_shutdown
}

View File

@ -1,4 +1,4 @@
# $NetBSD: t_setquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $
# $NetBSD: t_setquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
@ -48,7 +48,7 @@ done
set_quota()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local fail
@ -99,12 +99,12 @@ set_quota()
-o "not-match:-- 0 - -" \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt
done
rump_shutdown
rump_quota_shutdown
}
set_quota_new()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local fail
@ -149,12 +149,12 @@ set_quota_new()
-o "match:Disk quotas for .*: none$" \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
done
rump_shutdown
rump_quota_shutdown
}
set_quota_default()
{
create_with_quotas_server $*
create_ffs_server $*
local q=$4
local expect
local fail
@ -199,5 +199,5 @@ set_quota_default()
-o "match:Default (user|group) disk quotas: none$" \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
done
rump_shutdown
rump_quota_shutdown
}