| 1 | #!/bin/sh |
| 2 | # Runs test/libc on Alpine, whose C library is musl, in a docker |
| 3 | # container: raz, a static program, compiles each program there, so it |
| 4 | # links it against musl by default, having only musl's loader; then |
| 5 | # each runs, its output and status compared as test/check.sh compares |
| 6 | # them. Needs docker, and the network the first time, for the image. |
| 7 | |
| 8 | image=${ALPINE:-alpine:3.20} |
| 9 | exec docker run --rm -v "$PWD":/raz:ro -w /raz "$image" sh -c ' |
| 10 | pass=0; fail=0; out=/tmp/out; mkdir -p $out |
| 11 | for f in test/libc/*.raz; do |
| 12 | name=$(basename $f .raz) |
| 13 | if ! ./raz -Werror -I test/libc/mods -o $out/$name $f 2>$out/$name.cerr; then |
| 14 | echo "FAIL $f: does not compile: $(cat $out/$name.cerr)"; fail=$((fail + 1)); continue |
| 15 | fi |
| 16 | if ! grep -q ld-musl $out/$name; then # the loader it names |
| 17 | echo "FAIL $f: not linked against musl"; fail=$((fail + 1)); continue |
| 18 | fi |
| 19 | [ -f test/libc/$name.expect ] || { pass=$((pass + 1)); continue; } |
| 20 | status=$( { ( cd /tmp && exec $out/$name ) > $out/$name.out 2>$out/$name.err; echo $?; } 2>/dev/null ) |
| 21 | want=0; [ -f test/libc/$name.status ] && want=$(cat test/libc/$name.status) |
| 22 | if ! cmp -s $out/$name.out test/libc/$name.expect; then |
| 23 | echo "FAIL $f: output differs"; diff $out/$name.out test/libc/$name.expect | head -5; fail=$((fail + 1)) |
| 24 | elif [ $status != $want ]; then |
| 25 | echo "FAIL $f: status $status, not $want"; cat $out/$name.err | head -5; fail=$((fail + 1)) |
| 26 | else |
| 27 | pass=$((pass + 1)) |
| 28 | fi |
| 29 | done |
| 30 | cat /etc/alpine-release | sed "s/^/Alpine /" |
| 31 | echo "$pass passed, $fail failed" |
| 32 | [ $fail = 0 ]' |