forked from OpenModelica/OMLibraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-valid.sh
executable file
·32 lines (30 loc) · 959 Bytes
/
test-valid.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
#!/bin/sh
if test $# -ne 3 || ! test -f "$3"; then
echo "Usage: $0 omc build/dir path/file.mo"
exit 1
fi
OMC=$1
BUILD=$2
FILE=$3
rm -f $$.parse.log
# Verify that all libraries parse
cat > test-valid.$$.mos <<EOF
setModelicaPath("");getErrorString();
b:=loadFile("$FILE",uses=false);getErrorString();
s:=getErrorString();
if not b then
writeFile("$$.parse.log","Failed to load $FILE:\n" + s + "\n");
writeFile("error.log","Failed to load $FILE:\n" + s + "\n",append=true);
end if;
EOF
LIB=`echo $FILE | sed s,/package.mo,, | sed s,.mo$,, | sed s,$BUILD/,,`
if test -f "$BUILD/$LIB.std"; then
STD=`cat "$BUILD/$LIB.std"`
STD="+std=$STD"
fi
"$OMC" "+n=1" $STD test-valid.$$.mos > /dev/null
rm test-valid.$$.mos
echo $FILE turned to $LIB
# find "`echo $2 | sed s,/package.mo,,`" -type f -print0 | sort -z | xargs -0 cat | sha1sum > "$BUILD/$LIB.hash"
touch "$BUILD/$LIB.ok"
test ! -f $$.parse.log || (cat $$.parse.log ; rm -f $$.parse.log ; exit 1)