Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
7574c1a8
Commit
7574c1a8
authored
Jun 19, 2017
by
Andres Toom
Committed by
Daniel Tuulik
Apr 18, 2018
Browse files
Start creating a simple test for parsing models with QGen
parent
ce633510
Changes
6
Hide whitespace changes
Inline
Side-by-side
tests/regression/Makefile
View file @
7574c1a8
...
...
@@ -8,6 +8,9 @@ BENCHMARK_CASES=$(filter-out $(DISABLED_BENCHMARKS), $(sort $(dir $(wildcard */)
test-parse
:
@
python3 test.py test-parse
$(TEST_CASES)
test-qgen-parse
:
@
python3 test.py test-qgen-parse
$(TEST_CASES)
-s
$(size)
test-ada
:
@
python3 test.py test-ada
$(TEST_CASES)
...
...
@@ -43,5 +46,5 @@ clean:
do
$(MAKE)
-s
-C
$$
v clean
;
\
done
.PHONY
:
test-parse test-ada test-llvm benchmark benchmark-O1 benchmark-O2
\
.PHONY
:
test-parse
test-qgen-parse
test-ada test-llvm benchmark benchmark-O1 benchmark-O2
\
benchmark-O3 coverage clean
tests/regression/shared.mk
View file @
7574c1a8
...
...
@@ -6,6 +6,7 @@ GNATMAKE=gnatmake -gnat2012
GNATBIND
=
gnatbind
GNATLINK
=
gnatlink
-lgcov
-coverage
O
=
0
TESTQGEN
=
../testqgen.py
clean
:
rm
-rf
*
.adb
*
.ads
*
.pyc runSpark.sh spark.idx
*
.o
*
.so
*
.ali gnat.cfg
\
...
...
tests/regression/test.py
View file @
7574c1a8
#!/usr/bin/env python3
import
subprocess
import
sys
import
argparse
import
time
import
signal
import
os
from
functools
import
partial
from
multiprocessing
import
cpu_count
from
concurrent
import
futures
work1
=
[
'make'
,
'-C'
]
work2
=
[
'make'
,
'-C'
]
work3
=
[
'python'
,
'testqgen.py'
]
testsWork
=
{
'all'
:
work1
,
'test-parse'
:
work1
,
'test-qgen-parse'
:
work2
,
'test-ada'
:
work1
,
'test-c'
:
work1
,
'test-llvm'
:
work1
,
'test-vhdl'
:
work1
}
def
colorMe
(
result
,
msg
):
if
sys
.
stdout
.
isatty
():
...
...
@@ -15,34 +28,52 @@ def colorMe(result, msg):
msg
=
chr
(
27
)
+
"[3"
+
code
+
"m"
+
msg
+
chr
(
27
)
+
"[0m"
return
msg
def
parse_args
():
''' Parse command line arguments '''
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-s'
,
'--size'
,
type
=
int
,
default
=
0
)
parser
.
add_argument
(
'rule'
,
metavar
=
'Rule'
,
type
=
str
)
parser
.
add_argument
(
'paths'
,
metavar
=
'Path'
,
type
=
str
,
nargs
=
'+'
)
return
parser
.
parse_args
()
def
main
():
''' Run the test cases in parallel on all available CPUs '''
start
=
time
.
time
()
results
=
[]
rule
=
sys
.
argv
[
1
]
paths
=
sys
.
argv
[
2
:]
op
=
parse_args
()
with
futures
.
ProcessPoolExecutor
(
max_workers
=
cpu_count
())
as
executor
:
for
result
in
executor
.
map
(
partial
(
make
,
rule
),
paths
):
for
result
in
executor
.
map
(
partial
(
partial
(
make
,
op
.
rule
),
op
.
size
),
op
.
paths
):
print
(
"%40s: %s"
%
(
result
[
3
],
colorMe
(
result
[
0
],
'[OK]'
if
result
[
0
]
==
0
else
'[FAILED]'
)))
results
.
append
(
result
)
executor
.
map
(
partial
(
make
,
'clean'
),
paths
)
executor
.
map
(
partial
(
make
,
'clean'
),
op
.
paths
)
sys
.
stdout
.
write
(
'
\n
'
)
elapsed
=
time
.
time
()
-
start
return
summarize
(
results
,
elapsed
)
def
make
(
rule
,
path
):
def
make
(
rule
,
size
,
path
):
''' Call a Makefile with the required rule (e.g. test-ada or clean) '''
''' Choose work settings based on the given rule '''
work
=
testsWork
[
rule
]
''' Compose the command based on the rule'''
if
rule
==
'test-qgen-parse'
:
cmd
=
[
work
[
0
],
work
[
1
],
path
,
rule
,
'size='
+
str
(
size
)]
else
:
cmd
=
[
work
[
0
],
work
[
1
],
path
,
rule
]
proc
=
subprocess
.
Popen
(
[
'make'
,
'-C'
,
path
,
rule
]
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
proc
.
communicate
()
errcode
=
proc
.
wait
()
return
(
errcode
,
stdout
,
stderr
,
path
,
rule
)
...
...
tests/regression/test1/Makefile
View file @
7574c1a8
include
../shared.mk
all
:
test-ada test-llvm
edit
:
$(OPENGEODE)
og.pr system_structure.pr
test-parse
:
$(OPENGEODE)
og.pr system_structure.pr
--check
test-qgen-parse
:
$(TESTQGEN)
og.pr system_structure.pr
$(size)
test-ada
:
og.ali dataview-uniq.o | test_ada.o
$(GNATBIND)
-n
og.ali
$(GNATLINK)
-o
test_ada test_ada.o dataview-uniq.o og.ali
-lgnat
...
...
@@ -28,4 +29,4 @@ test-llvm: og.o dataview-uniq.o | test_llvm.o
coverage
:
coverage run
-p
$(OPENGEODE)
og.pr system_structure.pr
--toAda
.PHONY
:
all
edit test-parse test-ada test-llvm coverage
.PHONY
:
edit test-parse
test-qgen-parse
test-ada test-llvm coverage
tests/regression/test2/Makefile
View file @
7574c1a8
include
../shared.mk
all
:
test-ada test-llvm
edit
:
$(OPENGEODE)
orchestrator.pr system_structure.pr
test-parse
:
$(OPENGEODE)
orchestrator.pr system_structure.pr
--check
test-qgen-parse
:
$(TESTQGEN)
orchestrator.pr system_structure.pr
$(size)
test-ada
:
orchestrator.ali dataview-uniq.o | test_ada.o
$(GNATBIND)
-n
orchestrator.ali
$(GNATLINK)
-o
test_ada test_ada.o orchestrator.ali
-lgnat
...
...
@@ -25,4 +26,4 @@ test-llvm: orchestrator.o
coverage
:
coverage run
-p
$(OPENGEODE)
orchestrator.pr system_structure.pr
--toAda
.PHONY
:
all
edit test-parse test-ada test-llvm coverage
.PHONY
:
edit test-parse
test-qgen-parse
test-ada test-llvm coverage
tests/regression/testqgen.py
0 → 100755
View file @
7574c1a8
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Run some tests using QGen components
"""
import
os
import
sys
import
logging
import
argparse
__version__
=
'1.0.0'
LOG
=
logging
.
getLogger
(
__name__
)
def
parse_args
():
''' Parse command line arguments '''
parser
=
argparse
.
ArgumentParser
(
version
=
__version__
)
parser
.
add_argument
(
'files'
,
metavar
=
'file.pr'
,
type
=
str
,
nargs
=
'*'
,
help
=
'SDL file(s)'
)
parser
.
add_argument
(
'size'
,
type
=
int
)
return
parser
.
parse_args
()
def
init_logging
(
options
):
''' Initialize logging '''
terminal_formatter
=
logging
.
Formatter
(
fmt
=
"[%(levelname)s] %(message)s"
)
handler_console
=
logging
.
StreamHandler
()
handler_console
.
setFormatter
(
terminal_formatter
)
LOG
.
addHandler
(
handler_console
)
def
getSizeFiles
(
list
,
size
):
err
=
0
files
=
[
os
.
path
.
abspath
(
file
)
for
file
in
list
]
for
file
in
files
:
s
=
os
.
path
.
getsize
(
file
)
if
s
>
size
:
err
=
1
LOG
.
error
(
file
+
" too large - size "
+
str
(
s
))
else
:
LOG
.
warning
(
file
+
" size "
+
str
(
s
))
return
err
def
main
():
options
=
parse_args
()
init_logging
(
options
)
size
=
options
.
size
if
size
==
0
:
size
=
9000
return
getSizeFiles
(
options
.
files
,
size
)
if
__name__
==
'__main__'
:
ret
=
main
()
sys
.
exit
(
ret
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment