[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / test_modfile.sh
blobf52452030d66340f873595de9507c2df5b00e239
1 #!/usr/bin/env bash
2 # Compile a source file and compare generated .mod files against expected.
4 set -e
5 FLANG_FC1_OPTIONS="-fsyntax-only"
6 srcdir=$(dirname $0)
7 source $srcdir/common.sh
9 actual=$temp/actual.mod
10 expect=$temp/expect.mod
11 actual_files=$temp/actual_files
12 prev_files=$temp/prev_files
13 diffs=$temp/diffs
15 set $src
17 touch $actual
18 for src in "$@"; do
19 [[ ! -f $src ]] && echo "File not found: $src" && exit 1
20 path=$(git ls-files --full-name $src 2>/dev/null || echo $src)
22 cd $temp
23 ls -1 *.mod > prev_files
24 $FLANG_FC1 $FLANG_FC1_OPTIONS $src
25 ls -1 *.mod | comm -13 prev_files -
26 ) > $actual_files
27 expected_files=$(sed -n 's/^!Expect: \(.*\)/\1/p' $src | sort)
28 extra_files=$(echo "$expected_files" | comm -23 $actual_files -)
29 if [[ ! -z "$extra_files" ]]; then
30 echo "Unexpected .mod files produced:" $extra_files
31 die FAIL $path
33 for mod in $expected_files; do
34 if [[ ! -f $temp/$mod ]]; then
35 echo "Compilation did not produce expected mod file: $mod"
36 die FAIL $path
38 # The first three bytes of the file are a UTF-8 BOM
39 sed '/^[^!]*!mod\$/d' $temp/$mod > $actual
40 sed '1,/^!Expect: '"$mod"'/d' $src | sed -e '/^$/,$d' -e 's/^!//' > $expect
41 if ! diff -w -U999999 $expect $actual > $diffs; then
42 echo "Module file $mod differs from expected:"
43 sed '1,2d' $diffs
44 die FAIL $path
46 done
47 rm -f $actual $expect
48 done
49 echo PASS