1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or https://opensource.org/licenses/CDDL-1.0. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# Copyright (c) 2023 by Klara Inc. 31# 32 33. $STF_SUITE/tests/functional/cli_root/zpool_set/zpool_set_common.kshlib 34 35# 36# DESCRIPTION: 37# ZFS can set any valid user-defined pool property. 38# 39# STRATEGY: 40# 1. Combine all kind of valid characters into a valid user-defined 41# property name. 42# 2. Random get a string as the value. 43# 3. Verify all the valid user-defined pool properties can be set to a 44# pool. 45# 46 47verify_runnable "both" 48 49log_assert "ZFS can set any valid user-defined pool property." 50log_onexit cleanup_user_prop $TESTPOOL 51 52typeset -a names=() 53typeset -a values=() 54 55# Longest property name (255 bytes, which is the 256-byte limit minus 1 byte 56# for the null byte) 57names+=("$(awk 'BEGIN { printf "x:"; while (c++ < (256 - 2 - 1)) printf "a" }')") 58values+=("long-property-name") 59# Longest property value (the limits are 1024 on FreeBSD and 4096 on Linux, so 60# pick the right one; the longest value can use limit minus 1 bytes for the 61# null byte) 62if is_linux; then 63 typeset ZFS_MAXPROPLEN=4096 64else 65 typeset ZFS_MAXPROPLEN=1024 66fi 67names+=("long:property:value") 68values+=("$(awk -v max="$ZFS_MAXPROPLEN" 'BEGIN { while (c++ < (max - 1)) printf "A" }')") 69# Valid property names 70for i in {1..10}; do 71 typeset -i len 72 ((len = RANDOM % 32)) 73 names+=("$(valid_user_property $len)") 74 ((len = RANDOM % 512)) 75 values+=("$(user_property_value $len)") 76done 77 78typeset -i i=0 79while ((i < ${#names[@]})); do 80 typeset name="${names[$i]}" 81 typeset value="${values[$i]}" 82 83 log_must eval "zpool set $name='$value' $TESTPOOL" 84 log_must eval "check_user_prop $TESTPOOL $name '$value'" 85 86 ((i += 1)) 87done 88 89log_pass "ZFS can set any valid user-defined pool property passed." 90