Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
SquirrelJME
Commits
eb231029
Commit
eb231029
authored
Jul 18, 2021
by
Stephanie Gawroriski
Browse files
Add mechanism to skip from timeout tests.
parent
682fcdef
Pipeline
#39197
passed with stages
in 1 minute and 53 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
buildSrc/src/main/java/cc/squirreljme/plugin/multivm/VMTestResult.java
View file @
eb231029
...
...
@@ -17,17 +17,31 @@ package cc.squirreljme.plugin.multivm;
public
enum
VMTestResult
{
/** Pass. */
PASS
,
PASS
(
0
)
,
/** Fail. */
FAIL
,
FAIL
(
1
)
,
/** Skip. */
SKIP
,
SKIP
(
2
)
,
/* End. */
;
/** The mapped exit code. */
public
final
int
exitCode
;
/**
* Initializes the result with the exit code.
*
* @param __exitCode The exit code.
* @since 2021/07/18
*/
VMTestResult
(
int
__exitCode
)
{
this
.
exitCode
=
__exitCode
;
}
/**
* Decodes the exit value and returns the test result.
*
...
...
@@ -37,9 +51,9 @@ public enum VMTestResult
*/
public
static
VMTestResult
valueOf
(
int
__exitValue
)
{
if
(
__exitValue
==
0
)
if
(
__exitValue
==
VMTestResult
.
PASS
.
exitCode
)
return
VMTestResult
.
PASS
;
else
if
(
__exitValue
==
2
)
else
if
(
__exitValue
==
VMTestResult
.
SKIP
.
exitCode
)
return
VMTestResult
.
SKIP
;
return
VMTestResult
.
FAIL
;
}
...
...
buildSrc/src/main/java/cc/squirreljme/plugin/multivm/VMTestWorkAction.java
View file @
eb231029
...
...
@@ -33,6 +33,10 @@ public abstract class VMTestWorkAction
private
static
final
long
_TEST_TIMEOUT
=
360_000_000_000L
;
/** Skip sequence special. */
private
static
final
byte
[]
_SKIP_SPECIAL
=
new
byte
[]{
'%'
,
'!'
,
'S'
,
'k'
,
'O'
,
'n'
,
'T'
,
'i'
,
'!'
,
'%'
};
/**
* {@inheritDoc}
* @since 2020/09/07
...
...
@@ -92,23 +96,28 @@ public abstract class VMTestWorkAction
// Wait for the process to terminate, the exit code will contain
// the result of the test (pass, skip, fail)
int
exitCode
=
-
1
;
boolean
timeOutHit
=
false
;
for
(;;)
try
{
// Has the test run expired? Only when not debugging
if
(!
isDebugging
)
{
long
nsDur
=
System
.
nanoTime
()
-
nsStart
;
if
(
nsDur
>=
VMTestWorkAction
.
_TEST_TIMEOUT
)
{
// Note it
System
.
err
.
printf
(
"TIME %s (%d/%d)%n"
,
testName
,
count
,
total
);
System
.
err
.
flush
();
// The logic for interrupts is the same
throw
new
InterruptedException
(
"Test Timeout"
);
}
long
nsDur
=
System
.
nanoTime
()
-
nsStart
;
if
(
nsDur
>=
VMTestWorkAction
.
_TEST_TIMEOUT
)
{
// Note it
System
.
err
.
printf
(
"TIME %s (%d/%d)%n"
,
testName
,
count
,
total
);
System
.
err
.
flush
();
// Set timeout as being hit, used for special
// check
timeOutHit
=
true
;
// The logic for interrupts is the same
throw
new
InterruptedException
(
"Test Timeout"
);
}
}
// Wait for completion
...
...
@@ -136,6 +145,10 @@ public abstract class VMTestWorkAction
// Clock the ending time
long
nsDur
=
System
.
nanoTime
()
-
nsStart
;
byte
[]
stdErrBytes
=
stdErr
.
getBytes
(
stdErrThread
);
if
(
timeOutHit
&&
VMTestWorkAction
.
__findTimeoutSkip
(
stdErrBytes
))
exitCode
=
VMTestResult
.
SKIP
.
exitCode
;
// Note this has finished
VMTestResult
testResult
=
VMTestResult
.
valueOf
(
exitCode
);
System
.
err
.
printf
(
"%4s %s (%d/%d)%n"
,
testResult
,
testName
,
...
...
@@ -154,7 +167,7 @@ public abstract class VMTestWorkAction
VMTestWorkAction
.
__writeXml
(
out
,
testName
,
testResult
,
parameters
.
getVmName
().
get
(),
clockStart
,
nsDur
,
stdOut
.
getBytes
(
stdOutThread
),
stdErr
.
get
Bytes
(
stdErrThread
)
);
stdErrBytes
);
// Make sure everything is written
out
.
flush
();
...
...
@@ -185,6 +198,47 @@ public abstract class VMTestWorkAction
}
}
/**
* Finds the special timeout sequence if this has had a timeout, this is
* used to detect if a test should just skip rather than causing a fail.
*
* @param __stdErrBytes The standard error bytes.
* @return If the sequence was found.
* @throws NullPointerException On null arguments.
* @since 2021/07/18
*/
private
static
boolean
__findTimeoutSkip
(
byte
[]
__stdErrBytes
)
throws
NullPointerException
{
if
(
__stdErrBytes
==
null
)
throw
new
NullPointerException
(
"NARG"
);
// Skip special sequence
byte
[]
skipSpecial
=
VMTestWorkAction
.
_SKIP_SPECIAL
;
byte
firstByte
=
skipSpecial
[
0
];
int
skipLen
=
skipSpecial
.
length
;
// Find the sequence
for
(
int
i
=
0
,
n
=
Math
.
max
(
0
,
__stdErrBytes
.
length
-
skipLen
);
i
<
n
;
i
++)
{
// If the first byte is a match, then
byte
quick
=
__stdErrBytes
[
i
];
if
(
quick
!=
firstByte
)
continue
;
// Check if the entire sequence matched
for
(
int
j
=
0
,
q
=
i
;
j
<=
skipLen
;
j
++,
q
++)
if
(
j
==
skipLen
)
return
true
;
else
if
(
__stdErrBytes
[
q
]
!=
skipSpecial
[
j
])
break
;
}
// Not found
return
false
;
}
/**
* Writes the XML test result to the given output.
*
...
...
modules/midp-lcdui/src/test/java/lcdui/canvas/TestCanvasFullScreen.java
View file @
eb231029
...
...
@@ -9,11 +9,9 @@
package
lcdui.canvas
;
import
cc.squirreljme.runtime.cldc.debug.Debugging
;
import
javax.microedition.lcdui.Canvas
;
import
javax.microedition.lcdui.Command
;
import
javax.microedition.lcdui.Display
;
import
net.multiphasicapps.tac.UntestableException
;
/**
* Tests that a canvas is full-screen via
...
...
@@ -30,16 +28,6 @@ public class TestCanvasFullScreen
*/
@Override
public
void
test
(
Display
__display
,
CanvasPlatform
__platform
)
{
// This test can fail multiple times due to tight timings
for
(
int
i
=
0
;
i
<
3
;
i
++)
if
(
this
.
runSequence
(
__display
,
__platform
))
return
;
throw
new
UntestableException
(
"Ignoring full-screen test."
);
}
public
boolean
runSequence
(
Display
__display
,
CanvasPlatform
__platform
)
{
// Add a button, it should go away
__platform
.
addCommand
(
...
...
@@ -60,31 +48,16 @@ public class TestCanvasFullScreen
__platform
.
repaint
();
__platform
.
serviceRepaints
();
// Wait a bit to allow this to stay on
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
ignored
)
{
}
// Query the sizes again for checking
int
newWidth
=
__platform
.
getWidth
();
int
newHeight
=
__platform
.
getHeight
();
// Full-screen should cause the canvas to grow in size
boolean
didWidth
=
newWidth
>=
width
;
boolean
didHeight
=
newHeight
>=
height
;
this
.
secondary
(
"width"
,
didWidth
);
this
.
secondary
(
"height"
,
didHeight
);
this
.
secondary
(
"width"
,
newWidth
>=
width
);
this
.
secondary
(
"height"
,
newHeight
>=
height
);
// The canvas should be smaller or at the maximum display resolution
boolean
widthSmaller
=
newWidth
<=
__display
.
getWidth
();
boolean
heightSmaller
=
newHeight
<=
__display
.
getHeight
();
this
.
secondary
(
"wdisp"
,
widthSmaller
);
this
.
secondary
(
"hdisp"
,
heightSmaller
);
return
didWidth
&&
didHeight
&&
widthSmaller
&&
heightSmaller
;
this
.
secondary
(
"wdisp"
,
newWidth
<=
__display
.
getWidth
());
this
.
secondary
(
"hdisp"
,
newHeight
<=
__display
.
getHeight
());
}
}
modules/midp-lcdui/src/test/resources/lcdui/canvas/TestCanvasFullScreen.in
View file @
eb231029
result: NoResult
thrown: NoExceptionThrown
skip-on-timeout: true
secondary-width: true
secondary-height: true
secondary-wdisp: true
...
...
modules/tac/src/main/java/net/multiphasicapps/tac/__CoreTest__.java
View file @
eb231029
...
...
@@ -137,6 +137,16 @@ abstract class __CoreTest__
Object
thrown
;
try
{
// If skipping on timeout, add a sequence in to try to detect
// this. Print multiple times in the event of splicing.
String
skipOnTimeout
=
otherKeys
.
get
(
"skip-on-timeout"
);
if
(
Boolean
.
parseBoolean
(
skipOnTimeout
))
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
System
.
err
.
println
(
"%!SkOnTi!%"
);
System
.
err
.
flush
();
}
// Determine the system that the test needs to be on, if one was
// ever specified in the results
int
vmType
=
-
1
;
...
...
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