Perform quoting of variable expansions, etc correctly. That includes

(some) removing of quotes from where they're useless (superstition).

This should be NFC for these tests, as the data being quoted doesn't
happen to require it, but depending upon the data not altering, or the
code not being copied to a different environment is unwise, when it is
so easy to simply do it correctly.

A few line wrapping and white space changes as well.

Nothing changed here is intended to alter the way that the tests run,
or results generated.
This commit is contained in:
kre 2023-09-26 12:15:44 +00:00
parent 87f7d0994d
commit 5ae58755a4
4 changed files with 145 additions and 128 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: quotas_common.sh,v 1.2 2011/03/06 17:08:41 bouyer Exp $
# $NetBSD: quotas_common.sh,v 1.3 2023/09/26 12:15:44 kre Exp $
create_with_quotas()
{
@ -7,13 +7,13 @@ create_with_quotas()
local uid=$(id -u)
local gid=$(id -g)
atf_check -o ignore -e ignore newfs -B ${endian} -O ${vers} \
-s 4000 -F ${IMG}
atf_check -o ignore -e ignore tunefs -q user -q group -F ${IMG}
atf_check -o ignore -e ignore newfs -B "${endian}" -O "${vers}" \
-s 4000 -F "${IMG}"
atf_check -o ignore -e ignore tunefs -q user -q group -F "${IMG}"
atf_check -s exit:0 -o 'match:NO USER QUOTA INODE \(CREATED\)' \
-o 'match:USER QUOTA MISMATCH FOR ID '${uid}': 0/0 SHOULD BE 1/1' \
-o 'match:GROUP QUOTA MISMATCH FOR ID '${gid}': 0/0 SHOULD BE 1/1' \
fsck_ffs -p -F ${IMG}
-o "match:USER QUOTA MISMATCH FOR ID ${uid}: 0/0 SHOULD BE 1/1" \
-o "match:GROUP QUOTA MISMATCH FOR ID ${gid}: 0/0 SHOULD BE 1/1" \
fsck_ffs -p -F "${IMG}"
}
# from tests/ipf/h_common.sh via tests/sbin/resize_ffs
@ -25,20 +25,23 @@ test_case()
atf_test_case "${name}"
eval "${name}_head() { \
atf_set "descr" "Checks ${descr} quotas inodes"
eval "${name}_head() {
atf_set descr 'Checks ${descr} quotas inodes'
}"
eval "${name}_body() { \
${check_function} " "${@}" "; \
eval "${name}_body() {
${check_function} $*
}"
tests="${tests} ${name}"
tests="${tests} '${name}'"
}
atf_init_test_cases()
{
IMG=fsimage
DIR=target
for i in ${tests}; do
atf_add_test_case $i
eval "set -- ${tests}"
for i
do
atf_add_test_case "$i"
done
}

View File

