Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
test: add a unit test about previous commit
Baptiste Daroussin committed 2 months ago
commit c9d2db027b754064d70ae943183cc14c5b0a0eb4
parent 84f31da
2 files changed +82 -1
modified tests/Makefile.autosetup
@@ -75,7 +75,8 @@ TESTS_SH= \
	frontend/abi.sh \
	frontend/http.sh \
	frontend/triggers.sh \
-
	frontend/info.sh
+
	frontend/info.sh \
+
	frontend/force_reinstall_shlib.sh

#
# These files are mostly simple binaries obtained from
added tests/frontend/force_reinstall_shlib.sh
@@ -0,0 +1,80 @@
+
#! /usr/bin/env atf-sh
+

+
. $(atf_get_srcdir)/test_environment.sh
+

+
tests_init \
+
	force_install_no_unrelated_reinstall
+

+
force_install_no_unrelated_reinstall_body() {
+
	atf_skip_on Darwin The macOS linker uses different flags
+

+
	# Regression test: pkg install -f should not propose to reinstall
+
	# unrelated packages whose only connection to the target is via
+
	# shlib provides/requires.
+
	#
+
	# Without the fix in handle_provide, the remote provider would be
+
	# added to the universe even when its digest matches the local one,
+
	# giving the SAT solver the opportunity to pick the remote and
+
	# schedule a spurious reinstall.
+

+
	touch empty.c
+
	cc -shared -Wl,-soname=libtest.so.1 empty.c -o libtest.so.1
+
	ln -s libtest.so.1 libtest.so
+
	cc -shared -Wl,-soname=libconsumer.so.1 empty.c -o libconsumer.so.1 -ltest -L.
+

+
	# provider: provides libtest.so.1
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg provider provider 1 /usr/local
+
	cat << EOF >> provider.ucl
+
files: {
+
	${TMPDIR}/libtest.so.1: "",
+
}
+
EOF
+

+
	# target: links against libtest.so.1 but has NO explicit dep on
+
	# provider.  The only connection is via shlib require/provide.
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg target target 1 /usr/local
+
	cat << EOF >> target.ucl
+
files: {
+
	${TMPDIR}/libconsumer.so.1: "",
+
}
+
EOF
+

+
	# Create packages and repo
+
	for p in provider target; do
+
		atf_check \
+
			-o ignore \
+
			-e empty \
+
			-s exit:0 \
+
			pkg create -M ${p}.ucl
+
	done
+

+
	atf_check \
+
		-o ignore \
+
		-e empty \
+
		-s exit:0 \
+
		pkg repo .
+

+
	mkdir reposconf
+
	cat << EOF > reposconf/repo.conf
+
local: {
+
	url: file:///$TMPDIR,
+
	enabled: true
+
}
+
EOF
+

+
	# Install both from the repo (digests will match local vs remote)
+
	atf_check \
+
		-o ignore \
+
		-s exit:0 \
+
		pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" \
+
		install -y provider target
+

+
	# Force reinstall target: only target should be reinstalled,
+
	# provider must NOT be pulled in.
+
	atf_check \
+
		-o match:"target-1" \
+
		-o not-match:"provider" \
+
		-s exit:1 \
+
		pkg -o REPOS_DIR="${TMPDIR}/reposconf" -o PKG_CACHEDIR="${TMPDIR}" \
+
		install -fn target
+
}