1#!/usr/local/bin/ksh93 -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 http://www.opensolaris.org/os/licensing. 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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: link_count_001 33# 34# DESCRIPTION: 35# Verify file link count is zero on zfs 36# 37# STRATEGY: 38# 1. Make sure this test executes on multi-processes system 39# 2. Make zero size files and remove them in the background 40# 3. Call the binary 41# 4. Make sure the files can be removed successfully 42# 43# TESTABILITY: explicit 44# 45# TEST_AUTOMATION_LEVEL: automated 46# 47# CODING_STATUS: COMPLETED (2006-07-13) 48# 49# __stc_assertion_end 50# 51################################################################################ 52 53verify_runnable "both" 54 55log_assert "Verify file link count is zero on zfs" 56 57# Detect and make sure this test must be executed on a multi-process system 58NCPUS=`sysctl -n kern.smp.cpus` 59#NCPUS=`sysctl -a | awk -F '"' '/cpu count="[0-9+]"/ {print $2; exit}'` 60if [[ $? -ne 0 || -z "$NCPUS" || "$NCPUS" -le 1 ]]; then 61 log_unsupported "This test must be executed on a multi-processor system." 62fi 63 64log_must $MKDIR -p ${TESTDIR}/tmp 65 66typeset -i i=0 67while [ $i -lt $NUMFILES ]; do 68 (( i = i + 1 )) 69 $TOUCH ${TESTDIR}/tmp/x$i > /dev/null 2>&1 70done 71 72sleep 3 73 74$RM -f ${TESTDIR}/tmp/x* >/dev/null 2>&1 75 76$RM_LNKCNT_ZERO_FILE ${TESTDIR}/tmp/test${TESTCASE_ID} > /dev/null 2>&1 & 77PID=$! 78log_note "$RM_LNKCNT_ZERO_FILE ${TESTDIR}/tmp/test${TESTCASE_ID} pid: $PID" 79 80i=0 81while [ $i -lt $ITERS ]; do 82 if ! $PGREP $RM_LNKCNT_ZERO_FILE > /dev/null ; then 83 log_note "$RM_LNKCNT_ZERO_FILE completes" 84 break 85 fi 86 log_must $SLEEP 10 87 (( i = i + 1 )) 88done 89 90if $PGREP $RM_LNKCNT_ZERO_FILE > /dev/null; then 91 log_must $KILL -9 $PID 92 log_fail "file link count is zero" 93fi 94 95log_must $RM -f ${TESTDIR}/tmp/test${TESTCASE_ID}* 96 97log_pass "Verify file link count is zero on zfs" 98