7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / link_count / link_count_001.ksh
blob71e617ecf5e1393df43b6aa8792f8644057c1a47
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
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]
20 # CDDL HEADER END
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
35 # DESCRIPTION:
36 # Verify file link count is zero on zfs
38 # STRATEGY:
39 # 1. Make sure this test executes on multi-processes system
40 # 2. Make zero size files and remove them in the background
41 # 3. Call the binary
42 # 4. Make sure the files can be removed successfully
45 verify_runnable "both"
47 log_assert "Verify file link count is zero on zfs"
49 export ITERS=10
50 export NUMFILES=10000
52 # Detect and make sure this test must be executed on a multi-process system
53 is_mp || log_fail "This test requires a multi-processor system."
55 log_must mkdir -p ${TESTDIR}/tmp
57 typeset -i i=0
58 while [ $i -lt $NUMFILES ]; do
59 (( i = i + 1 ))
60 touch ${TESTDIR}/tmp/x$i > /dev/null 2>&1
61 done
63 sleep 3
65 rm -f ${TESTDIR}/tmp/x* >/dev/null 2>&1
67 rm_lnkcnt_zero_file ${TESTDIR}/tmp/test$$ > /dev/null 2>&1 &
68 PID=$!
69 log_note "rm_lnkcnt_zero_file ${TESTDIR}/tmp/test$$ pid: $PID"
71 i=0
72 while [ $i -lt $ITERS ]; do
73 if ! pgrep rm_lnkcnt_zero_file > /dev/null ; then
74 log_note "rm_lnkcnt_zero_file completes"
75 break
77 log_must sleep 10
78 (( i = i + 1 ))
79 done
81 if pgrep rm_lnkcnt_zero_file > /dev/null; then
82 log_must kill -TERM $PID
83 log_fail "file link count is zero"
86 log_must kill -TERM $PID
87 log_must rm -f ${TESTDIR}/tmp/test$$*
89 log_pass "Verify file link count is zero on zfs"