]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_create / zpool_create_tempname.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 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
15 #
16
17 . $STF_SUITE/include/libtest.shlib
18
19 #
20 # DESCRIPTION:
21 # 'zpool create -t <tempname>' can create a pool with the specified temporary
22 # name. The pool should be present in the namespace as <tempname> until exported
23 #
24 # STRATEGY:
25 # 1. Create a pool with '-t' option
26 # 2. Verify the pool is created with the specified temporary name
27 #
28
29 verify_runnable "global"
30
31 function cleanup
32 {
33         typeset pool
34
35         for pool in $TESTPOOL $TEMPPOOL; do
36                 poolexists $pool && destroy_pool $pool
37         done
38 }
39
40 log_assert "'zpool create -t <tempname>' can create a pool with the specified" \
41         " temporary name."
42 log_onexit cleanup
43
44 TEMPPOOL="tempname.$$"
45 typeset poolprops=('comment=text' 'ashift=12' 'listsnapshots=on' 'autoexpand=on'
46     'autoreplace=on' 'delegation=off' 'failmode=continue')
47 typeset fsprops=('canmount=off' 'mountpoint=none' 'utf8only=on'
48     'casesensitivity=mixed' 'version=1' 'normalization=formKD')
49
50 for poolprop in "${poolprops[@]}"; do
51         for fsprop in "${fsprops[@]}"; do
52                 # 1. Create a pool with '-t' option
53                 log_must zpool create -t $TEMPPOOL -O $fsprop -o $poolprop \
54                         $TESTPOOL $DISKS
55                 # 2. Verify the pool is created with the specified temporary name
56                 log_must poolexists $TEMPPOOL
57                 log_mustnot poolexists $TESTPOOL
58                 propname="$(awk -F= '{print $1}' <<< $fsprop)"
59                 propval="$(awk -F= '{print $2}' <<< $fsprop)"
60                 log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval"
61                 propname="$(awk -F= '{print $1}' <<< $poolprop)"
62                 propval="$(awk -F= '{print $2}' <<< $poolprop)"
63                 log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval"
64                 # Cleanup
65                 destroy_pool $TEMPPOOL
66         done
67 done
68
69 log_pass "'zpool create -t <tempname>' successfully creates pools with" \
70         " temporary names"