]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh
FreeBSD: Add zfs_link_create() error handling
[mirror_zfs.git] / tests / zfs-tests / tests / functional / procfs / procfs_list_concurrent_readers.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or https://opensource.org/licenses/CDDL-1.0.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright (c) 2018 by Delphix. All rights reserved.
25 #
26
27 . $STF_SUITE/include/libtest.shlib
28
29 #
30 # DESCRIPTION:
31 # Make sure that interleaving reads from different readers does not affect the
32 # results that are returned.
33 #
34 # STRATEGY:
35 # 1. Make sure a few debug messages have been logged.
36 # 2. Open the procfs file and start reading from it.
37 # 3. Open the file again, and read its entire contents.
38 # 4. Resume reading from the first instance.
39 # 5. Check that the contents read by the two instances are identical.
40 #
41
42 function cleanup
43 {
44 log_must rm -f $msgs1 $msgs2
45 datasetexists $FS && destroy_dataset $FS -r
46 }
47
48 typeset -r ZFS_DBGMSG=/proc/spl/kstat/zfs/dbgmsg
49 typeset -r FS=$TESTPOOL/fs
50 typeset msgs1 msgs2
51
52 log_onexit cleanup
53
54 # Clear out old messages
55 echo 0 >$ZFS_DBGMSG || log_fail "failed to write to $ZFS_DBGMSG"
56
57 # Add some new messages
58 log_must zfs create $FS
59 for i in {1..20}; do
60 log_must zfs snapshot "$FS@testsnapshot$i"
61 done
62 sync_pool $TESTPOOL
63
64 msgs1=$(mktemp) || log_fail
65 msgs2=$(mktemp) || log_fail
66
67 #
68 # Start reading file, pause and read it from another process, and then finish
69 # reading.
70 #
71 { dd bs=512 count=4; cp $ZFS_DBGMSG $msgs1; cat; } <$ZFS_DBGMSG >$msgs2
72
73 #
74 # Truncate the result of the read that completed second in case it picked up an
75 # extra message that was logged after the first read completed.
76 #
77 log_must truncate -s $(stat_size $msgs1) $msgs2
78
79 log_must diff $msgs1 $msgs2
80
81 log_pass "Concurrent readers receive identical results"