Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
eddd1249
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
eddd1249
编写于
12月 05, 2014
作者:
K
kshefov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8059070: [TESTBUG] java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java failed - timeout
Reviewed-by: psandoz, vlivanov, dfuchs
上级
1b798d7b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
150 addition
and
29 deletion
+150
-29
test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
+2
-2
test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java
.../java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java
+1
-1
test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
...java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
+1
-1
test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
+43
-25
test/lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java
test/lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java
+86
-0
test/lib/testlibrary/jdk/testlibrary/Utils.java
test/lib/testlibrary/jdk/testlibrary/Utils.java
+17
-0
未找到文件。
test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
浏览文件 @
eddd1249
...
...
@@ -26,12 +26,12 @@
* @bug 8046703
* @summary Test verifies that lambda forms are garbage collected
* @author kshefov
* @ignore 8057020
* @library /lib/testlibrary/jsr292 /lib/testlibrary
* @ignore 8057020
* @build TestMethods
* @build LambdaFormTestCase
* @build LFGarbageCollectedTest
* @run main/othervm
/timeout=600 -DtestLimit=150
LFGarbageCollectedTest
* @run main/othervm LFGarbageCollectedTest
*/
import
java.lang.invoke.MethodHandle
;
...
...
test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java
浏览文件 @
eddd1249
...
...
@@ -31,7 +31,7 @@
* @build LambdaFormTestCase
* @build LFCachingTestCase
* @build LFMultiThreadCachingTest
* @run main/othervm
/timeout=300
LFMultiThreadCachingTest
* @run main/othervm LFMultiThreadCachingTest
*/
import
java.lang.invoke.MethodHandle
;
...
...
test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
浏览文件 @
eddd1249
...
...
@@ -31,7 +31,7 @@
* @build LambdaFormTestCase
* @build LFCachingTestCase
* @build LFSingleThreadCachingTest
* @run main/othervm
/timeout=300
LFSingleThreadCachingTest
* @run main/othervm LFSingleThreadCachingTest
*/
import
java.lang.invoke.MethodHandle
;
...
...
test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
浏览文件 @
eddd1249
...
...
@@ -27,6 +27,8 @@ import java.lang.management.ManagementFactory;
import
java.lang.reflect.Method
;
import
java.util.Collection
;
import
java.util.function.Function
;
import
jdk.testlibrary.Utils
;
import
jdk.testlibrary.TimeLimitedRunner
;
/**
* Lambda forms caching test case class. Contains all necessary test routines to
...
...
@@ -41,6 +43,7 @@ public abstract class LambdaFormTestCase {
private
final
static
String
INTERNAL_FORM_METHOD_NAME
=
"internalForm"
;
private
static
final
double
ITERATIONS_TO_CODE_CACHE_SIZE_RATIO
=
45
/
(
128.0
*
1024
*
1024
);
private
static
final
long
TIMEOUT
=
Helper
.
IS_THOROUGH
?
0L
:
(
long
)
(
Utils
.
adjustTimeout
(
Utils
.
DEFAULT_TEST_TIMEOUT
)
*
0.9
);
/**
* Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is
...
...
@@ -59,6 +62,11 @@ public abstract class LambdaFormTestCase {
}
private
final
TestMethods
testMethod
;
private
static
long
totalIterations
=
0L
;
private
static
long
doneIterations
=
0L
;
private
static
boolean
passed
=
true
;
private
static
int
testCounter
=
0
;
private
static
int
failCounter
=
0
;
/**
* Test case constructor. Generates test cases with random method types for
...
...
@@ -88,13 +96,10 @@ public abstract class LambdaFormTestCase {
* @param testMethods list of test methods
*/
public
static
void
runTests
(
Function
<
TestMethods
,
LambdaFormTestCase
>
ctor
,
Collection
<
TestMethods
>
testMethods
)
{
boolean
passed
=
true
;
int
testCounter
=
0
;
int
failCounter
=
0
;
long
testCaseNum
=
testMethods
.
size
();
long
i
terations
=
Math
.
max
(
1
,
Helper
.
TEST_LIMIT
/
testCaseNum
);
totalI
terations
=
Math
.
max
(
1
,
Helper
.
TEST_LIMIT
/
testCaseNum
);
System
.
out
.
printf
(
"Number of iterations according to -DtestLimit is %d (%d cases)%n"
,
iterations
,
i
terations
*
testCaseNum
);
totalIterations
,
totalI
terations
*
testCaseNum
);
HotSpotDiagnosticMXBean
hsDiagBean
=
ManagementFactory
.
getPlatformMXBean
(
HotSpotDiagnosticMXBean
.
class
);
long
codeCacheSize
=
Long
.
parseLong
(
hsDiagBean
.
getVMOption
(
"ReservedCodeCacheSize"
).
getValue
());
...
...
@@ -103,29 +108,42 @@ public abstract class LambdaFormTestCase {
*
ITERATIONS_TO_CODE_CACHE_SIZE_RATIO
);
System
.
out
.
printf
(
"Number of iterations limited by code cache size is %d (%d cases)%n"
,
iterationsByCodeCacheSize
,
iterationsByCodeCacheSize
*
testCaseNum
);
if
(
i
terations
>
iterationsByCodeCacheSize
)
{
i
terations
=
iterationsByCodeCacheSize
;
if
(
totalI
terations
>
iterationsByCodeCacheSize
)
{
totalI
terations
=
iterationsByCodeCacheSize
;
}
System
.
out
.
printf
(
"Number of iterations is set to %d (%d cases)%n"
,
iterations
,
i
terations
*
testCaseNum
);
totalIterations
,
totalI
terations
*
testCaseNum
);
System
.
out
.
flush
();
for
(
long
i
=
0
;
i
<
iterations
;
i
++)
{
System
.
err
.
println
(
String
.
format
(
"Iteration %d:"
,
i
));
for
(
TestMethods
testMethod
:
testMethods
)
{
LambdaFormTestCase
testCase
=
ctor
.
apply
(
testMethod
);
try
{
System
.
err
.
printf
(
"Tested LF caching feature with MethodHandles.%s method.%n"
,
testCase
.
getTestMethod
().
name
);
testCase
.
doTest
();
System
.
err
.
println
(
"PASSED"
);
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
System
.
err
.
println
(
"FAILED"
);
passed
=
false
;
failCounter
++;
}
testCounter
++;
}
TimeLimitedRunner
runner
=
new
TimeLimitedRunner
(
TIMEOUT
,
4.0d
,
()
->
{
if
(
doneIterations
>=
totalIterations
)
{
return
false
;
}
System
.
err
.
println
(
String
.
format
(
"Iteration %d:"
,
doneIterations
));
for
(
TestMethods
testMethod
:
testMethods
)
{
LambdaFormTestCase
testCase
=
ctor
.
apply
(
testMethod
);
try
{
System
.
err
.
printf
(
"Tested LF caching feature with MethodHandles.%s method.%n"
,
testCase
.
getTestMethod
().
name
);
testCase
.
doTest
();
System
.
err
.
println
(
"PASSED"
);
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
System
.
err
.
println
(
"FAILED"
);
passed
=
false
;
failCounter
++;
}
testCounter
++;
}
doneIterations
++;
return
true
;
});
try
{
runner
.
call
();
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
System
.
err
.
println
(
"FAILED"
);
throw
new
Error
(
"Unexpected error!"
);
}
if
(!
passed
)
{
throw
new
Error
(
String
.
format
(
"%d of %d test cases FAILED! %n"
...
...
test/lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java
0 → 100644
浏览文件 @
eddd1249
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
jdk.testlibrary
;
import
java.util.Objects
;
import
java.util.concurrent.Callable
;
/**
* Auxiliary class to run target w/ given timeout.
*/
public
class
TimeLimitedRunner
implements
Callable
<
Void
>
{
private
final
long
stoptime
;
private
final
long
timeout
;
private
final
double
factor
;
private
final
Callable
<
Boolean
>
target
;
/**
* @param timeout a timeout. zero means no time limitation
* @param factor a multiplier used to estimate next iteration time
* @param target a target to run
* @throws NullPointerException if target is null
* @throws IllegalArgumentException if timeout is negative or
factor isn't positive
*/
public
TimeLimitedRunner
(
long
timeout
,
double
factor
,
Callable
<
Boolean
>
target
)
{
Objects
.
requireNonNull
(
target
,
"target must not be null"
);
if
(
timeout
<
0
)
{
throw
new
IllegalArgumentException
(
"timeout["
+
timeout
+
"] < 0"
);
}
if
(
factor
<=
0
d
)
{
throw
new
IllegalArgumentException
(
"factor["
+
factor
+
"] <= 0"
);
}
this
.
stoptime
=
System
.
currentTimeMillis
()
+
timeout
;
this
.
timeout
=
timeout
;
this
.
factor
=
factor
;
this
.
target
=
target
;
}
/**
* Runs @{linkplan target} while it returns true and timeout isn't exceeded
*/
@Override
public
Void
call
()
throws
Exception
{
long
maxDuration
=
0L
;
long
iterStart
=
System
.
currentTimeMillis
();
if
(
timeout
!=
0
&&
iterStart
>
stoptime
)
{
return
null
;
}
while
(
target
.
call
())
{
if
(
timeout
!=
0
)
{
long
iterDuration
=
System
.
currentTimeMillis
()
-
iterStart
;
maxDuration
=
Math
.
max
(
maxDuration
,
iterDuration
);
iterStart
=
System
.
currentTimeMillis
();
if
(
iterStart
+
(
maxDuration
*
factor
)
>
stoptime
)
{
System
.
out
.
println
(
"Not enough time to continue execution. "
+
"Interrupted."
);
break
;
}
}
}
return
null
;
}
}
test/lib/testlibrary/jdk/testlibrary/Utils.java
浏览文件 @
eddd1249
...
...
@@ -35,6 +35,7 @@ import java.util.Arrays;
import
java.util.Collections
;
import
java.util.regex.Pattern
;
import
java.util.regex.Matcher
;
import
java.util.concurrent.TimeUnit
;
/**
* Common library for various test helper functions.
...
...
@@ -67,6 +68,12 @@ public final class Utils {
TIMEOUT_FACTOR
=
Double
.
parseDouble
(
toFactor
);
}
/**
* Returns the value of JTREG default test timeout in milliseconds
* converted to {@code long}.
*/
public
static
final
long
DEFAULT_TEST_TIMEOUT
=
TimeUnit
.
SECONDS
.
toMillis
(
120
);
private
Utils
()
{
// Private constructor to prevent class instantiation
}
...
...
@@ -259,4 +266,14 @@ public final class Utils {
throw
t
;
}
}
/**
* Adjusts the provided timeout value for the TIMEOUT_FACTOR
* @param tOut the timeout value to be adjusted
* @return The timeout value adjusted for the value of "test.timeout.factor"
* system property
*/
public
static
long
adjustTimeout
(
long
tOut
)
{
return
Math
.
round
(
tOut
*
Utils
.
TIMEOUT_FACTOR
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录