Print this page
12281 zvol_swap_003_pos shouldn't use swapadd in cleanup
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh
1 1 #! /bin/ksh -p
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 #
29 29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30 +# Copyright 2020 Joyent, Inc.
30 31 #
31 32
32 33 . $STF_SUITE/include/libtest.shlib
33 34 . $STF_SUITE/tests/functional/zvol/zvol_common.shlib
34 35 . $STF_SUITE/tests/functional/zvol/zvol_swap/zvol_swap.cfg
35 36
36 37 #
37 38 # DESCRIPTION:
38 39 # Verify that a zvol device can be used as a swap device
39 40 # through /etc/vfstab configuration.
40 41 #
41 42 # STRATEGY:
42 43 # 1. Modify /etc/vfstab to add the test zvol as swap device.
43 44 # 2. Use /sbin/swapadd to add zvol as swap device throuth /etc/vfstab
44 45 # 3. Create a file under /tmp and verify the file
45 46 #
46 47
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
47 48 verify_runnable "global"
48 49
49 50 function cleanup
50 51 {
51 52 [[ -f /tmp/$TESTFILE ]] && log_must rm -f /tmp/$TESTFILE
52 53 [[ -f $NEW_VFSTAB_FILE ]] && log_must rm -f $NEW_VFSTAB_FILE
53 54 [[ -f $PREV_VFSTAB_FILE ]] && \
54 55 log_must mv $PREV_VFSTAB_FILE $VFSTAB_FILE
55 56 [[ -f $PREV_VFSTAB_FILE ]] && rm -f $PREV_VFSTAB_FILE
56 57
57 - log_must swapadd $VFSTAB_FILE
58 -
59 58 if is_swap_inuse $voldev ; then
60 59 log_must swap -d $voldev
61 60 fi
62 61
63 62 }
64 63
65 64 log_assert "Verify that a zvol device can be used as a swap device" \
66 65 "through /etc/vfstab configuration."
67 66
68 67 log_onexit cleanup
69 68
70 69 voldev=/dev/zvol/dsk/$TESTPOOL/$TESTVOL
71 70 VFSTAB_FILE=/etc/vfstab
72 71 NEW_VFSTAB_FILE=/var/tmp/zvol_vfstab.$$
73 72 PREV_VFSTAB_FILE=/var/tmp/zvol_vfstab.PREV.$$
74 73
75 74 [[ -f $NEW_VFSTAB_FILE ]] && cp /dev/null $NEW_VFSTAB_FILE
76 75
77 76 awk '{if ($4 != "swap") print $1}' /etc/vfstab > $NEW_VFSTAB_FILE
78 77 echo "$voldev\t-\t-\tswap\t-\tno\t-" >> $NEW_VFSTAB_FILE
79 78
80 79 # Copy off the original vfstab, and run swapadd on the newly constructed one.
81 80 log_must cp $VFSTAB_FILE $PREV_VFSTAB_FILE
82 81 log_must cp $NEW_VFSTAB_FILE $VFSTAB_FILE
83 82 log_must swapadd $VFSTAB_FILE
84 83
85 84 log_must file_write -o create -f /tmp/$TESTFILE \
86 85 -b $BLOCKSZ -c $NUM_WRITES -d $DATA
87 86
88 87 [[ ! -f /tmp/$TESTFILE ]] &&
89 88 log_fail "Unable to create file under /tmp"
90 89
91 90 filesize=`ls -l /tmp/$TESTFILE | awk '{print $5}'`
92 91 tf_size=$((BLOCKSZ * NUM_WRITES))
93 92 (($tf_size != $filesize)) && \
94 93 log_fail "testfile is ($filesize bytes), expected ($tf_size bytes)"
95 94
96 95 log_pass "Successfully added a zvol to swap area through /etc/vfstab."
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX