forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_lfortran_cmdline
executable file
·98 lines (83 loc) · 1.55 KB
/
test_lfortran_cmdline
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
#!/bin/bash
set -e
set -x
if [[ $1 == "" ]]; then
echo "Test local lfort"
PATH="$(pwd):$PATH"
FC=lfort
elif [[ $1 == "lfort" ]]; then
echo "Test installed lfort"
FC=lfort
elif [[ $1 == "gfortran" ]]; then
echo "Test installed gfortran"
FC=gfortran
elif [[ $1 == "lfortran" ]]; then
echo "Test installed lfortran"
FC=lfortran
else
echo "Invalid option"
exit 1
fi
f=`pwd`/examples/expr2.f90
ASM_PATTERN="movq\|movl\|retq"
cd $(mktemp -d)
$FC $f -o a.out
[ -f "a.out" ]
[ -x "a.out" ]
./a.out
cd $(mktemp -d)
$FC -c $f
[ -f "expr2.o" ]
[ ! -x "expr2.o" ]
$FC -o expr2 expr2.o
[ -f "expr2" ]
[ -x "expr2" ]
./expr2
cd $(mktemp -d)
$FC -o xx1 -c $f
[ -f "xx1" ]
[ ! -x "xx1" ]
$FC -o expr2 xx1
[ -f "expr2" ]
[ -x "expr2" ]
./expr2
cd $(mktemp -d)
$FC -o xx1 $f
[ -f "xx1" ]
[ -x "xx1" ]
./xx1
cd $(mktemp -d)
$FC -S $f
[ -f "expr2.s" ]
grep $ASM_PATTERN expr2.s
cd $(mktemp -d)
$FC -S -c $f
[ -f "expr2.s" ]
grep $ASM_PATTERN expr2.s
cd $(mktemp -d)
$FC -S -o xx1 $f
[ -f "xx1" ]
grep $ASM_PATTERN xx1
cd $(mktemp -d)
$FC -S -o xx1 -c $f
[ -f "xx1" ]
grep $ASM_PATTERN xx1
if [[ $FC == "lfort" ]]; then
# Python LFortran specific options
cd $(mktemp -d)
$FC --show-ast $f > log
[ ! -f "expr2.o" ]
grep 'mod.Program' log
grep 'Integer()' log && exit 1
$FC --show-ast-typed $f > log
[ ! -f "expr2.o" ]
grep 'mod.Program' log
grep 'Integer()' log
cd $(mktemp -d)
$FC -emit-llvm $f
[ -f "expr2.ll" ]
cd $(mktemp -d)
$FC $f
[ ! -f "a.out" ]
fi
echo "All tests succeeded"