[interp] Fix resuming from finally block (#8195)
[mono-project.git] / mono / mini / test_op_il_seq_point.sh
blobee235f5c739cb4a91bb87edfe55e0b5bb5a14f3c
1 #!/bin/bash
3 DEFAULT_PROFILE=$1
4 TEST_FILE=$2
5 USE_AOT=$3
7 TMP_FILE_PREFIX=$(basename $0).tmp
8 BASEDIR=$(dirname $0)
10 case "$(uname -s)" in
11 CYGWIN*) PLATFORM_PATH_SEPARATOR=';';;
12 *) PLATFORM_PATH_SEPARATOR=':';;
13 esac
15 MONO_PATH=$BASEDIR/../../mcs/class/lib/$DEFAULT_PROFILE$PLATFORM_PATH_SEPARATOR$BASEDIR
16 RUNTIME=$BASEDIR/../../runtime/mono-wrapper
18 trap "rm -rf ${TMP_FILE_PREFIX}*" EXIT
20 tmp_file () {
21 mktemp ./${TMP_FILE_PREFIX}XXXXXX
24 clean_aot () {
25 rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM *.exe.dll
28 # The test compares the generated native code size between a compilation with and without seq points.
29 # In some architectures ie:amd64 when possible 32bit instructions and registers are used instead of 64bit ones.
30 # Using MONO_DEBUG=single-imm-size avoids 32bit optimizations thus mantaining the native code size between compilations.
32 get_methods () {
33 if [ -z $4 ]; then
34 MONO_PATH=$1 $2 -v --compile-all=1 $3 | grep '^Method .*code length' | sed 's/emitted[^()]*//' | sort
35 else
36 clean_aot
37 MONO_PATH=$1 $2 -v --aot $3 | grep '^Method .*code length' | sed 's/emitted[^()]*//' | sort
41 get_method () {
42 if [ -z $5 ]; then
43 MONO_VERBOSE_METHOD="$4" MONO_PATH=$1 $2 --compile-all=1 $3 | sed 's/0x[0-9a-fA-F]*/0x0/g'
44 else
45 clean_aot
46 MONO_VERBOSE_METHOD="$4" MONO_PATH=$1 $2 --aot $3 | sed 's/0x[0-9a-fA-F]*/0x0/g'
50 diff_methods () {
51 TMP_FILE1=$(tmp_file)
52 TMP_FILE2=$(tmp_file)
53 echo "$(MONO_DEBUG=no-compact-seq-points,single-imm-size get_methods $1 $2 $3 $4)" >$TMP_FILE1
54 echo "$(MONO_DEBUG=single-imm-size get_methods $1 $2 $3 $4)" >$TMP_FILE2
55 diff $TMP_FILE1 $TMP_FILE2
58 diff_method () {
59 TMP_FILE1=$(tmp_file)
60 TMP_FILE2=$(tmp_file)
61 echo "$(MONO_DEBUG=no-compact-seq-points,single-imm-size get_method $1 $2 $3 $4 $5)" >$TMP_FILE1
62 echo "$(MONO_DEBUG=single-imm-size get_method $1 $2 $3 $4 $5 | grep -Ev il_seq_point)" >$TMP_FILE2
63 sdiff -w 150 $TMP_FILE1 $TMP_FILE2
66 get_method_name () {
67 echo $1 | sed -E 's/.*Method (\([^)]*\) )?([^ ]*).*/\2/g'
70 get_method_length () {
71 echo $1 | sed 's/.*code length \([0-9]*\).*/\1/'
74 if [ -z $USE_AOT ]; then
75 echo "Checking unintended native code changes in $TEST_FILE without AOT"
76 else
77 echo "Checking unintended native code changes in $TEST_FILE with AOT"
80 TMP_FILE=$(tmp_file)
82 echo "$(diff_methods $MONO_PATH $RUNTIME $TEST_FILE $USE_AOT)" > $TMP_FILE
84 CHANGES=0
85 METHOD=""
86 MIN_SIZE=10000
88 while read line; do
89 if [ "$line" != "" ]; then
90 echo $line
91 if [[ ${line:0:1} == "<" ]]; then
92 CHANGES=$((CHANGES+1))
93 SIZE=$(get_method_length "$line")
94 if [[ SIZE -lt MIN_SIZE ]]; then
95 MIN_SIZE=$SIZE
96 METHOD="$line"
100 done < $TMP_FILE
102 TESTRESULT_FILE=TestResult-op_il_seq_point.tmp
104 echo -n " <test-case name=\"MonoTests.op_il_seq_point.${TEST_FILE}${USE_AOT}\" executed=\"True\" time=\"0\" asserts=\"0\" success=\"" >> $TESTRESULT_FILE
106 if [ $CHANGES != 0 ]
107 then
108 METHOD_NAME=$(get_method_name "$METHOD")
110 echo "False\">" >> $TESTRESULT_FILE
111 echo " <failure>" >> $TESTRESULT_FILE
112 echo -n " <message><![CDATA[" >> $TESTRESULT_FILE
113 echo "Detected OP_IL_SEQ_POINT incompatibility on $TEST_FILE" >> $TESTRESULT_FILE
114 echo " $CHANGES methods differ when sequence points are enabled." >> $TESTRESULT_FILE
115 echo ' This is probably caused by a runtime optimization that is not handling OP_IL_SEQ_POINT' >> $TESTRESULT_FILE
116 echo '' >> $TESTRESULT_FILE
117 echo "Diff $METHOD_NAME" >> $TESTRESULT_FILE
118 echo "Without IL_OP_SEQ_POINT With IL_OP_SEQ_POINT" >> $TESTRESULT_FILE
119 echo -n "$(diff_method $MONO_PATH $RUNTIME $TEST_FILE $METHOD_NAME $USE_AOT)" >> $TESTRESULT_FILE
120 echo "]]></message>" >> $TESTRESULT_FILE
121 echo " <stack-trace>" >> $TESTRESULT_FILE
122 echo " </stack-trace>" >> $TESTRESULT_FILE
123 echo " </failure>" >> $TESTRESULT_FILE
124 echo " </test-case>" >> $TESTRESULT_FILE
126 echo ''
127 echo "Detected OP_IL_SEQ_POINT incompatibility on $TEST_FILE"
128 echo " $CHANGES methods differ when sequence points are enabled."
129 echo ' This is probably caused by a runtime optimization that is not handling OP_IL_SEQ_POINT'
131 echo ''
132 echo "Diff $METHOD_NAME"
133 echo "Without IL_OP_SEQ_POINT With IL_OP_SEQ_POINT"
134 echo "$(diff_method $MONO_PATH $RUNTIME $TEST_FILE $METHOD_NAME $USE_AOT)"
135 exit 1
136 else
137 echo "True\" />" >> $TESTRESULT_FILE