Debian Codegraph @

go/test-versions.sh

raw
1 #!/bin/bash
2 #
3 # Takes a list of install prefixes and tests the go source under the current directory
4 # against the proton install in each prefix.
5 #
6 # NOTE: This script will fail if it finds proton headers or libraries installed in standard
7 # places or on the existing paths, to avoid possible confusion.
8 #
9
10 for VAR in LD_LIBRARY_PATH LIBRARY_PATH C_INCLUDE_PATH; do
11 declare OLD_${VAR}=${!VAR};
12 done
13
14 prefix() {
15 prefix=$1
16 export LD_LIBRARY_PATH="$prefix/lib64:$prefix/lib:$OLD_LD_LIBRARY_PATH"
17 export LIBRARY_PATH="$prefix/lib64:$prefix/lib:$OLD_LIBRARY_PATH"
18 export C_INCLUDE_PATH="$prefix/include:$OLD_C_INCLUDE_PATH"
19 }
20
21 TEMP=$(mktemp -d)
22 trap "rm -rf $TEMP" EXIT
23 set -o pipefail
24
25 cat > $TEMP/test.c <<EOF
26 #include <proton/connection.h>
27 int main(int c, char **a) { return 0; }
28 EOF
29 cc $TEMP/test.c 2> /dev/null && {
30 echo "cc found proton in include path"; cc -E | grep proton/connection.h | head -n1; exit 1; } 1>&2
31
32 cat > $TEMP/test.c <<EOF
33 int main(int c, char **a) { return 0; }
34 EOF
35 cc -lqpid-proton $TEMPC 2>/dev/null && { echo "cc found proton in library path" 1>&2 ; exit 1; }
36
37 for P in "$@"; do
38 (
39 case $P in
40 /*) ;;
41 *) P=$PWD/$P;;
42 esac
43 test -d $P || { echo "no such directory: $P"; continue; }
44 echo ==== $P
45 prefix $P
46 export GOPATH=$PWD
47 git clean -dfx
48 go test qpid.apache.org/...
49 )
50 done