Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate the need for run() wrapper in the test-suite #3447

Merged
merged 12 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions tests/atlocal.in
Original file line number Diff line number Diff line change
Expand Up @@ -110,37 +110,23 @@ setup_env()
fi
}

run()
{
setup_env
"$@" --define "_buildhost testhost" \
--define "_tmppath ${RPMTEST}/tmp" \
--define "_topdir ${RPMTEST}/build" \
--define "_db_backend ${DBFORMAT}" \
--dbpath="${RPMTEST}/var/lib/rpm/"
}

rundebug()
{
setup_env
export RPM_CONFIGDIR=${RPMTEST}/@RPM_CONFIGDIR@
cp ${RPMDATA}/macros.debug ${RPM_CONFIGDIR}/macros.d/
run "$@"
"$@"
rm -f ${RPM_CONFIGDIR}/macros.d/macros.debug
unset RPM_CONFIGDIR
}

runroot()
{
setup_env
snapshot exec "$@" \
--define "_buildhost testhost" \
--define "_topdir /build"
--define "_tmppath /var/tmp"
pmatilai marked this conversation as resolved.
Show resolved Hide resolved
}

runroot_other()
{
setup_env
snapshot exec "$@"
}

Expand All @@ -152,7 +138,6 @@ runroot_user()
shift 2
;;
esac
setup_env
runroot_other --new-session sudo -iu $RPMUSER "$@"
}

Expand Down
4 changes: 4 additions & 0 deletions tests/data/macros.testenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# root's macro config in the test-environment
%_buildhost testhost
%_topdir %{getenv:RPMTEST}/build
%_tmppath %{getenv:RPMTEST}/tmp
3 changes: 3 additions & 0 deletions tests/local.at
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ LD_PRELOAD=${ASANLIB} ASAN_OPTIONS=detect_leaks=0 ${PYTHON} test.py
]])

m4_define([RPMTEST_CHECK],[
setup_env
AT_CHECK($@)
])

m4_define([RPMTEST_CHECK_UNQUOTED],[
setup_env
AT_CHECK_UNQUOTED($@)
])

Expand Down Expand Up @@ -61,6 +63,7 @@ RPMTEST_CHECK([RPMPY_RUN([$1])], [], [$2], [$3])
m4_define([RPMPY_TEST],[
AT_SETUP([$1])
AT_KEYWORDS([python])
setup_env
RPMDB_INIT
RPMPY_CHECK([$2], [$3], [$4])
RPMTEST_CLEANUP
Expand Down
3 changes: 3 additions & 0 deletions tests/mktree.common
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ make_install()

mkdir -p $DESTDIR/build
ln -sf ../data/SOURCES $DESTDIR/build/

# append in case Dockerfile put something in there already
cat @CMAKE_CURRENT_SOURCE_DIR@/data/macros.testenv >> $DESTDIR/root/.rpmmacros
}
1 change: 0 additions & 1 deletion tests/pinned/common/buildrepr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ runroot rpmbuild -bb --quiet \
--define "optflags -O2 -g" \
--define "_target_platform noarch-linux" \
--define "_binary_payload w.ufdio" \
--define "_buildhost localhost" \
--define "use_source_date_epoch_as_buildtime 1" \
--define "source_date_epoch_from_changelog 1" \
--define "build_mtime_policy clamp_to_source_date_epoch" \
Expand Down
38 changes: 23 additions & 15 deletions tests/rpmbuild.at
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild \
rpmbuild \
--define "packager Iam" \
-ba ${RPMDATA}/SPECS/hello.spec
],
[0],
[ignore],
[ignore])

RPMTEST_CHECK([
runroot rpm -qp --qf "%{buildhost}\n" /build/SRPMS/hello-1.0-1.src.rpm
],
[0],
[testhost
],
[])

