freebsd-dev/tests/sys
Eric van Gyzen 11ed0a95bf zfs tests: stop writing to arbitrary devices
TL;DR:  Three ZFS tests created ZFS pools on all unmounted devices listed
in /etc/fstab, corrupting their contents.  Stop that.

Imagine my surprise when the ESP on my main dev/test VM would "randomly"
become corrupted, making it unbootable.  Three tests collect various devices
from the system and try to add them to a test pool.  The test expects this
to fail because it _assumes_ these devices are in use and ZFS will correctly
reject the request.

My /etc/fstab has two entries for devices in /dev:

    /dev/gpt/swap0  none        swap    sw,trimonce,late
    /dev/gpt/esp0   /boot/efi   msdosfs rw,noauto

Note the `noauto` on the ESP.  In a remarkable example of irony, I chose
this because it should keep the ESP more protected from corruption;
in fact, mounting it would have protected it from this case.

The tests added all of these devices to a test pool in a _single command_,
expecting the command to fail.  The swap device was in use, so the command
correctly failed, but the ESP was added and therefore corrupted.  However,
since the command correctly failed, the test didn't notice the ESP problem.
If each device had been added with its own command, the test _might_ have
noticed that one of them incorrectly succeeded.  However, two of these
tests would not have noticed:

hotspare_create_001_neg was incorrectly specified as needing the Solaris
dumpadm command, so it was skipped.  _Some_ of the test needs that command,
but it checks for its presence and runs fine without it.

Due to bug 241070, zpool_add_005_pos was marked as an expected failure.
Due to the coarse level of integration with ATF, this test would still
"pass" even if it failed for the wrong reason.  I wrote bug 267554 to
reconsider the use of atf_expect_fail in these tests.

Let's further consider the use of various devices found around the system.
In addition to devices in /etc/fstab, the tests also used mounted devices
listed by the `mount` command.  If ZFS behaves correctly, it will refuse
to added mounted devices and swap devices to a pool.  However, these are
unit tests used by developers to ensure that ZFS still works after they
modify it, so it's reasonable to expect ZFS to do the _wrong_ thing
sometimes.  Using random host devices is unsafe.

Fix the root problem by using only the disks provided via the "disks"
variable in kyua.conf.  Use one to create a UFS file system and mount it.
Use another as a swap device.  Use a third as a dump device, but expect
it to fail due to bug 241070.

While I'm here:

Due to commit 6b6e2954dd, we can simply add a second dump device and
remove it in cleanup.  We no longer need to save, replace, and restore the
pre-existing dump device.

The cleanup_devices function used `camcontrol inquiry` to distinguish disks
from other devices, such as partitions.  That works fine for SCSI, but not
for ATA or VirtIO block.  Use `geom disk list` instead.

PR:		241070
PR:		267554
Reviewed by:	asomers
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D37257
2022-11-11 14:43:47 -06:00
..
acl tests/sys/acl: Add ATF C test for newly added acl_* functions. 2021-08-27 11:52:21 +03:00
aio Reap dead code in lio_kqueue_test and aio_kqueue_test 2022-07-24 09:31:40 -06:00
audit Extend the length of dirpath to fix failure in kyua test 2022-04-12 09:23:56 -07:00
auditpipe
capsicum Fix MK_TESTS build with MK_ASAN/MK_UBSAN 2021-08-02 14:33:24 +01:00
cddl zfs tests: stop writing to arbitrary devices 2022-11-11 14:43:47 -06:00
common tests: partial revert of 4627bc1e90 2022-09-06 20:54:49 -07:00
devrandom
fifo
file path_test: Verify that operations on unlinked files work 2022-04-18 17:55:24 -04:00
fs fusefs: fix VOP_ADVLOCK with SEEK_END 2022-10-18 19:11:49 -06:00
geom Skip sys.geom.class.multipath.failloop.failloop if dtrace fails to run 2022-03-08 18:12:40 +08:00
kern tests: also remove sparc64 case 2022-11-08 18:55:00 -05:00
kqueue kqueue tests: Simplify the test runner 2022-05-24 20:17:41 -04:00
mac
mqueue
net if_ovpn tests: add aes-128-gcm test case 2022-11-11 11:17:39 +01:00
netgraph Remove riscv workaround in sys.netgraph.hub.loop test 2021-12-05 11:12:40 -04:00
netinet Split netinet shell tests into one per line. 2022-10-28 13:36:12 -07:00
netinet6 netinet6: fix interface handling for loopback traffic 2022-07-10 12:47:47 +00:00
netipsec ipsec tests: add test case for chacha20_poly1305 2022-11-02 14:19:37 +01:00
netmap netmap: update unit tests with libnetmap tests 2021-04-02 14:39:30 +00:00
netpfil netpfil tests: add dummynet fq_codel test case 2022-11-11 11:55:59 +01:00
opencrypto test/sys/opencrypto: Fix NIST KAT parser iterator 2022-10-06 16:42:31 +02:00
pjdfstest
posixshm posixshm tests: Map the large pages in the madvise test 2022-09-26 08:58:10 -04:00
ses tests/sys/ses: Use ANSI C definition for has_ses. 2022-02-01 13:25:47 -08:00
sys rb_tree: test rank balance 2022-09-07 21:40:05 -05:00
vfs tests/sys/vfs/lookup_cap_dotdot: No longer aborts after ATF update 2021-02-04 17:57:27 +00:00
vm shared_shadow_inval_test: fix copy-pasto in error message 2022-08-24 13:03:11 -05:00
vmm vmm: Add credential to cdev object 2021-08-18 13:41:33 -04:00
Makefile Add tests for ses(4) 2022-01-19 12:43:51 -07:00
Makefile.depend
Makefile.inc