xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh (revision 04e56356520b98d5a93c496b10f02530bb6647e0)
1*04e56356SAndriy Gapon#!/bin/ksh -p
2*04e56356SAndriy Gapon#
3*04e56356SAndriy Gapon# This file and its contents are supplied under the terms of the
4*04e56356SAndriy Gapon# Common Development and Distribution License ("CDDL"), version 1.0.
5*04e56356SAndriy Gapon# You may only use this file in accordance with the terms of version
6*04e56356SAndriy Gapon# 1.0 of the CDDL.
7*04e56356SAndriy Gapon#
8*04e56356SAndriy Gapon# A full copy of the text of the CDDL should have accompanied this
9*04e56356SAndriy Gapon# source.  A copy of the CDDL is also available via the Internet at
10*04e56356SAndriy Gapon# http://www.illumos.org/license/CDDL.
11*04e56356SAndriy Gapon#
12*04e56356SAndriy Gapon
13*04e56356SAndriy Gapon#
14*04e56356SAndriy Gapon# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
15*04e56356SAndriy Gapon#
16*04e56356SAndriy Gapon
17*04e56356SAndriy Gapon. $STF_SUITE/include/libtest.shlib
18*04e56356SAndriy Gapon
19*04e56356SAndriy Gapon#
20*04e56356SAndriy Gapon# DESCRIPTION:
21*04e56356SAndriy Gapon# 'zpool create -t <tempname>' can create a pool with the specified temporary
22*04e56356SAndriy Gapon# name. The pool should be present in the namespace as <tempname> until exported
23*04e56356SAndriy Gapon#
24*04e56356SAndriy Gapon# STRATEGY:
25*04e56356SAndriy Gapon# 1. Create a pool with '-t' option
26*04e56356SAndriy Gapon# 2. Verify the pool is created with the specified temporary name
27*04e56356SAndriy Gapon#
28*04e56356SAndriy Gapon
29*04e56356SAndriy Gaponverify_runnable "global"
30*04e56356SAndriy Gapon
31*04e56356SAndriy Gaponfunction cleanup
32*04e56356SAndriy Gapon{
33*04e56356SAndriy Gapon	destroy_pool $TESTPOOL
34*04e56356SAndriy Gapon	destroy_pool $TEMPPOOL
35*04e56356SAndriy Gapon
36*04e56356SAndriy Gapon}
37*04e56356SAndriy Gapon
38*04e56356SAndriy Gaponlog_assert "'zpool create -t <tempname>' can create a pool with the specified" \
39*04e56356SAndriy Gapon	" temporary name."
40*04e56356SAndriy Gaponlog_onexit cleanup
41*04e56356SAndriy Gapon
42*04e56356SAndriy GaponTEMPPOOL="tempname.$$"
43*04e56356SAndriy Gapontypeset poolprops=('comment=text' 'listsnapshots=on' 'autoexpand=on'
44*04e56356SAndriy Gapon    'autoreplace=on' 'delegation=off' 'failmode=continue')
45*04e56356SAndriy Gapontypeset fsprops=('canmount=off' 'mountpoint=none' 'utf8only=on'
46*04e56356SAndriy Gapon    'casesensitivity=mixed' 'version=1' 'normalization=formKD')
47*04e56356SAndriy Gapon
48*04e56356SAndriy Gaponfor poolprop in "${poolprops[@]}"; do
49*04e56356SAndriy Gapon	for fsprop in "${fsprops[@]}"; do
50*04e56356SAndriy Gapon		# 1. Create a pool with '-t' option
51*04e56356SAndriy Gapon		log_must zpool create -t $TEMPPOOL \
52*04e56356SAndriy Gapon			-O $fsprop -o $poolprop $TESTPOOL $DISKS
53*04e56356SAndriy Gapon		# 2. Verify the pool is created with the specified temporary name
54*04e56356SAndriy Gapon		log_must poolexists $TEMPPOOL
55*04e56356SAndriy Gapon		log_mustnot poolexists $TESTPOOL
56*04e56356SAndriy Gapon		propname="$(awk -F= '{print $1}' <<< $fsprop)"
57*04e56356SAndriy Gapon		propval="$(awk -F= '{print $2}' <<< $fsprop)"
58*04e56356SAndriy Gapon		log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval"
59*04e56356SAndriy Gapon		propname="$(awk -F= '{print $1}' <<< $poolprop)"
60*04e56356SAndriy Gapon		propval="$(awk -F= '{print $2}' <<< $poolprop)"
61*04e56356SAndriy Gapon		log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval"
62*04e56356SAndriy Gapon		# Cleanup
63*04e56356SAndriy Gapon		destroy_pool $TEMPPOOL
64*04e56356SAndriy Gapon	done
65*04e56356SAndriy Gapondone
66*04e56356SAndriy Gapon
67*04e56356SAndriy Gaponlog_pass "'zpool create -t <tempname>' successfully creates pools with" \
68*04e56356SAndriy Gapon	" temporary names"
69