@ -1,4 +1,4 @@
# $NetBSD: t_check_quotas.sh,v 1.2 2011/03/06 17:08:41 bouyer Exp $
# $NetBSD: t_check_quotas.sh,v 1.3 2023/09/26 12:15:44 kre Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
@ -27,27 +27,29 @@
for e in le be; do
for v in 1 2; do
test_case corrupt_list_${e}_${v} corrupt_list \
"recovery of corrupted free list in" ${e} ${v}
test_case expand1_list_${e}_${v} expand_list \
"allocation of direct block in" 40 ${e} ${v}
test_case expand2_list_${e}_${v} expand_list \
"allocation of indirect block in" 1000 ${e} ${v}
test_case "corrupt_list_${e}_${v}" corrupt_list \
"recovery of corrupted free list in" "${e}" "${v}"
test_case "expand1_list_${e}_${v}" expand_list \
"allocation of direct block in" 40 "${e}" "${v}"
test_case "expand2_list_${e}_${v}" expand_list \
"allocation of indirect block in" 1000 "${e}" "${v}"
done
done
corrupt_list()
{
create_with_quotas $*
local blkno=$(printf "inode 3\nblks\n" | /sbin/fsdb -nF -f ${IMG} | awk '$1 == "0:" {print $2}')
create_with_quotas "$@"
local blkno=$(printf "inode 3\nblks\n" |
/sbin/fsdb -nF -f "${IMG}" |
awk '$1 == "0:" {print $2}')
blkno=$(($blkno * 512 + 104))
#clear the free list
atf_check -o ignore -e ignore dd if=/dev/zero of=${IMG} bs=1 \
count=8 seek=${blkno} conv=notrunc
atf_check -o ignore -e ignore dd if=/dev/zero "of=${IMG}" bs=1 \
count=8 "seek=${blkno}" conv=notrunc
atf_check -s exit:0 \
-o "match:QUOTA ENTRY NOT IN LIST \(FIXED\)" \
fsck_ffs -fp -F ${IMG}
atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
fsck_ffs -fp -F "${IMG}"
atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F "${IMG}"
}
expand_list()
@ -57,17 +59,17 @@ expand_list()
echo "/set uid=0 gid=0" > spec
echo ". type=dir mode=0755" >> spec
mkdir ${DIR}
for i in $(seq ${nuid}); do
touch ${DIR}/f${i}
for i in $(seq "${nuid}"); do
touch "${DIR}/f${i}"
echo "./f$i type=file mode=0600 uid=$i gid=$i" >> spec
done
atf_check -o ignore -e ignore makefs -B $1 -o version=$2 \
-F spec -s 4000b ${IMG} ${DIR}
atf_check -o ignore -e ignore tunefs -q user -F ${IMG}
atf_check -o ignore -e ignore makefs -B "$1" -o "version=$2" \
-F spec -s 4000b "${IMG}" "${DIR}"
atf_check -o ignore -e ignore tunefs -q user -F "${IMG}"
atf_check -s exit:0 -o 'match:NO USER QUOTA INODE \(CREATED\)' \
-o 'match:USER QUOTA MISMATCH FOR ID 10: 0/0 SHOULD BE 0/1' \
fsck_ffs -p -F ${IMG}
fsck_ffs -p -F "${IMG}"
atf_check -s exit:0 -o "match:${expected_files} files" \
fsck_ffs -nf -F ${IMG}
fsck_ffs -nf -F "${IMG}"
}

View File