RPMTEST_CHECK([

runroot rpm -qp --qf "%{license}\n" /build/SRPMS/hello-1.0-1.src.rpm
Expand Down Expand Up @@ -331,7 +339,7 @@ AT_SETUP([rpmbuild dir layout])
AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([
run rpmbuild \
rpmbuild \
-bi --target noarch --quiet \
${RPMDATA}/SPECS/simple.spec
runroot_other find /build/BUILD|sort
Expand All @@ -349,7 +357,7 @@ runroot_other find /build/BUILD|sort
[ignore])

RPMTEST_CHECK([
run rpmbuild \
rpmbuild \
-bi --target noarch --quiet \
--with setup \
${RPMDATA}/SPECS/simple.spec
Expand Down Expand Up @@ -378,7 +386,7 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild \
rpmbuild \
-ba ${RPMDATA}/SPECS/hello-auto.spec
],
[0],
Expand All @@ -391,7 +399,7 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild -D="nopatches 1" \
rpmbuild -D="nopatches 1" \
-bp ${RPMDATA}/SPECS/hello-auto.spec
],
[0],
Expand Down Expand Up @@ -518,7 +526,7 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild \
rpmbuild \
-bp ${RPMDATA}/SPECS/autosetup-noroot.spec
],
[0],
Expand All @@ -527,23 +535,23 @@ run rpmbuild \

RPMTEST_CHECK([

run rpmbuild \
rpmbuild \
-bp ${RPMDATA}/SPECS/autosetup-singleroot.spec
],
[0],
[ignore],
[ignore])

RPMTEST_CHECK([
run rpmbuild \
rpmbuild \
-bp ${RPMDATA}/SPECS/autosetup-singleroot1.spec
],
[0],
[ignore],
[ignore])

RPMTEST_CHECK([
run rpmbuild \
rpmbuild \
-bp ${RPMDATA}/SPECS/autosetup-singleroot2.spec
],
[0],
Expand All @@ -556,7 +564,7 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild \
rpmbuild \
-ba --quiet ${RPMDATA}/SPECS/hello-autopatch.spec
],
[0],
Expand Down Expand Up @@ -631,7 +639,7 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild \
rpmbuild \
--define "packager Iam" \
--rebuild ${RPMDATA}/SRPMS/hello-1.0-1.src.rpm
],
Expand All @@ -653,8 +661,8 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild -bi ${RPMDATA}/SPECS/hello.spec &> /dev/null
run rpmbuild --quiet -bl --short-circuit ${RPMDATA}/SPECS/hello.spec
rpmbuild -bi ${RPMDATA}/SPECS/hello.spec &> /dev/null
rpmbuild --quiet -bl --short-circuit ${RPMDATA}/SPECS/hello.spec
],
[0],
[],
Expand Down Expand Up @@ -755,7 +763,7 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild \
rpmbuild \
-ta "${RPMDATA}/SOURCES/hello-2.0.tar.gz"
],
[0],
Expand Down Expand Up @@ -2645,7 +2653,7 @@ AT_KEYWORDS([build])
RPMDB_INIT
RPMTEST_CHECK([

run rpmbuild \
rpmbuild \
--quiet -bd ${RPMDATA}/SPECS/hello.spec
ls ls ${RPMTEST}/build/*/*.rpm | wc --lines
],
Expand Down
2 changes: 1 addition & 1 deletion tests/rpmdb.at
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ AT_KEYWORDS([rpmdb])

# This needs to run *without* RPMDB_INIT to test behavior on read-only mount
RPMTEST_CHECK([
run rpmdb --exportdb --dbpath ${RPMTEST}/data/misc/ > rdonly.list
rpmdb --exportdb > rdonly.list
test -s rdonly.list
],
[0],
Expand Down
2 changes: 1 addition & 1 deletion tests/rpmi.at
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ for e in 1 2; do
runroot_other cp /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm /tmp/epoch${e}.rpm
done
# for testing sanity
echo '%_query_all_fmt %%{nevra}' > ${HOME}/.rpmmacros
echo '%_query_all_fmt %%{nevra}' >> ${HOME}/.rpmmacros

RPMTEST_CHECK([
RPMDB_INIT
Expand Down
Loading
Loading