diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9c9c80dbcb0cd91bd8c2ab294d0471be3db09422 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,139 @@ + +OBJDIR=../obj$(HOSTTYPE) + +LC0=$(OBJDIR)/lus2lic +LC=$(OBJDIR)/lus2lic -vl 2 +LC2=$(OBJDIR)/lus2lic + +NL="----------------------------------------------------------------------\\n" +filter_line=grep -v Opening\ file + +OK_LUS=$(shell find should_work -name "*.lus" -print | LC_ALL=C sort -n) + +KO_LUS=$(shell find should_fail -name "*.lus" -print | LC_ALL=C sort -n) + +ALL_LUS=$(OK_LUS) $(KO_LUS) + +all: + echo $(ALL_LUS) + +LIC=$(shell find should_work -name "*.lic" -print | LC_ALL=C sort -n) + + +when: + for d in ${ALL_LUS}; do \ + ls $$d; \ + grep -n " when" $$d; \ + done +tgz: + tar cvfz lustre_non_reg_files.tgz should_work should_fail + + +lic: + /bin/echo "generate all possible lic files" + for d in ${OK_LUS}; do \ + /bin/echo -e "\n$(NL)====> $(LC2) $$d -o $$d.lic " ;\ + $(LC2) $$d -o $$d.lic ;\ + done + +xxx: + /bin/echo "reentrant ?" + for d in ${LIC}; do \ + /bin/echo -e "\n$(NL)====> $(LC2) $$d " ;\ + $(LC2) $$d > /dev/null ;\ + done + + +begin: + /bin/echo "Non-regression tests" > test_ok.res + /bin/echo "Those tests are supposed to generate errors" > test_ko.res + + +unit: + $(LC0) -unit >> test_ok.res 2>&1 + +help: + $(LC0) -help >> test_ok.res 2>&1 + +version: + $(LC0) --version + +FILTER= grep -v "file was generated by" | grep -v " on " | grep -v "Opening file " + +do_not_exist: + $(LC) do_not_exist.lus | $(FILTER) >> test_ko.res 2>&1 || true + +test_lic: begin unit help version do_not_exist + for d in ${OK_LUS}; do \ + /bin/echo -e "\n$(NL)====> $(LC) --nonreg-test $$d" >> test_ok.res; \ + $(LC) --nonreg-test $$d >> test_ok.res 2>&1 ;\ + done; \ + for d in ${KO_LUS}; do \ + /bin/echo -e "\n$(NL)====> $(LC) --nonreg-test $$d" >> test_ko.res; \ + $(LC) --nonreg-test $$d >> test_ko.res 2>&1 ;\ + done; \ + rm -f test.res ; cat test_ok.res test_ko.res | $(FILTER) > test.res ;\ + diff -u test.res.exp test.res > test.diff || \ + (cat test.diff ; /bin/echo "cf test.diff"; exit 1) +utest_lic: + cp test.res test.res.exp + + +errors_nb: + /bin/echo -e "There were $(shell grep Error test_ok.res | wc -l) errors." + /bin/echo -e "There were $(shell grep Warning test_ok.res | wc -l) Warnings." + +errors:errors_nb + /bin/echo -e "There were $(shell grep Warning test_ok.res | wc -l) Warnings." + grep Warning test_ok.res || true + /bin/echo -e "There were $(shell grep Error test_ok.res | wc -l) errors." + grep "*** Error" test_ok.res + + + + + +test_ec: + rm -f test_ec.res + for d in ${OK_LUS}; do \ + /bin/echo -e "\n$(NL)====> $(LC0) --nonreg-test -ec $$d -o /tmp/xx.ec" >> test_ec.res; \ + $(LC0) -ec --nonreg-test $$d -o /tmp/xx.ec >> test_ec.res 2>&1 ;\ + /bin/echo -e "ec2c /tmp/xx.ec" >> test_ec.res; \ + (ec2c /tmp/xx.ec >> test_ec.res 2>&1 && /bin/echo -n "ok ") || /bin/echo " KO ($$d)!";\ + done; \ + diff -u test_ec.res.exp test_ec.res > test_ec.diff || \ + (cat test_ec.diff ; /bin/echo "cf test_ec.diff"; exit 1) + + +utest_ec: + cp test_ec.res test_ec.res.exp + +test_lv4: + rm test_lv4.res || /bin/echo ""; + for d in ${OK_LUS}; do \ + /bin/echo -e "\n$(NL)====> $(LC0) --nonreg-test -lv4 $$d -o /tmp/xx.lus" >> test_lv4.res; \ + $(LC0) --nonreg-test -lv4 $$d -o /tmp/xx.lus >> test_lv4.res 2>&1 ;\ + if [ ! -f /tmp/xx.lus ]; then echo "Error $$d: no /tmp/xx.lus file" >> test_lv4.res 2>&1; fi ;\ + for node in `lusinfo /tmp/xx.lus nodes`; do \ + /bin/echo -e "lus2ec /tmp/xx.lus $$node" >> test_lv4.res; \ + (lus2ec /tmp/xx.lus $$node >> \ + test_lv4.res 2>&1 && /bin/echo -n "ok ") \ + || /bin/echo " KO ($$d)!";\ + done; \ + done; \ + diff -u test_lv4.res.exp test_lv4.res > test_lv4.diff || \ + (cat test_lv4.diff ; /bin/echo "cf test_lv4.diff"; exit 1) + + +utest_lv4: + cp test_lv4.res test_lv4.res.exp + +test: test_lic test_ec test_lv4 +utest: utest_lic utest_ec utest_lv4 + + +clean: + rm -f *.c *.h *.ec + for d in ${ALL_LUS}; do \ + rm $$d.lic; \ + done diff --git a/tests/should_work/poly/ply01.lus b/tests/should_work/poly/ply01.lus new file mode 100644 index 0000000000000000000000000000000000000000..f0fc303becd5149449ffb8053faa388d0b21f64b --- /dev/null +++ b/tests/should_work/poly/ply01.lus @@ -0,0 +1,9 @@ + +(* ne passe pas DoNotPoly ... *) +node truc = map<<+,42>>; + +(* PASSE DoNotPoly ... *) +node trac = map<<Lustre::iplus,42>>; + +(* ne passe pas DoNotPoly ... *) +node main = truc; diff --git a/tests/should_work/poly/ply02.lus b/tests/should_work/poly/ply02.lus new file mode 100644 index 0000000000000000000000000000000000000000..74cb4dba69ab0f319e2062e70c8ad206418668ca --- /dev/null +++ b/tests/should_work/poly/ply02.lus @@ -0,0 +1,9 @@ + +(* ne passe pas DoNotPoly ... *) +node truc = map<<+,42>>; + +(* PASSE DoNotPoly en spécialisant truc ! ... *) +node main(x,y: int) returns (o: int^42); +let + o = if (x < y) then 0^42 else truc(x^42, y^42); +tel diff --git a/tests/should_work/poly/ply03.lus b/tests/should_work/poly/ply03.lus new file mode 100644 index 0000000000000000000000000000000000000000..57f13fb7a563993f6234f1ba3618b992dc8fc656 --- /dev/null +++ b/tests/should_work/poly/ply03.lus @@ -0,0 +1,5 @@ + +node main(x,y: int) returns (o: int^42); +let + o = if (x < y) then 0^42 else map<<+,42>>(x^42, y^42); +tel diff --git a/tests/should_work/static/cond01.lus b/tests/should_work/static/cond01.lus new file mode 100644 index 0000000000000000000000000000000000000000..f2865250592b9dc3fbb8dacc0cf32c7ae0ad6f12 --- /dev/null +++ b/tests/should_work/static/cond01.lus @@ -0,0 +1,5 @@ + +node main(c: bool; x,y:int) returns (o: int); +let + o = condact<<+,0>>(c,x,y); +tel diff --git a/tests/should_work/static/predef01.lus b/tests/should_work/static/predef01.lus new file mode 100644 index 0000000000000000000000000000000000000000..ff456acaeab74be76250bde531b19723cb835c41 --- /dev/null +++ b/tests/should_work/static/predef01.lus @@ -0,0 +1,7 @@ + + + +node main(x,y: bool^42) returns (o: bool^42); +let + o = map<<or, 42>>(x,y); +tel diff --git a/tests/should_work/static/predef02.lus b/tests/should_work/static/predef02.lus new file mode 100644 index 0000000000000000000000000000000000000000..5f5822e9f90e0fc9e9d3e2eebea7f024194569b2 --- /dev/null +++ b/tests/should_work/static/predef02.lus @@ -0,0 +1,7 @@ + + + +node main(x: bool^42) returns (o: bool); +let + o = red<<or, 42>>(false,x); +tel diff --git a/tests/should_work/static/predef03.lus b/tests/should_work/static/predef03.lus new file mode 100644 index 0000000000000000000000000000000000000000..c9e9dcac95e3973048686871023c9a070cea8b5d --- /dev/null +++ b/tests/should_work/static/predef03.lus @@ -0,0 +1,7 @@ + + + +node main(x: bool^13) returns (o: bool); +let + o = boolred<<1,2,13>>(x); +tel diff --git a/tests/should_work/static/ts01.lus b/tests/should_work/static/ts01.lus new file mode 100644 index 0000000000000000000000000000000000000000..c1c07f8c04f0b34572c98a243b214fb666495af6 --- /dev/null +++ b/tests/should_work/static/ts01.lus @@ -0,0 +1,9 @@ + +-- ok + +node ma_macro<<const i : int>>(x: int) returns (y: int); +let + y = i + x; +tel + +node main = ma_macro<<32>>; diff --git a/tests/should_work/static/ts02.lus b/tests/should_work/static/ts02.lus new file mode 100644 index 0000000000000000000000000000000000000000..d13971cc86c9f0f0ae6874973c7eb4626a9f54b0 --- /dev/null +++ b/tests/should_work/static/ts02.lus @@ -0,0 +1,10 @@ + +-- KO, mais pas où il faudrait ... + +node ma_macro<<const i : int>>(x: int) returns (y: int); +let + y = i + x; +tel + +-- n.b. ko à l'utilisation uniquement +node main = ma_macro<<32.0>>; diff --git a/tests/should_work/static/ts03.lus b/tests/should_work/static/ts03.lus new file mode 100644 index 0000000000000000000000000000000000000000..f5ab1442cc6ef52826f801ef8276102f2bf2c735 --- /dev/null +++ b/tests/should_work/static/ts03.lus @@ -0,0 +1,11 @@ + +-- KO + +node ma_macro<<const i : int>>(x: int) returns (y: int); +let + y = i + x; +tel + +--*** Bad static argument nature, a constant was expected + +node main = ma_macro<<+>>;