-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
unittest.sh
executable file
·87 lines (74 loc) · 2.11 KB
/
unittest.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
#!/bin/bash
LOCALTOP=$1
DEVICE=$2
# the test is not possible if:
# 1. GPU not available (only if GPU test requested) / avx instructions not supported (needed for singularity on CPU)
# 1b. Nvidia drivers not available
# 2. wrong architecture (not amd64)
# 3. singularity not found or not usable
# 4. inside singularity container w/o unprivileged user namespace enabled (needed for singularity-in-singularity)
# so just return true in those cases
if [ "$DEVICE" = "GPU" ]; then
if nvidia-smi -L; then
echo "has GPU"
else
echo "missing GPU"
exit 0
fi
if cmsTriton check; then
echo "has NVIDIA driver"
else
echo "missing current or compatible NVIDIA driver"
exit 0
fi
else
if grep -q avx /proc/cpuinfo; then
echo "has avx"
else
echo "missing avx"
exit 0
fi
fi
THIS_ARCH=$(echo $SCRAM_ARCH | cut -d'_' -f2)
if [ "$THIS_ARCH" == "amd64" ]; then
echo "has amd64"
else
echo "missing amd64"
exit 0
fi
if type singularity >& /dev/null; then
echo "has singularity"
else
echo "missing singularity"
exit 0
fi
if [ -n "$SINGULARITY_CONTAINER" ]; then
if grep -q "^allow setuid = no" /etc/singularity/singularity.conf && unshare -U echo >/dev/null 2>&1; then
echo "has unprivileged user namespace support"
else
echo "missing unprivileged user namespace support"
exit 0
fi
fi
fallbackName=triton_server_instance_${DEVICE}
tmpFile=$(mktemp -p ${LOCALTOP} SonicTritonTestXXXXXXXX.log)
cmsRun ${LOCALTOP}/src/HeterogeneousCore/SonicTriton/test/tritonTest_cfg.py modules=TritonGraphProducer,TritonGraphFilter,TritonGraphAnalyzer maxEvents=2 unittest=1 verbose=1 device=${DEVICE} testother=1 fallbackName=${fallbackName} >& $tmpFile
CMSEXIT=$?
cat $tmpFile
sleep 15
STOP_COUNTER=0
while ! LOGFILE="$(ls -rt ${LOCALTOP}/log_${fallbackName}_*.log 2>/dev/null | tail -n 1)" && [ "$STOP_COUNTER" -lt 5 ]; do
STOP_COUNTER=$((STOP_COUNTER+1))
sleep 5
done
if [ -n "$LOGFILE" ]; then
echo -e '\n=====\nContents of '$LOGFILE':\n=====\n'
cat "$LOGFILE"
rm $LOGFILE
fi
if grep -q "Socket closed" $tmpFile; then
echo "Transient server error (not caused by client code)"
CMSEXIT=0
fi
rm $tmpFile
exit $CMSEXIT