Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
2caac21b
Commit
2caac21b
authored
Mar 27, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: limit auto check execution time
parent
c5d977ba
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
18 deletions
+45
-18
IntegrationTest.java
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
+45
-18
No files found.
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
View file @
2caac21b
...
@@ -12,6 +12,13 @@ import java.util.ArrayList;
...
@@ -12,6 +12,13 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeoutException
;
import
java.util.jar.JarOutputStream
;
import
java.util.jar.JarOutputStream
;
import
jadx.api.JadxArgs
;
import
jadx.api.JadxArgs
;
...
@@ -229,16 +236,16 @@ public abstract class IntegrationTest extends TestUtils {
...
@@ -229,16 +236,16 @@ public abstract class IntegrationTest extends TestUtils {
return
;
return
;
}
}
try
{
try
{
checkMth
.
invoke
(
origCls
.
getConstructor
().
newInstance
(
));
limitExecTime
(()
->
checkMth
.
invoke
(
origCls
.
getConstructor
().
newInstance
()
));
}
catch
(
InvocationTargetException
i
e
)
{
}
catch
(
Exception
e
)
{
rethrow
(
"Original check failed"
,
i
e
);
rethrow
(
"Original check failed"
,
e
);
}
}
// run 'check' method from decompiled class
// run 'check' method from decompiled class
if
(
compile
)
{
if
(
compile
)
{
try
{
try
{
invoke
(
"check"
);
limitExecTime
(()
->
invoke
(
"check"
)
);
}
catch
(
InvocationTargetException
i
e
)
{
}
catch
(
Exception
e
)
{
rethrow
(
"Decompiled check failed"
,
i
e
);
rethrow
(
"Decompiled check failed"
,
e
);
}
}
System
.
out
.
println
(
"Auto check: PASSED"
);
System
.
out
.
println
(
"Auto check: PASSED"
);
}
}
...
@@ -248,14 +255,34 @@ public abstract class IntegrationTest extends TestUtils {
...
@@ -248,14 +255,34 @@ public abstract class IntegrationTest extends TestUtils {
}
}
}
}
private
void
rethrow
(
String
msg
,
InvocationTargetException
ie
)
{
private
<
T
>
T
limitExecTime
(
Callable
<
T
>
call
)
{
Throwable
cause
=
ie
.
getCause
();
ExecutorService
executor
=
Executors
.
newSingleThreadExecutor
();
Future
<
T
>
future
=
executor
.
submit
(
call
);
try
{
return
future
.
get
(
5
,
TimeUnit
.
SECONDS
);
}
catch
(
TimeoutException
ex
)
{
future
.
cancel
(
true
);
rethrow
(
"Execution timeout"
,
ex
);
}
catch
(
Exception
ex
)
{
rethrow
(
ex
.
getMessage
(),
ex
);
}
finally
{
executor
.
shutdownNow
();
}
return
null
;
}
private
void
rethrow
(
String
msg
,
Throwable
e
)
{
if
(
e
instanceof
InvocationTargetException
)
{
Throwable
cause
=
e
.
getCause
();
if
(
cause
instanceof
AssertionError
)
{
if
(
cause
instanceof
AssertionError
)
{
System
.
err
.
println
(
msg
);
throw
(
AssertionError
)
cause
;
throw
(
AssertionError
)
cause
;
}
else
{
}
else
{
cause
.
printStackTrace
();
fail
(
cause
);
fail
(
msg
+
cause
.
getMessage
());
}
}
else
if
(
e
instanceof
ExecutionException
)
{
rethrow
(
e
.
getMessage
(),
e
.
getCause
());
}
else
{
fail
(
msg
,
e
);
}
}
}
}
...
@@ -279,8 +306,7 @@ public abstract class IntegrationTest extends TestUtils {
...
@@ -279,8 +306,7 @@ public abstract class IntegrationTest extends TestUtils {
assertTrue
(
result
,
"Compilation failed"
);
assertTrue
(
result
,
"Compilation failed"
);
System
.
out
.
println
(
"Compilation: PASSED"
);
System
.
out
.
println
(
"Compilation: PASSED"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
fail
(
e
);
fail
(
e
.
getMessage
());
}
}
}
}
...
@@ -437,13 +463,14 @@ public abstract class IntegrationTest extends TestUtils {
...
@@ -437,13 +463,14 @@ public abstract class IntegrationTest extends TestUtils {
// Use only for debug purpose
// Use only for debug purpose
@Deprecated
@Deprecated
protected
void
setO
utputCFG
()
{
protected
void
o
utputCFG
()
{
this
.
args
.
setCfgOutput
(
true
);
this
.
args
.
setCfgOutput
(
true
);
this
.
args
.
setRawCFGOutput
(
true
);
this
.
args
.
setRawCFGOutput
(
true
);
}
// Use only for debug purpose
}
// Use only for debug purpose
@Deprecated
@Deprecated
protected
void
setO
utputRawCFG
()
{
protected
void
o
utputRawCFG
()
{
this
.
args
.
setRawCFGOutput
(
true
);
this
.
args
.
setRawCFGOutput
(
true
);
}
}
...
...
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