]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_wait/zfs_wait_deleteq.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_wait / zfs_wait_deleteq.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source.  A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright (c) 2018 by Delphix. All rights reserved.
15 #
16
17 . $STF_SUITE/include/libtest.shlib
18 . $STF_SUITE/tests/functional/cli_root/zfs_wait/zfs_wait.kshlib
19
20 #
21 # DESCRIPTION:
22 # 'zfs wait' works when waiting for checkpoint discard to complete.
23 #
24 # STRATEGY:
25 # 1. Create a file
26 # 2. Open a file descriptor pointing to that file.
27 # 3. Delete the file.
28 # 4. Start a background process waiting for the delete queue to empty.
29 # 5. Verify that the command doesn't return immediately.
30 # 6. Close the open file descriptor.
31 # 7. Verify that the command returns soon after the descriptor is closed.
32 #
33
34 function cleanup
35 {
36         kill_if_running $pid
37         exec 3<&-
38 }
39
40
41 typeset -r TESTFILE="/$TESTPOOL/testfile"
42 typeset pid
43
44 log_onexit cleanup
45
46 log_must touch $TESTFILE
47 exec 3<> $TESTFILE
48 log_must rm $TESTFILE
49 log_bkgrnd zfs wait -t deleteq $TESTPOOL
50 pid=$!
51 proc_must_exist $pid
52
53 exec 3<&-
54 log_must sleep 0.5
55 bkgrnd_proc_succeeded $pid
56
57 log_pass "'zfs wait -t discard' works."