diff --git a/.github/workflows/genesis-openembedded.yml b/.github/workflows/genesis-openembedded.yml index bde8ffa..8a4885b 100644 --- a/.github/workflows/genesis-openembedded.yml +++ b/.github/workflows/genesis-openembedded.yml @@ -97,3 +97,15 @@ jobs: echo 'a native test file was skipped' >&2 exit 1 fi + + # Ubuntu ships no mock, so the test of mock's configuration loader runs on Fedora. + - name: Run mock configuration loader test + run: | + set -o pipefail + docker run --rm -v "$PWD:/src:ro" -w /src fedora:42 bash -ec ' + dnf -y -q install mock perl perl-File-Slurper >/dev/null + prove -v native/mock-chroot-uid.t' 2>&1 | tee mock.tap + if grep -E '^1\.\.0 # SKIP|^native/[^ ]+\.t \.+ skipped' mock.tap; then + echo 'the mock configuration loader test was skipped' >&2 + exit 1 + fi diff --git a/native/mock-chroot-uid.t b/native/mock-chroot-uid.t new file mode 100644 index 0000000..510c3c2 --- /dev/null +++ b/native/mock-chroot-uid.t @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +# mock_chroot_uid must give the uid mock itself builds as, so it runs mock's own loader. +use strict; +use warnings; + +use File::Slurper qw(write_text); +use File::Temp qw(tempdir); +use FindBin qw($RealBin); +use Test::More; + +use lib "$RealBin/.."; +use MockBuildUtils qw(mock_chroot_uid); + +plan skip_all => 'native Mock Python library required' + if system('python3 -c "import mockbuild.config" >/dev/null 2>&1') != 0; + +my $tmp = tempdir(CLEANUP => 1); +write_text("$tmp/base.cfg", <<'CFG'); +config_opts['root'] = 'xcat-chrootuid-base' +config_opts['chrootuid'] = 1000 +CFG +write_text("$tmp/override.cfg", <<"CFG"); +include('$tmp/base.cfg') +config_opts['chrootuid'] = 1001 +CFG +write_text("$tmp/wrapper.cfg", <<"CFG"); +include('$tmp/base.cfg') +config_opts['environment']['SOURCE_DATE_EPOCH'] = '1757000000' +CFG +write_text("$tmp/plain.cfg", "config_opts['root'] = 'xcat-chrootuid-plain'\n"); + +is(mock_chroot_uid("$tmp/override.cfg"), 1001, 'a chrootuid set after an include overrides the include'); +is(mock_chroot_uid("$tmp/wrapper.cfg"), 1000, 'a wrapper keeps the chrootuid of the configuration it includes'); +is(mock_chroot_uid("$tmp/plain.cfg"), $<, 'a configuration with no chrootuid keeps the uid that runs mock'); + +done_testing();