diff options
Diffstat (limited to 'test/cases/librechroot.bats')
-rw-r--r-- | test/cases/librechroot.bats | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/test/cases/librechroot.bats b/test/cases/librechroot.bats index 7d05ebc..ca61e1e 100644 --- a/test/cases/librechroot.bats +++ b/test/cases/librechroot.bats @@ -49,19 +49,31 @@ load ../lib/common @test "librechroot obeys depends in PKGBUILD" { require network sudo || skip - # Make sure it's not in the base install + # NB: We chown `/startdir` because chcleanup runs `makepkg + # --printsrcinfo > .SRCINFO` as the user that owns + # `/startdir/PKGBUILD`, and `makepkg` doesn't like to be run + # as root. Unfortunately, this test runs with a chroot that + # doesn't have the `builduser` set up, and it'd be a pain to + # set it up. So choose an arbitrary user from + # `/usr/lib/sysusers.d/arch.conf`. + local builduser_uid="${SUDO_UID:-$UID}" + local builduser_gid="$(id -g "$builduser_uid")" + testsudo librechroot -l "$BATS_TEST_NAME" run sh -c " + echo 'builduser:x:${builduser_gid}:' >>/etc/group + echo 'builduser:x:${builduser_uid}:${builduser_gid}:builduser:/build:/bin/bash' >>/etc/passwd + echo 'builduser:!!:$(( $(date -u +%s) / 86400 ))::::::' >>/etc/shadow" + + # Pre-flight: Make sure `lsof` isn't in the base install not testsudo librechroot -l "$BATS_TEST_NAME" run lsof - # Make sure it removes it without the PKGBUILD + # Make sure librechroot removes `lsof` when the PKGBUILD is not present. testsudo librechroot -l "$BATS_TEST_NAME" install-name lsof testsudo librechroot -l "$BATS_TEST_NAME" run lsof testsudo librechroot -l "$BATS_TEST_NAME" clean-pkgs not testsudo librechroot -l "$BATS_TEST_NAME" run lsof - # Make sure it leaves it with the PKGBUILD + # Make sure librechroot keeps `lsof` when the PKGBUILD is present. testsudo librechroot -l "$BATS_TEST_NAME" install-name lsof testsudo librechroot -l "$BATS_TEST_NAME" run sh -c 'printf "%s\n" "$1" > /startdir/PKGBUILD' -- "$(cat fixtures/librechroot/PKGBUILD-arches)" - # uid=99 is 'nobody', but we say '99' because sometimes 'nobody' is uid=65534. - # https://bugs.archlinux.org/task/56828 - testsudo librechroot -l "$BATS_TEST_NAME" run chown -R 99:99 /startdir + testsudo librechroot -l "$BATS_TEST_NAME" run chown -R builduser: /startdir testsudo librechroot -l "$BATS_TEST_NAME" clean-pkgs testsudo librechroot -l "$BATS_TEST_NAME" run lsof } @@ -69,12 +81,21 @@ load ../lib/common @test "librechroot can install libretools with chcleanup" { require network sudo || skip + # NB: We chown `/startdir` because chcleanup runs `makepkg + # --printsrcinfo > .SRCINFO` as the user that owns + # `/startdir/PKGBUILD`, and `makepkg` doesn't like to be run + # as root. + local builduser_uid="${SUDO_UID:-$UID}" + local builduser_gid="$(id -g "$builduser_uid")" + testsudo librechroot -l "$BATS_TEST_NAME" run sh -c " + echo 'builduser:x:${builduser_gid}:' >>/etc/group + echo 'builduser:x:${builduser_uid}:${builduser_gid}:builduser:/build:/bin/bash' >>/etc/passwd + echo 'builduser:!!:$(( $(date -u +%s) / 86400 ))::::::' >>/etc/shadow" + not testsudo librechroot -l "$BATS_TEST_NAME" run test -f /usr/bin/chcleanup testsudo librechroot -l "$BATS_TEST_NAME" run mkdir /startdir testsudo librechroot -l "$BATS_TEST_NAME" run sh -c 'printf "%s\n" "$1" > /startdir/PKGBUILD' -- "$(cat fixtures/librechroot/PKGBUILD-libretools)" - # uid=99 is 'nobody', but we say '99' because sometimes 'nobody' is uid=65534. - # https://bugs.archlinux.org/task/56828 - testsudo librechroot -l "$BATS_TEST_NAME" run chown -R 99:99 /startdir + testsudo librechroot -l "$BATS_TEST_NAME" run chown -R builduser: /startdir testsudo librechroot -l "$BATS_TEST_NAME" clean-pkgs testsudo librechroot -l "$BATS_TEST_NAME" run test -f /usr/bin/chcleanup } |