1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # ident "@(#)tp_delete_002.ksh 1.2 08/12/19 SMI"
27 #
28
29 LOGFILE=${LOGDIR}/mkdir.out
30 . ${TET_SUITE_ROOT}/lofi-tests/lib/fs_common
31
32 #
33 # start __stc_assertion__
34 #
35 # ASSERTION: delete_002
36 #
37 # DESCRIPTION:
38 # Delete a lofi device based on the name of the device.
39 #
40 # STRATEGY:
41 # Setup
42 # - Create a file of default size
43 # - Add a lofi device using the file
44 # Assert
45 # - Delete the lofi device by specifying the device name to
46 # 'lofiadm -d'
47 # Cleanup
48 # - Remove the file
49 #
50 # end __stc_assertion__
51 #
52 function tp_delete_002 {
53 typeset cmd lofi_add_status
54 typeset lofi_file=${SCRATCH_DIR}/lofi_file_$$_$TET_TPNUMBER
55 typeset status=0
56
57 typeset -r ASSERTION="delete_002"
58 typeset -r TP_NAME=tp_${ASSERTION}
59 typeset -r ME=$(whence -p ${0})
60 extract_assertion_info $(dirname $ME)/$TP_NAME
61
62 # Initialization
63 cti_pass
64 cti_assert $ASSERTION "Delete lofi device by device name"
65 create_execution_record # Record cmds; will display on failure
66 execution_phase_setup # Record setup cmds
67
68 # Setup -- create file for lofi device
69 make_and_verify_file $DEFAULT_FILE_SIZE $lofi_file
70 if (( $? != 0 )); then
71 cti_unresolved "Unable to test lofi deletion because" \
72 "creation of file failed"
73 status=1
74 fi
75
76 # Setup -- add lofi device
77 if (( $status == 0 )); then
78 lofi_dev_returned=`add_lofi_device $lofi_file`
79 lofi_add_status=$?
80 if (( $lofi_add_status != 0 )) && (( $lofi_add_status != 2 ))
81 then
82 cti_unresolved "Unable to test lofi deletion because" \
83 "creation failed"
84 status=1
85 fi
86 fi
87
88 # Assertion -- delete lofi device using name of device
89 if (( $status == 0 )); then
90 execution_phase_assert # Record assertion cmds
91 del_lofi_device $lofi_dev_returned
92 if (( $? == 0 )); then
93 cti_report "Deletion of lofi $lofi_dev_returned" \
94 "succeeded"
95 else
96 cti_fail "Unable to delete lofi device" \
97 "$lofi_dev_returned"
98 status=1
99 fi
100 fi
101
102 # Cleanup
103 execution_phase_cleanup # Record cleanup cmds
104 if [[ -f "$lofi_file" ]]; then
105 cmd="$RM $lofi_file"
106 record_cmd_execution $cmd
107 cti_execute "PASS" "$cmd"
108 if (( $? != 0 )); then
109 cti_fail "Unable to remove file $lofi_file" \
110 "used to for lofi device. Possible lofi" \
111 "is still using it."
112 status=1
113 fi
114 fi
115
116 if [[ -n "$VERBOSE" ]] || (( $status != 0 )); then
117 display_execution_record
118 else
119 delete_execution_record
120 fi
121 }