@ -1,4 +1,4 @@
# $NetBSD: t_enable_quotas.sh,v 1.3 2021/09/16 22:19:12 andvar Exp $
# $NetBSD: t_enable_quotas.sh,v 1.4 2023/09/26 12:15:44 kre Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
@ -27,79 +27,84 @@
for e in le be; do
for v in 1 2; do
test_case disable_${e}_${v} disable_quotas "creation/removal of" ${e} ${v}
test_case corrupt_${e}_${v} corrupt_quotas "repair of corrupted" ${e} ${v}
test_case unallocated_${e}_${v} unallocated_quotas \
"recovery of unallocated" ${e} ${v}
test_case dir1_${e}_${v} dir1_quotas \
"successful clear of wrong type of" ${e} ${v}
test_case notreg_${e}_${v} notreg_quotas \
"successful clear of wrong type of" ${e} ${v}
test_case "disable_${e}_${v}" disable_quotas \
"creation/removal of" "${e}" "${v}"
test_case "corrupt_${e}_${v}" corrupt_quotas \
"repair of corrupted" "${e}" "${v}"
test_case "unallocated_${e}_${v}" unallocated_quotas \
"recovery of unallocated" "${e}" "${v}"
test_case "dir1_${e}_${v}" dir1_quotas \
"successful clear of wrong type of" "${e}" "${v}"
test_case "notreg_${e}_${v}" notreg_quotas \
"successful clear of wrong type of" "${e}" "${v}"
done
done
disable_quotas()
{
create_with_quotas $*
create_with_quotas "$@"
# check that the quota inode creation didn't corrupt the filesystem
atf_check -s exit:0 -o "match:already clean" -o "match:3 files" \
fsck_ffs -nf -F ${IMG}
fsck_ffs -nf -F "${IMG}"
#now check fsck can properly clear the quota inode when quota flags are
# cleared
atf_check -o ignore -e ignore tunefs -q nouser -q nogroup -F ${IMG}
atf_check -o ignore -e ignore tunefs -q nouser -q nogroup -F "${IMG}"
atf_check -s exit:0 -o "match:SUPERBLOCK QUOTA FLAG CLEARED" \
fsck_ffs -fp -F ${IMG}
atf_check -s exit:0 -o "match:1 files, 1 used" fsck_ffs -nf -F ${IMG}
fsck_ffs -fp -F "${IMG}"
atf_check -s exit:0 -o "match:1 files, 1 used" fsck_ffs -nf -F "${IMG}"
}
corrupt_quotas()
{
create_with_quotas $*
create_with_quotas "$@"
local blkno=$(printf "inode 3\nblks\n" | /sbin/fsdb -nF -f ${IMG} | awk '$1 == "0:" {print $2}')
atf_check -o ignore -e ignore dd if=/dev/zero of=${IMG} bs=512 \
count=1 seek=${blkno} conv=notrunc
local blkno=$(printf "inode 3\nblks\n" |
/sbin/fsdb -nF -f "${IMG}" |
awk '$1 == "0:" {print $2}')
atf_check -o ignore -e ignore dd if=/dev/zero "of=${IMG}" bs=512 \
count=1 "seek=${blkno}" conv=notrunc
atf_check -s exit:0 \
-o "match:CORRUPTED USER QUOTA INODE 3 \(CLEARED\)" \
-o "match:NO USER QUOTA INODE \(CREATED\)" \
fsck_ffs -fp -F ${IMG}
atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
fsck_ffs -fp -F "${IMG}"
atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F "${IMG}"
}
unallocated_quotas()
{
create_with_quotas $*
create_with_quotas "$@"
atf_check -o ignore -e ignore clri ${IMG} 3
atf_check -o ignore -e ignore clri "${IMG}" 3
atf_check -s exit:0 \
-o "match:UNALLOCATED USER QUOTA INODE 3 \(CLEARED\)" \
-o "match:NO USER QUOTA INODE \(CREATED\)" \
fsck_ffs -fp -F ${IMG}
atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
fsck_ffs -fp -F "${IMG}"
atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F "${IMG}"
}
dir1_quotas()
{
create_with_quotas $*
create_with_quotas "$@"
atf_check -s exit:255 -o ignore -e ignore -x \
"printf 'inode 3\nchtype dir\nexit\n' | fsdb -F -f ${IMG}"
"printf 'inode 3\nchtype dir\nexit\n' | fsdb -F -f '${IMG}'"
atf_check -s exit:0 \
-o "match:DIR I=3 CONNECTED. PARENT WAS I=0" \
-o "match:USER QUOTA INODE 3 IS A DIRECTORY" \
fsck_ffs -y -F ${IMG}
fsck_ffs -y -F "${IMG}"
}
notreg_quotas()
{
create_with_quotas $*
create_with_quotas "$@"
atf_check -s exit:255 -o ignore -e ignore -x \
"printf 'inode 3\nchtype fifo\nexit\n' | fsdb -F -f ${IMG}"
"printf 'inode 3\nchtype fifo\nexit\n' | fsdb -F -f '${IMG}'"
atf_check -s exit:0 \
-o "match:WRONG TYPE 4096 for USER QUOTA INODE 3 \(CLEARED\)" \
-o "match:NO USER QUOTA INODE \(CREATED\)" \
fsck_ffs -p -F ${IMG}
atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
fsck_ffs -p -F "${IMG}"
atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F "${IMG}"
}

View File

