-
Notifications
You must be signed in to change notification settings - Fork 31
/
setup.sh
executable file
·141 lines (126 loc) · 3.54 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#This is necessary in every sub-script that loads spack packages.
command -v spack >/dev/null 2>&1 || { source /spack/share/spack/setup-env.sh; }
command -v spack >/dev/null 2>&1 || { echo "Failure: Spack not found. Exiting"; exit 1; }
source ${SPACK_ROOT}/share/spack/setup-env.sh
#source ./settings.sh
#echo $BASH_SOURCE
#echo dirname $BASH_SOURCE
if [ -z ${TESTSUITE_SETTINGS_FILE+x} ]; then source `dirname $BASH_SOURCE`/settings.sh; else source $TESTSUITE_SETTINGS_FILE; fi
#alias test_run='$TEST_RUN'
rArg=" "
dArg=" -dpl "
spackTestRun(){
testOut=$(timeout 10m spack test run /${1} )
res=$?
echo "--- $testOut ---"
#echo $testOut | grep "No installed packages match spec"
#grepRes=$?
#echo $grepRes
if [ $res -eq 0 ]; then
testHash=$(echo "$testOut" | head -n 1 | awk '{print $NF}')
echo TEST-HASH: $testHash
spack test results -l $testHash
fi
return $res
}
spackHashFromName(){
E4S_SPACK_TEST_HASH_NAME=${@^^}_HASH
E4S_SPACK_TEST_HASH_NAME=`echo $E4S_SPACK_TEST_HASH_NAME | tr '-' '_'`
echo ${!E4S_SPACK_TEST_HASH_NAME}
}
spackSetPackageRoot(){
# echo ${1}
ARCH_IFS=$IFS
IFS=' '
PACK_ARRAY=(${1})
IFS=$ARCH_IFS
# echo ${PACK_ARRAY[0]}
# echo ${PACK_ARRAY[1]}
# echo ${PACK_ARRAY[2]}
NAME_BLOB=${PACK_ARRAY[1]}
SPAC_NAM=${NAME_BLOB%@*}
SPAC_LOC=${PACK_ARRAY[2]} #`spack location -i ${1}`
SPAC_NAM=${SPAC_NAM^^}
SPAC_NAM=`echo $SPAC_NAM | tr '-' '_'`
if [ $SPAC_NAM = BINUTILS ];then
SPAC_NAM=BINUTILS_E4S
fi
#eval "${SPAC_NAM}_ROOT"
###BEWARE: Setting this value can
#echo $SPAC_NAM
export ${SPAC_NAM}_ROOT=${SPAC_LOC}
export ${SPAC_NAM}_HASH=${PACK_ARRAY[0]}
export ${SPAC_NAM}_LIB_PATH=${SPAC_LOC}/lib64
if [[ ! -d ${SPAC_LOC}/lib64 ]]; then
export ${SPAC_NAM}_LIB_PATH=${SPAC_LOC}/lib
fi
}
expinst=" -x "
spackGetUniqueExplicit(){
#set -x
xhashes=`spack find $expinst --format {hash} $@ $TESTSUITE_VARIANT`
ret_val=$?
if [ $ret_val -ne 0 ] ; then
#echo "get unique Returning 215!"
#export SPACK_LOAD_RESULT=215
return 215
fi
echo $xhashes | awk '{print $1}'
#unset -x
}
spackLoadUnique(){
if [[ ! -z $E4S_TEST_SETUP ]]; then
echo "Skipping load: Environment already setup"
return
fi
#SPACK_LOAD_RESULT=0
uniquehash=`spackGetUniqueExplicit $@`
ret_val=$?
if [ $ret_val -ne 0 ] ; then
#echo "Returning 215!"
export SPACK_LOAD_RESULT=215
return 215
fi
#spack load $rArg --first $@ $TESTSUITE_VARIANT
spack load /${uniquehash}
ret_val=$?
#echo "Load return: $ret_val"
if [ $ret_val -ne 0 ] ; then
#echo "Returning 215!"
export SPACK_LOAD_RESULT=215
return 215
fi
#FIND_ARRAY1=($(spack find -l --loaded $@)) #`spack find -l --loaded $@`
#HASHDEX=${#FIND_ARRAY1[@]}-2
HASH=${uniquehash} #${FIND_ARRAY1[HASHDEX]}
echo "$@ $TESTSUITE_VARIANT: $HASH"
export E4S_TEST_HASH=$HASH
ARCH_IFS=$IFS
FIND_BLOB2=`spack find $dArg /$HASH`
IFS=$'\n'
FIND_ARRAY2=(${FIND_BLOB2}) #($($dArg /$HASH))
IFS=$ARCH_IFS
for((i=${#FIND_ARRAY2[@]}-1; i>=0; i--)); do
#echo ${FIND_ARRAY2[i]}
if [[ ${FIND_ARRAY2[i]} == --* ]]; then
break
fi
spackSetPackageRoot "${FIND_ARRAY2[i]}"
done
IFS=$ARCH_IFS
}
spackLoadUniqueNoX(){
expinst=" "
spackLoadUnique $@
expinst=" -x "
}
spackLoadUniqueNoR(){
#spack load $@
rArg=" --only package "
dArg=" -pl "
spackLoadUnique $@
_ret=$?
rArg=" "
dArg=" -dpl "
return $_ret
}