From c3d87bec70a58f76cde96cefd9be69011bc27cc3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 Oct 2018 20:31:08 -0400 Subject: test: libremakepkg: Verify that it correctly forwards ports through distcc-tool [ci-skip] --- test/cases/libremakepkg.bats | 29 ++++++++++++++++++++++++----- test/fixtures/libremakepkg/PKGBUILD-distcc | 24 +++++++++++++++--------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/test/cases/libremakepkg.bats b/test/cases/libremakepkg.bats index d511c38..9ddfd2e 100644 --- a/test/cases/libremakepkg.bats +++ b/test/cases/libremakepkg.bats @@ -8,6 +8,16 @@ setup() { eot } +teardown() { + local file + for file in "$tmpdir"/*.pid; do + [[ -f $file ]] || continue + xargs -a "$file" kill -- + done + + common_teardown +} + @test "libremakepkg builds a trivial package" { require network sudo || skip cp fixtures/libremakepkg/PKGBUILD-hello "$tmpdir/PKGBUILD" @@ -152,18 +162,27 @@ setup() { not globfile libretools-hello-1.0-1-any.pkg.tar.?z } -@test "libremakepkg allows distcc on long chrootpaths" { +@test "libremakepkg forwards distcc ports" { + require network sudo || skip + # The maximum AF_UNIX socket path is 108 bytes; so let's have - # a chroot name that's guaranteed to be >110 characters. + # a chroot name that's guaranteed to be >110 characters, to + # make sure we handle that. local chrootname=$BATS_TEST_NAME.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - require network sudo || skip - cp fixtures/libremakepkg/PKGBUILD-distcc "$tmpdir/PKGBUILD" - cd "$tmpdir" + local distcc_port + distcc_port=$(./lib/runserver "$tmpdir/distcc.pid" \ + echo 'Hello, I am a distcc server') cat >> "$XDG_CONFIG_HOME/libretools/chroot.conf" <<-eot CHROOTEXTRAPKG+=(distcc-nozeroconf socat) eot + cat >> "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot + DISTCC_HOSTS=127.0.0.1:${distcc_port@Q} + eot + + cp fixtures/libremakepkg/PKGBUILD-distcc "$tmpdir/PKGBUILD" + cd "$tmpdir" testsudo librechroot -l "$chrootname" install-name distcc-nozeroconf socat testsudo libremakepkg -l "$chrootname" globfile libretools-distcc-1.0-1-any.pkg.tar.?z diff --git a/test/fixtures/libremakepkg/PKGBUILD-distcc b/test/fixtures/libremakepkg/PKGBUILD-distcc index 5127ae6..e9f1d72 100644 --- a/test/fixtures/libremakepkg/PKGBUILD-distcc +++ b/test/fixtures/libremakepkg/PKGBUILD-distcc @@ -5,19 +5,25 @@ url='https://parabola.nu' pkgrel=1 arch=(any) -depends=(sh) -build() { +build() ( cd "$srcdir" - echo '#!/bin/sh' > hello.sh - echo 'echo Hello, world!' >> hello.sh - # I don't like hard-coding in an implementation detail, but - # this is the simplest way to verify that `distcc-tool - # odaemon` started correctly. + set -x + + # Check that the odaemon socket exists [[ -S /socket ]] -} + + # ... and that it works + printf 'GET / HTTP/1.1\r\nHost: parabola.nu\r\n\r\n' | distcc-tool client parabola.nu 80 > http.txt + [[ "$(sed 1q http.txt)" == HTTP/* ]] + + # ... and that idaemon talks to it + socat TCP-CONNECT:"${DISTCC_HOSTS}" STDIO < /dev/null > hello.txt + [[ "$(cat hello.txt)" == 'Hello, I am a distcc server' ]] +) package() { cd "$srcdir" - install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello + install -Dm644 hello.txt "$pkgdir"/usr/share/hello.txt + install -Dm644 http.txt "$pkgdir"/usr/share/http.txt } -- cgit v1.2.2