Skip to content

Commit

Permalink
Explicitly separate test-suite rpmdb reset from test initialization
Browse files Browse the repository at this point in the history
Many of our tests require RPMTEST_INIT to create a writable snapshot,
but especially after c17cc69,
relatively few require initializing or resetting the rpmdb in the image.

Separate the two and explicitly call RPMDB_RESET (renamed from RPMDB_INIT
for a clean break) where it is actually needed. The common pattern that
emerges is: build several packages at once and then do various things with
it. Each of these RPMDB_RESET uses is actually somewhat problematic because
whenever it's required there's a chance that previous tests could affect
the results. Can't help that just now, but at least we've identified the
issue.

Besides making the needs and usages clearer, this introduces a nice fat
speed boost for the test-suite - on my laptop, from 2m 50s to 2m 20s.
  • Loading branch information
pmatilai authored and dmnks committed Jan 27, 2025
1 parent 6e80bdb commit 1a99ef7
Show file tree
Hide file tree
Showing 25 changed files with 585 additions and 588 deletions.
3 changes: 2 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ as well as the existing tests. Below are the specifics of RPM's test-suite:
* Use `RPMTEST_SETUP` instead of `AT_SETUP`
* Use `RPMTEST_CHECK` instead of `AT_CHECK`
* Use `RPMTEST_CLEANUP` instead of `AT_CLEANUP`
* Use `RPMTEST_INIT` or `RPMDB_INIT` to create a mutable snapshot (optional)
* Use `RPMTEST_INIT` to create a mutable snapshot (optional)
* The absolute path to the snapshot's root is stored in the `$RPMTEST`
environment variable, modify the directory tree as you wish
* To run RPM inside the snapshot, use the `runroot` prefix, e.g. `runroot
Expand All @@ -155,6 +155,7 @@ as well as the existing tests. Below are the specifics of RPM's test-suite:
* You can create a custom user (or users) by supplying a list of usernames
to the macro, e.g. `RPMTEST_USER([user1, user2])`. Then, use
`runroot_user -n <name>` to run a binary as a specific user
* Use `RPMDB_RESET` to reinitialize a snapshot to an empty rpmdb (avoid this)
* If no snapshot was used, just call the RPM binaries normally
* Store any working files in the current directory (it's always writable)

Expand Down
6 changes: 0 additions & 6 deletions tests/local.at
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ rm -rf "${RPMTEST}"`rpm --eval '%_dbpath'`
runroot rpm --initdb
])

m4_define([RPMDB_INIT],[
RPMTEST_INIT
RPMDB_RESET
])

m4_define([RPMPY_RUN],[[
cat << EOF > test.py
# coding=utf-8
Expand Down Expand Up @@ -72,7 +67,6 @@ m4_define([RPMPY_TEST],[
RPMTEST_SETUP([$1])
AT_KEYWORDS([python])
setup_env
RPMDB_INIT
RPMPY_CHECK([$2], [$3], [$4])
RPMTEST_CLEANUP
])
Expand Down
Loading

0 comments on commit 1a99ef7

Please sign in to comment.