|
| 1 | +#!/bin/ksh -p |
| 2 | +# SPDX-License-Identifier: CDDL-1.0 |
| 3 | +# |
| 4 | +# CDDL HEADER START |
| 5 | +# |
| 6 | +# The contents of this file are subject to the terms of the |
| 7 | +# Common Development and Distribution License (the "License"). |
| 8 | +# You may not use this file except in compliance with the License. |
| 9 | +# |
| 10 | +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
| 11 | +# or https://opensource.org/licenses/CDDL-1.0. |
| 12 | +# See the License for the specific language governing permissions |
| 13 | +# and limitations under the License. |
| 14 | +# |
| 15 | +# When distributing Covered Code, include this CDDL HEADER in each |
| 16 | +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
| 17 | +# If applicable, add the following below this CDDL HEADER, with the |
| 18 | +# fields enclosed by brackets "[]" replaced with your own identifying |
| 19 | +# information: Portions Copyright [yyyy] [name of copyright owner] |
| 20 | +# |
| 21 | +# CDDL HEADER END |
| 22 | +# |
| 23 | + |
| 24 | +# |
| 25 | +# Copyright (c) 2025, Klara, Inc. |
| 26 | +# |
| 27 | + |
| 28 | +. $STF_SUITE/include/libtest.shlib |
| 29 | + |
| 30 | +# |
| 31 | +# DESCRIPTION: |
| 32 | +# |
| 33 | +# zpool get name <pool> all-vdevs works as expected |
| 34 | +# |
| 35 | +# STRATEGY: |
| 36 | +# |
| 37 | +# 1. create various kinds of pools |
| 38 | +# 2. get all vdev names |
| 39 | +# 3. make sure we get all the names back and they look correct |
| 40 | +# |
| 41 | + |
| 42 | +verify_runnable "global" |
| 43 | + |
| 44 | +function cleanup { |
| 45 | + zpool destroy -f $TESTPOOL1 |
| 46 | + [[ -e $TESTDIR ]] && rm -rf $TESTDIR/* |
| 47 | +} |
| 48 | +log_onexit cleanup |
| 49 | + |
| 50 | +log_assert "zpool get all-vdevs works as expected" |
| 51 | + |
| 52 | +# map of vdev spec -> summary form |
| 53 | +# |
| 54 | +# left side is normal args to zpool create; single number will be replaced |
| 55 | +# with that number test file |
| 56 | +# |
| 57 | +# right side is a summary of the vdev tree, one char per vdev |
| 58 | +# ! root |
| 59 | +# 0-9 file number |
| 60 | +# m mirror |
| 61 | +# r raidz |
| 62 | +# d draid |
| 63 | +typeset -A specs=( |
| 64 | + ["{0..9}"]="!0123456789" |
| 65 | + ["mirror {0..9}"]="!m0123456789" |
| 66 | + ["mirror 0 1 mirror 2 3 mirror 4 5 mirror 6 7"]="!m01m23m45m67" |
| 67 | + ["raidz1 {0..9}"]="!r0123456789" |
| 68 | + ["raidz1 {0..4} raidz1 {5..9}"]="!r01234r56789" |
| 69 | + ["raidz2 {0..9}"]="!r0123456789" |
| 70 | + ["raidz2 {0..4} raidz2 {5..9}"]="!r01234r56789" |
| 71 | + ["raidz3 {0..9}"]="!r0123456789" |
| 72 | + ["raidz3 {0..4} raidz3 {5..9}"]="!r01234r56789" |
| 73 | + ["draid1 {0..9}"]="!d0123456789" |
| 74 | + ["draid2 {0..9}"]="!d0123456789" |
| 75 | + ["draid3 {0..9}"]="!d0123456789" |
| 76 | +) |
| 77 | + |
| 78 | +for spec in "${!specs[@]}" ; do |
| 79 | + log_must truncate -s 100M $TESTDIR/$TESTFILE1.{0..9} |
| 80 | + log_must zpool create -f $TESTPOOL1 \ |
| 81 | + $(echo $spec | sed -E "s#(^| )([0-9])#\1$TESTDIR/$TESTFILE1.\2#g") |
| 82 | + typeset desc=$( zpool get -Ho name name $TESTPOOL1 all-vdevs | awk ' |
| 83 | + /^\// { t = t substr($1,length($1)) ; next } |
| 84 | + /^root/ { t = t "!" last ; next } |
| 85 | + /^[a-z]/ { t = t substr($1,0,1) last ; next } |
| 86 | + END { print t } |
| 87 | + ') |
| 88 | + log_must test "${specs[$spec]}" == "$desc" |
| 89 | + cleanup |
| 90 | +done |
| 91 | + |
| 92 | +log_pass |
0 commit comments