summaryrefslogtreecommitdiff
path: root/regress/tools-platform/spec
blob: 91732b6abde9731f60debd4d032aeb0d008ddb1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# $NetBSD: spec,v 1.2 2020/05/02 07:24:32 rillig Exp $
#
# Tests for the platform-provided tools.
#
# The individual *.test files are run in a minimal environment.
# In that environment, only the PATH is set, and it points to a
# directory containing only the tools from mk/tools/tools.${OPSYS}.mk.
#
# Additionally, MACHINE_PLATFORM is set, so that the tests can expect
# different results depending on the platform.  This is used for
# documenting bugs that have been fixed in a certain version.
#
# The individual tests may create arbitrary files in their current
# working directory.
#

do_test() {
	regressdir="$PWD"
	tmpdir="$(mktemp -d)" || { TEST_EXITSTATUS=$?; return; }
	bindir="$tmpdir/bin"
	mkdir "$bindir"
	(
		cd ../../pkgtools/digest \
		&& $TEST_MAKE \
			BINDIR="$bindir" \
			-f "$regressdir/zzz-prepare-tools.mk" \
			"prepare-platform-tools"
	)
	machine_platform=$(
		cd ../../pkgtools/digest \
		&& $TEST_MAKE show-var VARNAME=MACHINE_PLATFORM
	)

	for testfile in *.test; do
		mkdir "$tmpdir/work"
		(cd "$tmpdir/work" && "$bindir/env" -i \
			MACHINE_PLATFORM="$machine_platform" \
			PATH="$bindir" \
			"sh" "$regressdir/$testfile") \
		|| TEST_EXITSTATUS=$?
		rm -rf "$tmpdir/work"
	done

	rm -rf "$tmpdir"
}

check_result() {
	exit_status 0
}