#!/bin/bash set -e mold=$1 cd $(dirname $0) echo -n "Testing $(basename -s .sh $0) ... " t=$(pwd)/tmp/$(basename -s .sh $0) mkdir -p $t cat <&1 \ | grep -q 'undefined symbol:.*foo' clang -fuse-ld=$mold -o $t/exe $t/a.o --warn-unresolved-symbols 2>&1 \ | grep -q 'undefined symbol:.*foo' ! clang -fuse-ld=$mold -o $t/exe $t/a.o --warn-unresolved-symbols \ --error-unresolved-symbols 2>&1 \ | grep -q 'undefined symbol:.*foo' echo OK