Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ufebl
mjtest
Commits
e843d83b
Commit
e843d83b
authored
Nov 30, 2016
by
Johannes Bechberger
Browse files
Improve infinite loop test case runner
parent
0706a7a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
mjtest/test/exec_tests.py
View file @
e843d83b
...
@@ -129,6 +129,7 @@ class JavaExecTest(BasicSyntaxTest):
...
@@ -129,6 +129,7 @@ class JavaExecTest(BasicSyntaxTest):
test_result
.
add_long_text
(
"Output"
,
out
.
decode
())
test_result
.
add_long_text
(
"Output"
,
out
.
decode
())
if
exp_out
.
strip
()
!=
out
.
strip
():
if
exp_out
.
strip
()
!=
out
.
strip
():
test_result
.
incorrect_msg
=
"incorrect output"
test_result
.
incorrect_msg
=
"incorrect output"
test_result
.
has_succeeded
=
False
test_result
.
add_diff
(
"Output diff [expected <-> actual]"
,
exp_out
,
out
)
test_result
.
add_diff
(
"Output diff [expected <-> actual]"
,
exp_out
,
out
)
test_result
.
add_file
(
"Source file"
,
self
.
preprocessed_file
)
test_result
.
add_file
(
"Source file"
,
self
.
preprocessed_file
)
os
.
chdir
(
cwd
)
os
.
chdir
(
cwd
)
...
@@ -172,31 +173,64 @@ class JavaInfiniteLoopTest(BasicSyntaxTest):
...
@@ -172,31 +173,64 @@ class JavaInfiniteLoopTest(BasicSyntaxTest):
cwd
=
os
.
getcwd
()
cwd
=
os
.
getcwd
()
os
.
chdir
(
tmp_dir
)
os
.
chdir
(
tmp_dir
)
timeout
=
1
timeout
=
1
err
=
""
err
=
None
out
=
""
out
=
None
out2
=
""
rtcode
=
None
test_result
=
ExtensibleTestResult
(
self
)
try
:
try
:
out2
,
err
,
rtcode
=
self
.
env
.
run_mj_command
(
self
.
MODE
,
base_filename
+
".java"
)
out
,
err
,
rtcode
=
self
.
env
.
run_mj_command
(
self
.
MODE
,
base_filename
+
".java"
)
out
,
_
,
_
=
self
.
env
.
run_command
(
"./"
+
base_filename
,
timeout
=
timeout
)
if
rtcode
!=
0
:
except
SigKill
as
kill
:
test_result
.
incorrect_msg
=
"file can't be compiled"
os
.
chdir
(
cwd
)
test_result
.
error_code
=
rtcode
if
kill
.
retcode
==
signal
.
SIGXCPU
:
test_result
.
add_long_text
(
"Error output"
,
err
.
decode
())
test_result
.
add_long_text
(
"Output"
,
out
.
decode
())
test_result
.
add_file
(
"Source file"
,
self
.
preprocessed_file
)
os
.
chdir
(
cwd
)
return
test_result
out
,
err
,
rtcode
=
self
.
env
.
run_command
(
"./"
+
base_filename
,
timeout
=
timeout
)
if
rtcode
!=
0
:
test_result
.
incorrect_msg
=
"file can't be run"
test_result
.
error_code
=
rtcode
test_result
.
add_long_text
(
"Error output"
,
err
.
decode
())
test_result
.
add_long_text
(
"Output"
,
out
.
decode
())
test_result
.
add_file
(
"Source file"
,
self
.
preprocessed_file
)
os
.
chdir
(
cwd
)
return
test_result
except
SigKill
as
sig
:
if
sig
.
retcode
==
signal
.
SIGXCPU
:
test_result
.
add_long_text
(
"Output"
,
out
.
decode
())
if
self
.
_has_output_file
:
if
self
.
_has_output_file
:
out
=
out
.
decode
().
strip
()
out
=
out
.
decode
().
strip
()
exp_out
=
""
exp_out
=
""
with
open
(
self
.
_output_file
,
"r"
)
as
f
:
with
open
(
self
.
_output_file
,
"r"
)
as
f
:
exp_out
=
f
.
read
().
strip
()
exp_out
=
f
.
read
().
strip
()
test_result
.
add_long_text
(
"Expected output start"
,
exp_out
)
if
not
out
.
startswith
(
exp_out
):
if
not
out
.
startswith
(
exp_out
):
return
BasicDiffTestResult
(
self
,
1
,
out
,
err
.
decode
(),
exp_out
,
test_result
.
incorrect_msg
=
"incorrect output start"
"Output doesn't start like expected"
)
test_result
.
has_succeeded
=
False
return
BasicTestResult
(
self
,
0
,
err
.
decode
(),
out
.
decode
())
test_result
.
add_file
(
"Source file"
,
self
.
preprocessed_file
)
os
.
chdir
(
cwd
)
return
test_result
else
:
test_result
.
add_file
(
"Source file"
,
self
.
preprocessed_file
)
os
.
chdir
(
cwd
)
return
test_result
else
:
else
:
return
BasicTestResult
(
self
,
kill
.
retcode
,
""
,
err
.
decode
(),
"No timeout, got "
+
kill
.
name
)
test_result
.
incorrect_msg
=
"binary can't be run: "
+
sig
.
name
test_result
.
error_code
=
sig
.
retcode
test_result
.
add_file
(
"Source file"
,
self
.
preprocessed_file
)
os
.
chdir
(
cwd
)
return
test_result
except
:
except
:
os
.
chdir
(
cwd
)
os
.
chdir
(
cwd
)
raise
raise
os
.
chdir
(
cwd
)
os
.
chdir
(
cwd
)
return
BasicTestResult
(
self
,
1
,
""
,
err
.
decode
(),
"No timeout"
)
test_result
.
incorrect_msg
=
"run shorter than one second"
test_result
.
add_long_text
(
"Output"
,
out
)
test_result
.
has_succeeded
=
False
test_result
.
add_file
(
"Source file"
,
self
.
preprocessed_file
)
os
.
chdir
(
cwd
)
return
test_result
TestCase
.
TEST_CASE_CLASSES
[
TestMode
.
compile_firm
].
append
(
JavaInfiniteLoopTest
)
TestCase
.
TEST_CASE_CLASSES
[
TestMode
.
compile_firm
].
append
(
JavaInfiniteLoopTest
)
\ No newline at end of file
mjtest/test/tests.py
View file @
e843d83b
...
@@ -354,6 +354,7 @@ class ExtensibleTestResult(TestResult):
...
@@ -354,6 +354,7 @@ class ExtensibleTestResult(TestResult):
texts
.
append
(
msg
.
content
)
texts
.
append
(
msg
.
content
)
else
:
else
:
texts
.
append
(
"{}: {}"
.
format
(
msg
.
title
,
msg
.
content
))
texts
.
append
(
"{}: {}"
.
format
(
msg
.
title
,
msg
.
content
))
return
"
\n
"
.
join
(
texts
)
def
_ident
(
self
,
text
:
Union
[
str
,
List
[
str
]])
->
str
:
def
_ident
(
self
,
text
:
Union
[
str
,
List
[
str
]])
->
str
:
arr
=
text
if
isinstance
(
text
,
list
)
else
text
.
split
(
"
\n
"
)
arr
=
text
if
isinstance
(
text
,
list
)
else
text
.
split
(
"
\n
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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