tests: move C test helpers into test cmd

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-22 20:09:35 +01:00 committed by Brian Behlendorf
parent 1948f6dbbf
commit 20093de25c
55 changed files with 103 additions and 216 deletions

View File

@ -640,7 +640,9 @@ tests = ['history_001_pos', 'history_002_pos', 'history_003_pos',
tags = ['functional', 'history']
[tests/functional/hkdf]
tests = ['run_hkdf_test']
pre =
post =
tests = ['hkdf_test']
tags = ['functional', 'hkdf']
[tests/functional/inheritance]

View File

@ -438,7 +438,9 @@ tests = ['history_004_pos', 'history_005_neg', 'history_007_pos',
tags = ['functional', 'history']
[tests/functional/hkdf]
tests = ['run_hkdf_test']
pre =
post =
tests = ['hkdf_test']
tags = ['functional', 'hkdf']
[tests/functional/inuse]

View File

@ -32,3 +32,14 @@
/user_ns_exec
/write_dos_attributes
/xattrtest
/zed_fd_spill-zedlet
/suid_write_to_file
/cp_files
/ctime
/truncate_test
/ereports
/zfs_diff-socket
/dosmode_readonly_write
/edonr_test
/skein_test
/sha2_test

View File

@ -124,6 +124,45 @@ pkgexec_PROGRAMS += threadsappend
threadsappend_SOURCES = threadsappend.c
threadsappend_LDADD = -lpthread
pkgexec_PROGRAMS += suid_write_to_file
suid_write_to_file_SOURCES = suid_write_to_file.c
pkgexec_PROGRAMS += cp_files
cp_files_SOURCES = cp_files.c
pkgexec_PROGRAMS += ctime
ctime_SOURCES = ctime.c
pkgexec_PROGRAMS += truncate_test
truncate_test_SOURCES = truncate_test.c
pkgexec_PROGRAMS += ereports
ereports_SOURCES = ereports.c
ereports_LDADD = \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libzfs/libzfs.la
pkgexec_PROGRAMS += zfs_diff-socket
zfs_diff_socket_SOURCES = zfs_diff-socket.c
pkgexec_PROGRAMS += dosmode_readonly_write
dosmode_readonly_write_SOURCES = dosmode_readonly_write.c
pkgexec_PROGRAMS += edonr_test skein_test sha2_test
skein_test_SOURCES = checksum/skein_test.c
sha2_test_SOURCES = checksum/sha2_test.c
edonr_test_SOURCES = checksum/edonr_test.c
skein_test_LDADD = \
$(abs_top_builddir)/lib/libicp/libicp.la \
$(abs_top_builddir)/lib/libspl/libspl_assert.la
sha2_test_LDADD = \
$(abs_top_builddir)/lib/libicp/libicp.la \
$(abs_top_builddir)/lib/libspl/libspl_assert.la
edonr_test_LDADD = \
$(abs_top_builddir)/lib/libicp/libicp.la \
$(abs_top_builddir)/lib/libspl/libspl_assert.la
if BUILD_LINUX
pkgexec_PROGRAMS += getversion
@ -142,4 +181,7 @@ user_ns_exec_SOURCES = user_ns_exec.c
pkgexec_PROGRAMS += xattrtest
xattrtest_SOURCES = xattrtest.c
pkgexec_PROGRAMS += zed_fd_spill-zedlet
zed_fd_spill_zedlet_SOURCES = zed_fd_spill-zedlet.c
endif

View File

@ -42,7 +42,7 @@
* When the class and all of these values match, then an ereport is
* considered to be a duplicate.
*/
static const char *criteria_name[] = {
static const char *const criteria_name[] = {
FM_EREPORT_PAYLOAD_ZFS_POOL,
FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID,
FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR,

View File

@ -206,4 +206,15 @@ export ZFSTEST_FILES='badsend
user_ns_exec
write_dos_attributes
xattrtest
stride_dd'
stride_dd
zed_fd_spill-zedlet
suid_write_to_file
cp_files
edonr_test
skein_test
sha2_test
ctime
truncate_test
ereports
zfs_diff-socket
dosmode_readonly_write'

View File

@ -1 +0,0 @@
/dosmode_readonly_write

View File

@ -1,5 +1,3 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl/off
dist_pkgdata_SCRIPTS = \
@ -7,8 +5,3 @@ dist_pkgdata_SCRIPTS = \
posixmode.ksh \
cleanup.ksh \
setup.ksh
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl/off
pkgexec_PROGRAMS = dosmode_readonly_write
dosmode_readonly_write_SOURCES = dosmode_readonly_write.c

View File

@ -64,7 +64,6 @@ function hasflag
log_assert "Verify DOS mode flags function correctly"
log_onexit cleanup
tests_base=$STF_SUITE/tests/functional/acl/off
testfile=$TESTDIR/testfile
owner=$ZFS_ACL_STAFF1
other=$ZFS_ACL_STAFF2
@ -157,7 +156,7 @@ log_must rm $testfile
# READONLY is set. We have a special test program for that.
log_must user_run $owner touch $testfile
log_mustnot user_run $other $changeflags rdonly $testfile
log_must user_run $owner $tests_base/dosmode_readonly_write $testfile
log_must user_run $owner dosmode_readonly_write $testfile
log_mustnot user_run $other $changeflags nordonly $testfile
log_must hasflag rdonly $testfile
if ! is_linux; then

View File

@ -1,4 +0,0 @@
skein_test
edonr_test
sha2_test

View File

@ -1,9 +1,3 @@
include $(top_srcdir)/config/Rules.am
LDADD = \
$(abs_top_builddir)/lib/libicp/libicp.la \
$(abs_top_builddir)/lib/libspl/libspl_assert.la
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/checksum
dist_pkgdata_SCRIPTS = \
@ -17,15 +11,3 @@ dist_pkgdata_SCRIPTS = \
dist_pkgdata_DATA = \
default.cfg
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/checksum
pkgexec_PROGRAMS = \
edonr_test \
skein_test \
sha2_test
skein_test_SOURCES = skein_test.c
sha2_test_SOURCES = sha2_test.c
edonr_test_SOURCES = edonr_test.c

View File

@ -25,6 +25,6 @@
log_assert "Run the tests for the EdonR hash algorithm."
freq=$(get_cpu_freq)
log_must $STF_SUITE/tests/functional/checksum/edonr_test $freq
log_must edonr_test $freq
log_pass "EdonR tests passed."

View File

@ -25,6 +25,6 @@
log_assert "Run the tests for the SHA-2 hash algorithm."
freq=$(get_cpu_freq)
log_must $STF_SUITE/tests/functional/checksum/sha2_test $freq
log_must sha2_test $freq
log_pass "SHA-2 tests passed."

View File

@ -25,6 +25,6 @@
log_assert "Run the tests for the Skein hash algorithm."
freq=$(get_cpu_freq)
log_must $STF_SUITE/tests/functional/checksum/skein_test $freq
log_must skein_test $freq
log_pass "Skein tests passed."

View File

@ -1 +0,0 @@
/socket

View File

@ -1,5 +1,3 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_diff
dist_pkgdata_SCRIPTS = \
@ -11,8 +9,3 @@ dist_pkgdata_SCRIPTS = \
zfs_diff_mangle.ksh \
zfs_diff_timestamp.ksh \
zfs_diff_types.ksh
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_diff
pkgexec_PROGRAMS = socket
socket_SOURCES = socket.c

View File

@ -123,7 +123,7 @@ verify_object_class "$MNTPOINT/dir" "/"
# 2. = (Socket)
log_must zfs snapshot "$TESTSNAP1"
log_must $STF_SUITE/tests/functional/cli_root/zfs_diff/socket "$MNTPOINT/sock"
log_must zfs_diff-socket "$MNTPOINT/sock"
log_must zfs snapshot "$TESTSNAP2"
verify_object_class "$MNTPOINT/sock" "="

View File

@ -1 +0,0 @@
/ereports

View File

@ -1,7 +1,4 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_events
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_events
dist_pkgdata_SCRIPTS = \
setup.ksh \
@ -17,10 +14,3 @@ dist_pkgdata_SCRIPTS = \
dist_pkgdata_DATA = \
zpool_events.cfg \
zpool_events.kshlib
ereports_LDADD = \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libzfs/libzfs.la
pkgexec_PROGRAMS = ereports
ereports_SOURCES = ereports.c

View File

@ -55,8 +55,6 @@ OLD_LEN_MAX=$(get_tunable ZEVENT_LEN_MAX)
RETAIN_MAX=$(get_tunable ZEVENT_RETAIN_MAX)
OLD_CHECKSUMS=$(get_tunable CHECKSUM_EVENTS_PER_SECOND)
EREPORTS="$STF_SUITE/tests/functional/cli_root/zpool_events/ereports"
function cleanup
{
log_must set_tunable64 CHECKSUM_EVENTS_PER_SECOND $OLD_CHECKSUMS
@ -78,7 +76,7 @@ function damage_and_repair
log_must dd conv=notrunc if=$SUPPLY of=$VDEV1 bs=1M seek=4 count=$DAMAGEBLKS
log_must zpool scrub $POOL
log_must zpool wait -t scrub $POOL
log_note "pass $1 observed $($EREPORTS | grep -c checksum) checksum ereports"
log_note "pass $1 observed $(ereports | grep -c checksum) checksum ereports"
repaired=$(zpool status $POOL | awk '/scan: scrub repaired/ {print $4}')
if [ "$repaired" == "0B" ]; then

View File

@ -46,8 +46,6 @@ FILESIZE="10M"
OLD_LEN_MAX=$(get_tunable ZEVENT_LEN_MAX)
RETAIN_MAX=$(get_tunable ZEVENT_RETAIN_MAX)
EREPORTS="$STF_SUITE/tests/functional/cli_root/zpool_events/ereports"
duplicates=false
function cleanup
@ -117,7 +115,7 @@ function do_dup_test
log_must zinject -c all
ereports="$($EREPORTS | sort)"
ereports="$(ereports | sort)"
actual=$(echo "$ereports" | wc -l)
unique=$(echo "$ereports" | uniq | wc -l)
log_note "$actual total $ERR $RW ereports where $unique were unique"

View File

@ -1 +0,0 @@
/cp_files

View File

@ -1,13 +1,6 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cp_files
dist_pkgdata_SCRIPTS = \
cp_files_001_pos.ksh \
cleanup.ksh \
setup.ksh
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cp_files
pkgexec_PROGRAMS = cp_files
cp_files_SOURCES= cp_files.c

View File

@ -55,8 +55,7 @@ log_onexit cleanup
NR_FILES=60000
BATCH=1000
log_must mkdir $TESTDIR/src
log_must mkdir $TESTDIR/dst
log_must mkdir $TESTDIR/src $TESTDIR/dst
WD=$PWD
cd $TESTDIR/src
@ -67,7 +66,7 @@ cd $WD
log_must test $NR_FILES -eq $(ls -U $TESTDIR/src | wc -l)
# copy files from src to dst, use cp_files to make sure we copy in readdir order
log_must $STF_SUITE/tests/functional/cp_files/cp_files $TESTDIR/src $TESTDIR/dst
log_must cp_files $TESTDIR/src $TESTDIR/dst
log_must test $NR_FILES -eq $(ls -U $TESTDIR/dst | wc -l)

View File

@ -1 +0,0 @@
/ctime

View File

@ -1,13 +1,6 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime
dist_pkgdata_SCRIPTS = \
ctime_001_pos.ksh \
cleanup.ksh \
setup.ksh
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime
pkgexec_PROGRAMS = ctime
ctime_SOURCES = ctime.c

View File

@ -38,7 +38,7 @@ log_note "Verify [acm]time is modified appropriately."
for arg in ${args[*]}; do
log_note "Testing with xattr set to $arg"
log_must zfs set xattr=$arg $TESTPOOL
log_must $STF_SUITE/tests/functional/ctime/ctime
log_must ctime
done
log_pass "PASS"

View File

@ -1 +0,0 @@
/zed_fd_spill-zedlet

View File

@ -1,5 +1,3 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/events
dist_pkgdata_SCRIPTS = \
setup.ksh \
@ -12,7 +10,3 @@ dist_pkgdata_SCRIPTS = \
dist_pkgdata_DATA = \
events.cfg \
events_common.kshlib
pkgexecdir = $(pkgdatadir)
pkgexec_PROGRAMS = zed_fd_spill-zedlet
zed_fd_spill_zedlet_SOURCES = zed_fd_spill-zedlet.c

View File

@ -48,13 +48,12 @@ logdir="$(mktemp -d)"
log_must ln -s "$logdir" /tmp/zts-zed_fd_spill-logdir
self="$(readlink -f "$0")"
zedlet="${self%/*}/zed_fd_spill-zedlet"
log_must ln -s $zedlet "${ZEDLET_DIR}/all-dumpfds"
zedlet="$(command -v zed_fd_spill-zedlet)"
log_must ln -s "$zedlet" "${ZEDLET_DIR}/all-dumpfds"
# zed will cry foul and refuse to run it if this isn't true
sudo chown root $zedlet
sudo chmod 700 $zedlet
sudo chown root "$zedlet"
sudo chmod 700 "$zedlet"
log_must zpool events -c
log_must zed_stop

View File

@ -1,17 +1,8 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/hkdf
dist_pkgdata_SCRIPTS = \
setup.ksh \
cleanup.ksh \
run_hkdf_test.ksh
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/hkdf
pkgexec_PROGRAMS = \
hkdf_test
pkgexec_PROGRAMS = hkdf_test
hkdf_test_SOURCES = hkdf_test.c
hkdf_test_LDADD = \
$(abs_top_builddir)/lib/libzpool/libzpool.la

View File

@ -1,22 +0,0 @@
#!/bin/ksh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2017 by Datto Inc. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
verify_runnable "global"
log_pass

View File

@ -1,30 +0,0 @@
#!/bin/ksh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2017 by Datto Inc. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Call the hkdf_test tool to test ZFS's HKDF implementation against
# a few test vectors.
#
log_assert "Run the tests for the HKDF algorithm."
log_must $STF_SUITE/tests/functional/hkdf/hkdf_test
log_pass "HKDF tests pass."

View File

@ -1,22 +0,0 @@
#!/bin/ksh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2017 by Datto Inc. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
verify_runnable "global"
log_pass

View File

@ -1,7 +1,6 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/libzfs
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/libzfs
dist_pkgdata_SCRIPTS = \
@ -9,9 +8,7 @@ dist_pkgdata_SCRIPTS = \
setup.ksh \
libzfs_input.ksh
many_fds_LDADD = \
$(abs_top_builddir)/lib/libzfs/libzfs.la
pkgexec_PROGRAMS = many_fds
many_fds_SOURCES = many_fds.c
many_fds_LDADD = \
$(abs_top_builddir)/lib/libzfs/libzfs.la

View File

@ -1 +0,0 @@
/suid_write_to_file

View File

@ -1,5 +1,3 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/suid
dist_pkgdata_SCRIPTS = \
@ -10,8 +8,3 @@ dist_pkgdata_SCRIPTS = \
suid_write_zil_replay.ksh \
cleanup.ksh \
setup.ksh
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/suid
pkgexec_PROGRAMS = suid_write_to_file
suid_write_to_file_SOURCES = suid_write_to_file.c

View File

@ -47,6 +47,6 @@ function cleanup
log_onexit cleanup
log_note "Verify write(2) to regular file by non-owner"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "PRECRASH"
log_must suid_write_to_file "NONE" "PRECRASH"
log_pass "Verify write(2) to regular file by non-owner passed"

View File

@ -47,6 +47,6 @@ function cleanup
log_onexit cleanup
log_note "Verify write(2) to SGID file by non-owner"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "PRECRASH"
log_must suid_write_to_file "SGID" "PRECRASH"
log_pass "Verify write(2) to SGID file by non-owner passed"

View File

@ -47,6 +47,6 @@ function cleanup
log_onexit cleanup
log_note "Verify write(2) to SUID file by non-owner"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "PRECRASH"
log_must suid_write_to_file "SUID" "PRECRASH"
log_pass "Verify write(2) to SUID file by non-owner passed"

View File

@ -47,6 +47,6 @@ function cleanup
log_onexit cleanup
log_note "Verify write(2) to SUID/SGID file by non-owner"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "PRECRASH"
log_must suid_write_to_file "SUID_SGID" "PRECRASH"
log_pass "Verify write(2) to SUID/SGID file by non-owner passed"

View File

@ -65,10 +65,10 @@ log_must zpool freeze $TESTPOOL
#
# 3. Unprivileged write to a setuid file
#
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "PRECRASH"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "PRECRASH"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "PRECRASH"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "PRECRASH"
log_must suid_write_to_file "NONE" "PRECRASH"
log_must suid_write_to_file "SUID" "PRECRASH"
log_must suid_write_to_file "SGID" "PRECRASH"
log_must suid_write_to_file "SUID_SGID" "PRECRASH"
#
# 4. Unmount filesystem and export the pool
@ -91,9 +91,9 @@ log_must zpool export $TESTPOOL
#
log_must zpool import -f -d $VDIR $TESTPOOL
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "REPLAY"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "REPLAY"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "REPLAY"
log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "REPLAY"
log_must suid_write_to_file "NONE" "REPLAY"
log_must suid_write_to_file "SUID" "REPLAY"
log_must suid_write_to_file "SGID" "REPLAY"
log_must suid_write_to_file "SUID_SGID" "REPLAY"
log_pass

View File

@ -1 +0,0 @@
/truncate_test

View File

@ -1,5 +1,3 @@
include $(top_srcdir)/config/Rules.am
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/truncate
dist_pkgdata_SCRIPTS = \
@ -11,8 +9,3 @@ dist_pkgdata_SCRIPTS = \
dist_pkgdata_DATA = \
truncate.cfg
pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/truncate
pkgexec_PROGRAMS = truncate_test
truncate_test_SOURCES = truncate_test.c

View File

@ -42,7 +42,7 @@ function verify_truncate # <filename> <filesize> <option>
typeset -i timestm="$(stat -f "%m" $filename)"
typeset -i timestc="$(stat -f "%c" $filename)"
log_must sleep 1
log_must $STF_SUITE/tests/functional/truncate/truncate_test -s $size $filename $option
log_must truncate_test -s $size $filename $option
verify_eq $size "$(stat_size $filename)" "size"
verify_ne $timestm "$(stat -f "%m" $filename)" "mtime"
verify_ne $timestc "$(stat -f "%c" $filename)" "ctime"
@ -50,7 +50,7 @@ function verify_truncate # <filename> <filesize> <option>
typeset -i timestm="$(stat -c %Y $filename)"
typeset -i timestc="$(stat -c %Z $filename)"
log_must sleep 1
log_must $STF_SUITE/tests/functional/truncate/truncate_test -s $size $filename $option
log_must truncate_test -s $size $filename $option
verify_eq $size "$(stat_size $filename)" "size"
verify_ne $timestm "$(stat -c %Y $filename)" "mtime"
verify_ne $timestc "$(stat -c %Z $filename)" "ctime"