#!/bin/bash set -e cd $(dirname $0) mold=`pwd`/../mold echo -n "Testing $(basename -s .sh $0) ... " t=$(pwd)/tmp/$(basename -s .sh $0) mkdir -p $t cat < $t/log || false grep -q 'undefined symbol: .*: _Z3fooii' $t/log ! clang -fuse-ld=$mold -o $t/exe $t/a.o -Wl,-demangle 2> $t/log || false grep -Pq 'undefined symbol: .*: foo\(int, int\)' $t/log ! clang -fuse-ld=$mold -o $t/exe $t/a.o 2> $t/log || false grep -Pq 'undefined symbol: .*: foo\(int, int\)' $t/log cat < $t/log || false grep -q 'undefined symbol: .*: Pi' $t/log echo OK