[Rpm-maint] [rpm-software-management/rpm] Fix a test relying on glibc version of glob(3) (PR #2401)
Michal Domonkos
notifications at github.com
Mon Feb 27 15:24:22 UTC 2023
When fakechroot is called with FAKECHROOT_BASE and HOME both pointed at the same directory (as is the case with our test suite, see the file tests/atlocal.in), the pattern "~" gets expanded by glob() to the empty string. However, this wasn't the case back when we bundled our own glob() implementation (before commit [1]) which would yield zero matches for such a pattern, probably due to a bug in that implementation.
We rely on this (glibc-only?) behavior in the recently added epoch tests (commits [2]) which create the "~/.rpmmacros" file and expect it to be loaded by RPM on startup. This works since the commits were added after [1] and thus the pattern yields "/.rpmmacros" which is the correct path inside the fakechroot environment, but it prevents us from cherry picking [2] to stable branches where [1] is not (and won't be) present.
Fix that by simply choosing a different, non-tilde, default macro path in these tests.
Note: We could just consider this patch "backporting" work and only apply it on the respective stable branch(es), but this is a very non-obvious thing that took me a couple of days of head-scratching (as part of 4.18.1 preparation) so having it on master will make our life easier in case we need to include (and not forget) this on multiple stable branches.
Here's a simple C program showing the difference between the pre-[1] and post-[1] version of glob() (through the rpmGlob() wrapper):
#include <rpm/rpmfileutil.h>
int main()
{
ARGV_t path, paths = NULL;
if (rpmGlob("~", NULL, &paths) != 0) {
printf("No matches.\n");
exit(1);
}
for (path = paths; *path; path++)
printf("\"%s\"\n", *path);
}
$ gcc -lrpmio -o globtest globtest.c
$ echo $HOME
/home/test
$ ./globtest
"/home/test"
$ mkdir myroot
# before [1]
$ FAKECHROOT_BASE=$PWD/myroot HOME=$PWD/myroot fakechroot ./globtest No matches.
# after [1]
$ FAKECHROOT_BASE=$PWD/myroot HOME=$PWD/myroot fakechroot ./globtest ""
[1] 66fa46c006bae0f28d93238b8f7f1c923645eee5
[2] 7788763e09b7beed75345e11c223735ad4829fdb
89676fad73d0808588dca620344efa4d6b3889b4
You can view, comment on, or merge this pull request online at:
https://github.com/rpm-software-management/rpm/pull/2401
-- Commit Summary --
* Fix a test relying on glibc version of glob(3)
-- File Changes --
M tests/rpmi.at (2)
-- Patch Links --
https://github.com/rpm-software-management/rpm/pull/2401.patch
https://github.com/rpm-software-management/rpm/pull/2401.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/2401
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/pull/2401 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20230227/afe5d955/attachment-0001.html>
More information about the Rpm-maint
mailing list