From 08c81de2ee753778763810add5221e9162d925cb Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 21 Nov 2008 17:48:27 +0200 Subject: [PATCH] Hackery to get rpm install tests to "work" with fakechroot - fakechroot throws it's own curveballs into the already mixed up thing, copy things to the test dir and set chroot base to that to avoid confusion with cwd and such - klunky and ugly but at least the tests pass now when running non-root --- tests/atlocal.in | 21 +++++++++++++++++---- tests/rpmdb.at | 31 ++++++++++++++++++------------- tests/rpmquery.at | 15 ++++++++------- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/tests/atlocal.in b/tests/atlocal.in index 484a621..4e4e30e 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -3,12 +3,15 @@ export LD_LIBRARY_PATH PATH="${abs_builddir}/testing@rpmbindir@:${abs_builddir}/testing@usrbindir@:$PATH" export PATH +RPMTEST="${abs_builddir}/testing" +RPMDATA="${abs_srcdir}/data/" + # Popt looks into $HOME -HOME="${abs_builddir}/testing" +HOME="${RPMTEST}" export HOME -RPMRC="${abs_builddir}/testing@RPMCONFIGDIR@/rpmrc" -TOPDIR="${abs_builddir}/testing/build" +RPMRC="${RPMTEST}@RPMCONFIGDIR@/rpmrc" +TOPDIR="${RPMTEST}/build" RPM_XFAIL=${RPM_XFAIL-1} @@ -16,5 +19,15 @@ function run() { cmd="$1" shift - "${cmd}" --rcfile="${RPMRC}" --define "_topdir ${TOPDIR}" $* + "${cmd}" --rcfile="${RPMRC}" --define "_topdir ${TOPDIR}" $@ +} + +function runroot() +{ + cmd="$1" + shift + (cd ${RPMTEST} && \ + mkdir -p etc && touch etc/mtab && + FAKECHROOT_BASE="${RPMTEST}" fakechroot "${cmd}" --rcfile="${RPMRC}" --define "_topdir ${TOPDIR}" $@ + ) } diff --git a/tests/rpmdb.at b/tests/rpmdb.at index d95d017..9da741b 100644 --- a/tests/rpmdb.at +++ b/tests/rpmdb.at @@ -35,8 +35,7 @@ AT_SETUP([rpm -qa]) AT_CHECK([ RPMDB_CLEAR RPMDB_INIT -run rpm \ - --root="${abs_builddir}"/testing \ +runroot rpm \ -qa ], [0]) @@ -52,9 +51,11 @@ AT_CHECK([ RPMDB_CLEAR RPMDB_INIT -run rpm -i \ - --root="${abs_builddir}"/testing \ - "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm +tpkg="foo-1.0-1.noarch.rpm" +cp "${RPMDATA}/RPMS/${tpkg}" "${RPMTEST}" + +runroot rpm -i \ + "${tpkg}" ], [0]) @@ -70,10 +71,12 @@ AT_CHECK([ RPMDB_CLEAR RPMDB_INIT -run rpm -i \ - --root="${abs_builddir}"/testing \ - --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \ - "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm +tpkg="hello-1.0-1.i386.rpm" +cp "${RPMDATA}/RPMS/${tpkg}" "${RPMTEST}" + +runroot rpm -i \ + --noscripts --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \ + "${tpkg}" ], [0]) @@ -89,10 +92,12 @@ AT_CHECK([ RPMDB_CLEAR RPMDB_INIT -run rpm -i \ - --root="${abs_builddir}"/testing \ - --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \ - "${abs_srcdir}"/data/RPMS/hello-1.0-1.ppc64.rpm +tpkg="hello-1.0-1.ppc64.rpm" +cp "${RPMDATA}/RPMS/${tpkg}" "${RPMTEST}" + +runroot rpm -i \ + --noscripts --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \ + "${tpkg}" ], [0], [ignore], diff --git a/tests/rpmquery.at b/tests/rpmquery.at index 9fbddea..f450f1c 100644 --- a/tests/rpmquery.at +++ b/tests/rpmquery.at @@ -101,15 +101,17 @@ AT_CHECK([ RPMDB_CLEAR RPMDB_INIT -run rpm \ - --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \ - -i "${abs_srcdir}"/data/RPMS/hello-1.0-1.ppc64.rpm +tpkg="hello-1.0-1.ppc64.rpm" +cp "${RPMDATA}/RPMS/$tpkg" "${RPMTEST}" + +runroot rpm \ + --noscripts --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \ + -i "${tpkg}" ], [0]) AT_CHECK([ -run rpm \ - --root="${abs_builddir}"/testing \ +runroot rpm \ -q hello ], [0], @@ -124,8 +126,7 @@ ${abs_builddir}/testing/check/share/doc/hello-1.0/FAQ _ATEOF AT_CHECK([ -rpm \ - --root="${abs_builddir}"/testing \ +runroot rpm \ -ql hello ], [0], -- 2.7.4