1# SPDX-License-Identifier: CDDL-1.0 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 (c) 2026 by ConnectWise. All rights reserved. 25# 26 27. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/include/math.shlib 29. $STF_SUITE/tests/functional/zstream/zstream.cfg 30 31# 32# Several zstream tests need functions defined in rsend.kshlib 33# (stream_has_features, get_resume_token, cleanup_pool). Rather than 34# duplicate them, source the rsend library. Note that rsend.kshlib 35# also sources rsend.cfg, which will define its own $BACKDIR, $POOL, 36# $POOL2, etc. Our zstream.cfg is sourced first, and we reassert our 37# values afterward so that our tests use the zstream-specific paths 38# and pool names. 39# 40. $STF_SUITE/tests/functional/rsend/rsend.kshlib 41 42# Reassert our config over rsend's 43. $STF_SUITE/tests/functional/zstream/zstream.cfg 44 45ZSTREAM_DATADIR=$STF_SUITE/tests/functional/zstream 46 47# 48# Return "little" or "big" depending on the system's byte order. 49# 50function get_system_endian 51{ 52 python3 -c "import sys; print(sys.byteorder)" 53} 54 55# 56# Map a stream filename stem to its dump-file abbreviation. 57# e.g. "big-endian-all-drr-types-base-NATIVE" -> "beadtbn" 58# 59function get_stream_abbrev 60{ 61 typeset stem=$1 62 typeset -l abbrev="" 63 typeset IFS="-" 64 65 for part in $stem; do 66 abbrev="${abbrev}${part%"${part#?}"}" 67 done 68 69 echo "$abbrev" 70} 71 72# 73# Receive a stream into $POOL/recv, compute sorted xxhsum -H2 of all 74# regular files under the mountpoint, and write the result to $1. 75# Destroys $POOL/recv afterward if $3 is set to "cleanup". 76# 77function recv_and_hash 78{ 79 typeset hashfile=$1 80 typeset stream=$2 81 typeset cleanup=${3:-""} 82 83 log_must zfs receive -F $POOL/recv < "$stream" 84 typeset mnt=$(get_prop mountpoint $POOL/recv) 85 ( cd "$mnt" && find . -type f -print0 | sort -z | \ 86 xargs -0 xxh128sum ) > "$hashfile" 87 if [[ -n $cleanup ]]; then 88 log_must zfs destroy -r $POOL/recv 89 fi 90} 91