@ -1,4 +1,4 @@
# $NetBSD: t_extattr.sh,v 1.4 2022/11/30 07:20:36 martin Exp $
# $NetBSD: t_extattr.sh,v 1.5 2023/09/26 12:15:44 kre Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@ -38,8 +38,8 @@ atf_test_case fsck_extattr_disable cleanup
cleanup()
{
echo in cleanup
umount -f ${MNT} > /dev/null 2>&1 || true
vnconfig -u ${VND} > /dev/null 2>&1 || true
umount -f "${MNT}" > /dev/null 2>&1 || true
vnconfig -u "${VND}" > /dev/null 2>&1 || true
}
fsck_extattr_enable_head()
@ -50,32 +50,32 @@ fsck_extattr_enable_head()
fsck_extattr_enable_body()
{
atf_check mkdir -p ${MNT}
atf_check mkdir -p "${MNT}"
atf_check -o ignore newfs -O2 -s 4m -F ${IMG}
atf_check vnconfig ${VND} ${IMG}
atf_check -o ignore newfs -O2 -s 4m -F "${IMG}"
atf_check vnconfig "${VND}" "${IMG}"
# Verify that extattrs are disabled.
atf_check -o ignore -e 'match:POSIX1e ACLs not supported by this fs' \
tunefs -p enable ${CDEV}
atf_check mount -t ffs ${BDEV} ${MNT}
atf_check touch ${MNT}/file
atf_check -s exit:1 -e ignore setextattr user name1 value1 ${MNT}/file
atf_check umount ${MNT}
tunefs -p enable "${CDEV}"
atf_check mount -t ffs "${BDEV}" "${MNT}"
atf_check touch "${MNT}/file"
atf_check -s exit:1 -e ignore setextattr user name1 value1 "${MNT}/file"
atf_check umount "${MNT}"
# Enable extattrs.
atf_check -o 'match:ENABLING EXTATTR SUPPORT' \
fsck_ffs -c ea ${CDEV}
fsck_ffs -c ea "${CDEV}"
# Verify that extattrs are now enabled.
atf_check -o 'match:POSIX1e ACLs set' -e ignore \
tunefs -p enable ${CDEV}
atf_check mount -t ffs ${BDEV} ${MNT}
atf_check touch ${MNT}/file
atf_check setextattr user testname testvalue ${MNT}/file
atf_check -o 'match:testvalue' getextattr user testname ${MNT}/file
atf_check umount ${MNT}
atf_check vnconfig -u ${VND}
tunefs -p enable "${CDEV}"
atf_check mount -t ffs "${BDEV}" "${MNT}"
atf_check touch "${MNT}/file"
atf_check setextattr user testname testvalue "${MNT}/file"
atf_check -o 'match:testvalue' getextattr user testname "${MNT}/file"
atf_check umount "${MNT}"
atf_check vnconfig -u "${VND}"
}
fsck_extattr_enable_cleanup()
@ -91,49 +91,55 @@ fsck_extattr_enable_corrupted_head()
fsck_extattr_enable_corrupted_body()
{
atf_check mkdir -p ${MNT}
atf_check mkdir -p "${MNT}"
# Create an fs with extattrs enabled and set an extattr on the test file.
atf_check -o ignore newfs -O2ea -b 8k -f 1k -s 4m -F ${IMG}
atf_check vnconfig ${VND} ${IMG}
atf_check -o ignore newfs -O2ea -b 8k -f 1k -s 4m -F "${IMG}"
atf_check vnconfig "${VND}" "${IMG}"
atf_check mount -t ffs ${BDEV} ${MNT}
atf_check touch ${MNT}/file
atf_check setextattr user testname testvalue ${MNT}/file
atf_check -o 'match:testvalue' getextattr user testname ${MNT}/file
atf_check umount ${MNT}
atf_check mount -t ffs "${BDEV}" "${MNT}"
atf_check touch "${MNT}/file"
atf_check setextattr user testname testvalue "${MNT}/file"
atf_check -o 'match:testvalue' getextattr user testname "${MNT}/file"
atf_check umount "${MNT}"
# Find the location and size of the extattr block.
extb0=$(printf 'cd file\niptrs\n' | fsdb -n $CDEV | grep 'di_extb 0' |
extb0=$(printf 'cd file\niptrs\n' |
fsdb -n "$CDEV" |
grep 'di_extb 0' |
awk '{print $3}')
extsize=$(printf 'cd file\n' | fsdb -n $CDEV | grep EXTSIZE | tail -1 |
awk '{print $4}' | sed 's,.*=,,')
atf_check [ $extb0 != 0 ]
atf_check [ $extsize != 0 ]
extsize=$(printf 'cd file\n' |
fsdb -n "$CDEV" |
grep EXTSIZE |
tail -n 1 |
awk '{print $4}' |
sed 's,.*=,,')
atf_check [ "$extb0" != 0 ]
atf_check [ "$extsize" != 0 ]
# Recreate the fs with extattrs disabled and set the extattr block
# size/location of the new test file to the same values as the old
# test file. This simulates extattrs having been created in a
# UFS2-non-ea file system before UFS2ea was invented.
atf_check -o ignore newfs -O2 -b 8k -f 1k -s 4m -F ${IMG}
atf_check mount -t ffs ${BDEV} ${MNT}
atf_check touch ${MNT}/file
atf_check umount ${MNT}
printf "cd file\nchextb 0 $extb0\n" | fsdb -N $CDEV
printf "cd file\nchextsize $extsize\n" | fsdb -N $CDEV
atf_check -o ignore newfs -O2 -b 8k -f 1k -s 4m -F "${IMG}"
atf_check mount -t ffs "${BDEV}" "${MNT}"
atf_check touch "${MNT}/file"
atf_check umount "${MNT}"
printf "cd file\nchextb 0 $extb0\n" | fsdb -N "$CDEV"
printf "cd file\nchextsize $extsize\n" | fsdb -N "$CDEV"
# Convert to enable extattrs.
atf_check -o 'match:CLEAR EXTATTR FIELDS' \
-o 'match:ENABLING EXTATTR SUPPORT' \
fsck_ffs -y -c ea ${CDEV}
fsck_ffs -y -c ea "${CDEV}"
# Verify that the test file does not have the extattr.
atf_check -o ignore fsck_ffs -n ${CDEV}
atf_check mount -t ffs ${BDEV} ${MNT}
atf_check -o ignore fsck_ffs -n "${CDEV}"
atf_check mount -t ffs "${BDEV}" "${MNT}"
atf_check -s exit:1 -e 'match:Attribute not found' \
getextattr user testname ${MNT}/file
atf_check umount ${MNT}
atf_check vnconfig -u ${VND}
getextattr user testname "${MNT}/file"
atf_check umount "${MNT}"
atf_check vnconfig -u "${VND}"
}
fsck_extattr_enable_corrupted_cleanup()
@ -149,42 +155,43 @@ fsck_extattr_disable_head()
fsck_extattr_disable_body()
{
atf_check mkdir -p ${MNT}
atf_check mkdir -p "${MNT}"
# Create an fs with extattrs enabled and set an extattr on the test file.
atf_check -o ignore newfs -O2ea -b 8k -f 1k -s 4m -F ${IMG}
atf_check vnconfig ${VND} ${IMG}
atf_check -o ignore newfs -O2ea -b 8k -f 1k -s 4m -F "${IMG}"
atf_check vnconfig "${VND}" "${IMG}"
atf_check mount -t ffs ${BDEV} ${MNT}
atf_check touch ${MNT}/file
atf_check setextattr user testname testvalue ${MNT}/file
atf_check -o 'match:testvalue' getextattr user testname ${MNT}/file
atf_check umount ${MNT}
atf_check mount -t ffs "${BDEV}" "${MNT}"
atf_check touch "${MNT}/file"
atf_check setextattr user testname testvalue "${MNT}/file"
atf_check -o 'match:testvalue' getextattr user testname "${MNT}/file"
atf_check umount "${MNT}"
# Convert to disable extattrs.
atf_check -o 'match:CLEAR EXTATTR FIELDS' \
-o 'match:DISABLING EXTATTR SUPPORT' \
fsck_ffs -y -c no-ea ${CDEV}
fsck_ffs -y -c no-ea "${CDEV}"
# Verify that the test file does not have the test extattr.
atf_check -o ignore fsck_ffs -n ${CDEV}
atf_check mount -t ffs ${BDEV} ${MNT}
atf_check -s exit:1 -e 'match:getextattr: mnt/file: failed: Operation not supported' \
getextattr user testname ${MNT}/file
atf_check umount ${MNT}
atf_check -o ignore fsck_ffs -n "${CDEV}"
atf_check mount -t ffs "${BDEV}" "${MNT}"
atf_check -s exit:1 \
-e 'match:getextattr: mnt/file: failed: Operation not supported' \
getextattr user testname "${MNT}/file"
atf_check umount "${MNT}"
# Convert to enable extattrs again.
atf_check -o 'match:ENABLING EXTATTR SUPPORT' \
fsck_ffs -y -c ea ${CDEV}
# Verify that the test extattr is still gone.
atf_check -o ignore fsck_ffs -n ${CDEV}
atf_check mount -t ffs ${BDEV} ${MNT}
atf_check -o ignore fsck_ffs -n "${CDEV}"
atf_check mount -t ffs "${BDEV}" "${MNT}"
atf_check -s exit:1 -e 'match:Attribute not found' \
getextattr user testname ${MNT}/file
atf_check umount ${MNT}
getextattr user testname "${MNT}/file"
atf_check umount "${MNT}"
atf_check vnconfig -u ${VND}
atf_check vnconfig -u "${VND}"
}
fsck_extattr_disable_cleanup()