#!/bin/sh

set -eu

testdir=${0%/*}

busybox httpd -h ${testdir} -p 9000
trap "pkill -f 'busybox httpd'" INT TERM EXIT
sleep 1

page=${0##*/}

cd "${AUTOPKGTEST_TMP}"

set -x
wget --recursive --page-requisites http://localhost:9000/${page}.html
set +x

rc=0
for ext in css woff woff svg eot ttf; do
    files=$(find localhost:9000/ -name \*."$ext")
    for f in $files; do
        echo "Found $ext: $f"
    done
    if [ -z "$files" ]; then
        echo "E: No $ext found"
        rc=1
    fi
done

exit "$rc"
