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
29verify_runnable "global"
30
31function cleanup
32{
33	typeset pool
34
35	for pool in $TESTPOOL $TEMPPOOL; do
36		poolexists $pool && destroy_pool $pool
37	done
38}
39
40log_assert "'zpool create -t <tempname>' can create a pool with the specified" \
41	" temporary name."
42log_onexit cleanup
43
44TEMPPOOL="tempname.$$"
45typeset poolprops=('comment=text' 'ashift=12' 'listsnapshots=on' 'autoexpand=on'
46    'autoreplace=on' 'delegation=off' 'failmode=continue')
47typeset fsprops=('canmount=off' 'mountpoint=none' 'utf8only=on'
48    'casesensitivity=mixed' 'version=1' 'normalization=formKD')
49
50for 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		IFS='=' read -r propname propval <<<"$fsprop"
59		log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval"
60		IFS='=' read -r propname propval <<<"$poolprop"
61		log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval"
62		# Cleanup
63		destroy_pool $TEMPPOOL
64	done
65done
66
67log_pass "'zpool create -t <tempname>' successfully creates pools with" \
68	" temporary names"
69