xref: /illumos-gate/usr/src/test/util-tests/tests/find/find.kshlib (revision 47ec9542e2cec788e0d0ff35e54ad5cef6f520d5)
1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11# Copyright 2020 Joyent, Inc.
12# Copyright 2024 Bill Sommerfeld <sommerfeld@hamachi.org>
13#
14
15#
16# Shell functions and definitions common to both find tests.
17#
18
19export LC_ALL=C.UTF-8
20
21set -o pipefail
22unalias -a
23
24find_prog=/usr/bin/find
25find_prog_xpg4=/usr/xpg4/bin/find
26find_exit=0
27
28# make sure we don't end in 1 or 2, which breaks the tests
29find_dir=/var/tmp/findtest.$$.dir
30
31testfind()
32{
33	exp=$1
34	shift
35	cmd="$@"
36
37	echo "TEST: $cmd"
38
39	out=$(eval $cmd | sort | tr '\n' ',')
40
41	[[ "$exp" == "$out" ]] || {
42		echo "TEST FAILED: $cmd" >&2
43		echo "expected: $exp" >&2
44		echo "got: $out" >&2
45		find_exit=1
46	}
47}
48