From cc23957a2c3b34604f0b15aa8fe1157d6d7f3aa2 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 15 Mar 2017 21:53:31 -0400 Subject: [PATCH] tests: Stop using "ostree trivial-httpd" I built+installed ostree git master with https://github.com/ostreedev/ostree/pull/723 in my dev container, which broke the rpm-ostree tests. Kind of embarrassing that I forgot to check rpm-ostree for usage of `ostree trivial-httpd`. This is another thing that really wants a shared test container. Anyways let's just use Python for this. Closes: #684 Approved by: jlebon --- tests/common/libtest.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/common/libtest.sh b/tests/common/libtest.sh index e517fe3c..7042e1ce 100644 --- a/tests/common/libtest.sh +++ b/tests/common/libtest.sh @@ -189,6 +189,19 @@ setup_test_repository () { cd $oldpwd } +run_temp_webserver() { + env PYTHONUNBUFFERED=1 setsid python -m SimpleHTTPServer 0 >${test_tmpdir}/httpd-output & + for x in $(seq 50); do + sed -e 's,Serving HTTP on 0.0.0.0 port \([0-9]*\) \.\.\.,\1,' < ${test_tmpdir}/httpd-output > ${test_tmpdir}/httpd-port + if ! cmp ${test_tmpdir}/httpd-output ${test_tmpdir}/httpd-port 1>/dev/null; then + break + fi + sleep 0.1 + done + port=$(cat ${test_tmpdir}/httpd-port) + echo "http://127.0.0.1:${port}" > ${test_tmpdir}/httpd-address +} + setup_fake_remote_repo1() { mode=$1 args=$2 @@ -218,9 +231,7 @@ setup_fake_remote_repo1() { mkdir ${test_tmpdir}/httpd cd httpd ln -s ${test_tmpdir}/ostree-srv ostree - ostree trivial-httpd --autoexit --daemonize -p ${test_tmpdir}/httpd-port $args - port=$(cat ${test_tmpdir}/httpd-port) - echo "http://127.0.0.1:${port}" > ${test_tmpdir}/httpd-address + run_temp_webserver cd ${oldpwd} export OSTREE="ostree --repo=repo" @@ -322,9 +333,7 @@ EOF mkdir ${test_tmpdir}/httpd cd httpd ln -s ${test_tmpdir} ostree - ostree trivial-httpd --autoexit --daemonize -p ${test_tmpdir}/httpd-port $args - port=$(cat ${test_tmpdir}/httpd-port) - echo "http://127.0.0.1:${port}" > ${test_tmpdir}/httpd-address + run_temp_webserver cd ${oldpwd} }