Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
tests: Add a regression test for #2522
Mark Johnston committed 6 months ago
commit c7f00cc98b7ff384726606eb3dd51b7b5f2e67e5
parent 35343ea
1 file changed +148 -1
modified tests/frontend/backup_lib.sh
@@ -5,7 +5,8 @@
tests_init \
	basic \
	split_upgrade \
-
	depends
+
	depends \
+
	multiple_upgrade

basic_body() {
	atf_skip_on Darwin The macOS linker uses different flags
@@ -242,3 +243,149 @@ EOF
	atf_check test -f ${TMPDIR}/target/${TMPDIR}/libfoo.so.2
	atf_check test -f ${TMPDIR}/target/${TMPDIR}/libbar.so.2
}
+

+
# A regression test for a scenario where the same shlib version is backed up
+
# multiple times.  This would result in a registration failure of the
+
# compat-libraries, which in turn could result in a sqlite error if this
+
# happened during a pkg uninstall during a split upgrade.
+
multiple_upgrade_body()
+
{
+
	atf_skip_on Darwin The macOS linker uses different flags
+

+
	atf_check touch a b c d
+
	atf_check touch empty.c
+
	atf_check cc -shared -Wl,-soname=libfoo.so.1 empty.c -o libfoo.so.1
+
	atf_check ln -s libfoo.so.1 libfoo.so
+
	atf_check cc -shared -Wl,-soname=libbar.so.1 empty.c -o libbar.so.1
+
	atf_check ln -s libbar.so.1 libbar.so
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "foo" "foo" "1"
+
	cat << EOF >> foo.ucl
+
files: {
+
	${TMPDIR}/a: "",
+
	${TMPDIR}/libfoo.so.1: "",
+
	${TMPDIR}/libbar.so.1: "",
+
}
+
EOF
+
	atf_check pkg create -M foo.ucl
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "bar" "bar" "1"
+
	cat << EOF >> bar.ucl
+
files: {
+
	${TMPDIR}/b: "",
+
}
+
EOF
+
	atf_check pkg create -M bar.ucl
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "baz" "baz" "1"
+
	cat << EOF >> baz.ucl
+
files: {
+
	${TMPDIR}/c: "",
+
}
+
EOF
+
	atf_check pkg create -M baz.ucl
+

+
	atf_check mkdir ${TMPDIR}/target ${TMPDIR}/reposconf
+
	atf_check -o ignore \
+
	    pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy \
+
	    ${TMPDIR}/foo-1.pkg ${TMPDIR}/bar-1.pkg ${TMPDIR}/baz-1.pkg
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "foo" "foo" "2"
+
	cat << EOF >> foo.ucl
+
files: {
+
	${TMPDIR}/a: "",
+
}
+
EOF
+
	atf_check pkg create -M foo.ucl
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "bar" "bar" "2"
+
	cat << EOF >> bar.ucl
+
files: {
+
	${TMPDIR}/b: "",
+
	${TMPDIR}/libfoo.so.1: "",
+
	${TMPDIR}/libbar.so.1: "",
+
}
+
EOF
+
	atf_check pkg create -M bar.ucl
+

+
	cat <<EOF > ${TMPDIR}/reposconf/repo.conf
+
local: {
+
	url: file://${TMPDIR}/repo,
+
	enabled: true
+
}
+
EOF
+
	atf_check mkdir repo
+
	atf_check mv foo-2.pkg bar-2.pkg repo
+
	atf_check -o ignore pkg repo repo
+

+
	# Upgrade the packages.  Moving the libraries between packages will
+
	# cause them to be backed up.
+
	atf_check -o ignore \
+
	    pkg \
+
	        -o REPOS_DIR=${TMPDIR}/reposconf -r ${TMPDIR}/target \
+
		-o BACKUP_LIBRARIES=yes \
+
		-o BACKUP_LIBRARY_PATH=/back/ \
+
	        upgrade -y
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "foo" "foo" "3"
+
	cat << EOF >> foo.ucl
+
files: {
+
	${TMPDIR}/a: "",
+
	${TMPDIR}/libfoo.so.1: "",
+
	${TMPDIR}/libbar.so.1: "",
+
}
+
EOF
+
	atf_check pkg create -M foo.ucl
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "bar" "bar" "3"
+
	cat << EOF >> bar.ucl
+
files: {
+
	${TMPDIR}/b: "",
+
	${TMPDIR}/c: "",
+
}
+
EOF
+
	atf_check pkg create -M bar.ucl
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "baz" "baz" "3"
+
	cat << EOF >> baz.ucl
+
files: {
+
	${TMPDIR}/d: "",
+
},
+
deps: {
+
	"foo": {
+
		version: "3",
+
		origin: "foo",
+
	},
+
}
+
EOF
+
	atf_check pkg create -M baz.ucl
+

+
	atf_check rm -rf repo
+
	atf_check mkdir repo
+
	atf_check mv foo-3.pkg bar-3.pkg baz-3.pkg repo
+
	atf_check -o ignore pkg repo repo
+

+
	# Make sure pkg fetches a new catalogue.
+
	atf_check -o ignore \
+
	    pkg \
+
	        -o REPOS_DIR=${TMPDIR}/reposconf -r ${TMPDIR}/target \
+
	        update -f
+

+
	# Upgrade the three packages to version 3.  The shlibs move from bar-2
+
	# to foo-3, and the library backup logic infers that it must therefore
+
	# back up libfoo.so and libbar.so.  (This is really a bug in itself
+
	# since those libraries aren't actually going away, but that's because
+
	# library backup mechanism is plumbed in at the wrong layer.  One step
+
	# at a time.)
+
	#
+
	# Then, we use a conflict between bar-3 and baz-2 to split the
+
	# bar-2->bar-3 upgrade.  baz-3 depends on foo-3 to try and provoke the
+
	# split, otherwise pkg would first upgrade baz-1->baz-3 and then there
+
	# would be no need to split the bar upgrade.
+
	atf_check -o ignore -e match:"compat-libraries-.* conflicts with compat-libraries-.*" \
+
	    pkg \
+
	        -o REPOS_DIR=${TMPDIR}/reposconf -r ${TMPDIR}/target \
+
		-o BACKUP_LIBRARIES=yes \
+
		-o BACKUP_LIBRARY_PATH=/back/ \
+
	        upgrade -y
+
}