Skip to content

Commit

Permalink
ojtests: Split out public/boot tests and add device targets
Browse files Browse the repository at this point in the history
* Enable tests to be run from CTS (without changing bootclasspath)
* Fix host test script to pass higher heap maximum
* Include test source code as part of the core-ojtests-public.jar

Bug: 27521545
Bug: 27797922
Change-Id: Ibd5ac74c939d1252e17dab2dc22d2a00de837bfd
(cherry picked from commit ce0115e)
  • Loading branch information
iam committed Apr 26, 2016
1 parent 75b9bef commit 6037000
Show file tree
Hide file tree
Showing 80 changed files with 5,272 additions and 397 deletions.
39 changes: 38 additions & 1 deletion JavaLibrary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ ifeq ($(LIBCORE_SKIP_TESTS),)
include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
endif

# Make the core-ojtests library.
# Make the core-ojtests-hostdex library.
ifeq ($(LIBCORE_SKIP_TESTS),)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(ojtest_src_files)
Expand All @@ -340,6 +340,43 @@ ifeq ($(LIBCORE_SKIP_TESTS),)
include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
endif

# Make the core-ojtests library.
ifeq ($(LIBCORE_SKIP_TESTS),)
include $(CLEAR_VARS)
LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVA_LIBRARIES := core-oj core-libart core-lambda-stubs okhttp bouncycastle
LOCAL_STATIC_JAVA_LIBRARIES := testng
LOCAL_JAVACFLAGS := $(local_javac_flags)
LOCAL_MODULE_TAGS := optional
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
LOCAL_MODULE := core-ojtests
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
# jack bug workaround: int[] java.util.stream.StatefulTestOp.-getjava-util-stream-StreamShapeSwitchesValues() is a private synthetic method in an interface which causes a hard verifier error
LOCAL_DEX_PREOPT := false # disable AOT preverification which breaks the build. it will still throw VerifyError at runtime.
include $(BUILD_JAVA_LIBRARY)
endif


# Make the core-ojtests-public library. Excludes any private API tests.
ifeq ($(LIBCORE_SKIP_TESTS),)
include $(CLEAR_VARS)
# Filter out SerializedLambdaTest because it depends on stub classes and won't actually run.
LOCAL_SRC_FILES := $(filter-out %/DeserializeMethodTest.java %/SerializedLambdaTest.java ojluni/src/test/java/util/stream/boot%,$(ojtest_src_files)) # Do not include anything from the boot* directories. Those directories need a custom bootclasspath to run.
# Include source code as part of JAR
LOCAL_JAVA_RESOURCE_DIRS := ojluni/src/test/dist
LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVA_LIBRARIES := core-oj core-libart core-lambda-stubs okhttp bouncycastle testng
LOCAL_JAVACFLAGS := $(local_javac_flags)
LOCAL_MODULE_TAGS := optional
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
LOCAL_MODULE := core-ojtests-public
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
# jack bug workaround: int[] java.util.stream.StatefulTestOp.-getjava-util-stream-StreamShapeSwitchesValues() is a private synthetic method in an interface which causes a hard verifier error
LOCAL_DEX_PREOPT := false # disable AOT preverification which breaks the build. it will still throw VerifyError at runtime.
include $(BUILD_JAVA_LIBRARY)
endif


endif # HOST_OS == linux

#
Expand Down
45 changes: 23 additions & 22 deletions ojluni/src/main/java/java/util/stream/AbstractPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@
* @param <E_OUT> type of output elements
* @param <S> type of the subclass implementing {@code BaseStream}
* @since 1.8
* @hide Visibility for CTS only (OpenJDK 8 streams tests).
*/
abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
public abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
extends PipelineHelper<E_OUT> implements BaseStream<E_OUT, S> {
private static final String MSG_STREAM_LINKED = "stream has already been operated upon or closed";
private static final String MSG_CONSUMED = "source already consumed or closed";
Expand Down Expand Up @@ -241,7 +242,7 @@ final <R> R evaluate(TerminalOp<E_OUT, R> terminalOp) {
* @return a flat array-backed Node that holds the collected output elements
*/
@SuppressWarnings("unchecked")
final Node<E_OUT> evaluateToArrayNode(IntFunction<E_OUT[]> generator) {
public final Node<E_OUT> evaluateToArrayNode(IntFunction<E_OUT[]> generator) {
if (linkedOrConsumed)
throw new IllegalStateException(MSG_STREAM_LINKED);
linkedOrConsumed = true;
Expand Down Expand Up @@ -379,7 +380,7 @@ public final boolean isParallel() {
* intermediate operations
* @see StreamOpFlag
*/
final int getStreamFlags() {
public final int getStreamFlags() {
return StreamOpFlag.toStreamFlags(combinedFlags);
}

Expand Down Expand Up @@ -500,7 +501,7 @@ final <P_IN> void copyIntoWithCancel(Sink<P_IN> wrappedSink, Spliterator<P_IN> s
}

@Override
final int getStreamAndOpFlags() {
public final int getStreamAndOpFlags() {
return combinedFlags;
}

Expand All @@ -510,7 +511,7 @@ final boolean isOrdered() {

@Override
@SuppressWarnings("unchecked")
final <P_IN> Sink<P_IN> wrapSink(Sink<E_OUT> sink) {
public final <P_IN> Sink<P_IN> wrapSink(Sink<E_OUT> sink) {
Objects.requireNonNull(sink);

for ( @SuppressWarnings("rawtypes") AbstractPipeline p=AbstractPipeline.this; p.depth > 0; p=p.previousStage) {
Expand All @@ -532,7 +533,7 @@ final <P_IN> Spliterator<E_OUT> wrapSpliterator(Spliterator<P_IN> sourceSplitera

@Override
@SuppressWarnings("unchecked")
final <P_IN> Node<E_OUT> evaluate(Spliterator<P_IN> spliterator,
public final <P_IN> Node<E_OUT> evaluate(Spliterator<P_IN> spliterator,
boolean flatten,
IntFunction<E_OUT[]> generator) {
if (isParallel()) {
Expand All @@ -557,7 +558,7 @@ final <P_IN> Node<E_OUT> evaluate(Spliterator<P_IN> spliterator,
*
* @return the output shape
*/
abstract StreamShape getOutputShape();
public abstract StreamShape getOutputShape();

/**
* Collect elements output from a pipeline into a Node that holds elements
Expand All @@ -569,10 +570,10 @@ final <P_IN> Node<E_OUT> evaluate(Spliterator<P_IN> spliterator,
* @param generator the array generator
* @return a Node holding the output of the pipeline
*/
abstract <P_IN> Node<E_OUT> evaluateToNode(PipelineHelper<E_OUT> helper,
Spliterator<P_IN> spliterator,
boolean flattenTree,
IntFunction<E_OUT[]> generator);
public abstract <P_IN> Node<E_OUT> evaluateToNode(PipelineHelper<E_OUT> helper,
Spliterator<P_IN> spliterator,
boolean flattenTree,
IntFunction<E_OUT[]> generator);

/**
* Create a spliterator that wraps a source spliterator, compatible with
Expand All @@ -583,16 +584,16 @@ abstract <P_IN> Node<E_OUT> evaluateToNode(PipelineHelper<E_OUT> helper,
* @param supplier the supplier of a spliterator
* @return a wrapping spliterator compatible with this shape
*/
abstract <P_IN> Spliterator<E_OUT> wrap(PipelineHelper<E_OUT> ph,
Supplier<Spliterator<P_IN>> supplier,
boolean isParallel);
public abstract <P_IN> Spliterator<E_OUT> wrap(PipelineHelper<E_OUT> ph,
Supplier<Spliterator<P_IN>> supplier,
boolean isParallel);

/**
* Create a lazy spliterator that wraps and obtains the supplied the
* spliterator when a method is invoked on the lazy spliterator.
* @param supplier the supplier of a spliterator
*/
abstract Spliterator<E_OUT> lazySpliterator(Supplier<? extends Spliterator<E_OUT>> supplier);
public abstract Spliterator<E_OUT> lazySpliterator(Supplier<? extends Spliterator<E_OUT>> supplier);

/**
* Traverse the elements of a spliterator compatible with this stream shape,
Expand All @@ -602,7 +603,7 @@ abstract <P_IN> Spliterator<E_OUT> wrap(PipelineHelper<E_OUT> ph,
* @param spliterator the spliterator to pull elements from
* @param sink the sink to push elements to
*/
abstract void forEachWithCancel(Spliterator<E_OUT> spliterator, Sink<E_OUT> sink);
public abstract void forEachWithCancel(Spliterator<E_OUT> spliterator, Sink<E_OUT> sink);

/**
* Make a node builder compatible with this stream shape.
Expand All @@ -620,8 +621,8 @@ abstract <P_IN> Spliterator<E_OUT> wrap(PipelineHelper<E_OUT> ph,
* @return a node builder
*/
@Override
abstract Node.Builder<E_OUT> makeNodeBuilder(long exactSizeIfKnown,
IntFunction<E_OUT[]> generator);
public abstract Node.Builder<E_OUT> makeNodeBuilder(long exactSizeIfKnown,
IntFunction<E_OUT[]> generator);


// Op-specific abstract methods, implemented by the operation class
Expand All @@ -634,7 +635,7 @@ abstract Node.Builder<E_OUT> makeNodeBuilder(long exactSizeIfKnown,
*
* @return {@code true} if this operation is stateful
*/
abstract boolean opIsStateful();
public abstract boolean opIsStateful();

/**
* Accepts a {@code Sink} which will receive the results of this operation,
Expand All @@ -655,7 +656,7 @@ abstract Node.Builder<E_OUT> makeNodeBuilder(long exactSizeIfKnown,
* each element, and passes the results (if any) to the provided
* {@code Sink}.
*/
abstract Sink<E_IN> opWrapSink(int flags, Sink<E_OUT> sink);
public abstract Sink<E_IN> opWrapSink(int flags, Sink<E_OUT> sink);

/**
* Performs a parallel evaluation of the operation using the specified
Expand All @@ -672,7 +673,7 @@ abstract Node.Builder<E_OUT> makeNodeBuilder(long exactSizeIfKnown,
* @param generator the array generator
* @return a {@code Node} describing the result of the evaluation
*/
<P_IN> Node<E_OUT> opEvaluateParallel(PipelineHelper<E_OUT> helper,
public <P_IN> Node<E_OUT> opEvaluateParallel(PipelineHelper<E_OUT> helper,
Spliterator<P_IN> spliterator,
IntFunction<E_OUT[]> generator) {
throw new UnsupportedOperationException("Parallel evaluation is not supported");
Expand All @@ -699,7 +700,7 @@ <P_IN> Node<E_OUT> opEvaluateParallel(PipelineHelper<E_OUT> helper,
* @return a {@code Spliterator} describing the result of the evaluation
*/
@SuppressWarnings("unchecked")
<P_IN> Spliterator<E_OUT> opEvaluateParallelLazy(PipelineHelper<E_OUT> helper,
public <P_IN> Spliterator<E_OUT> opEvaluateParallelLazy(PipelineHelper<E_OUT> helper,
Spliterator<P_IN> spliterator) {
return opEvaluateParallel(helper, spliterator, i -> (E_OUT[]) new Object[i]).spliterator();
}
Expand Down
6 changes: 3 additions & 3 deletions ojluni/src/main/java/java/util/stream/DistinctOps.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <P_IN> Node<T> reduce(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
}

@Override
<P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
Spliterator<P_IN> spliterator,
IntFunction<T[]> generator) {
if (StreamOpFlag.DISTINCT.isKnown(helper.getStreamAndOpFlags())) {
Expand Down Expand Up @@ -100,7 +100,7 @@ else if (StreamOpFlag.ORDERED.isKnown(helper.getStreamAndOpFlags())) {
}

@Override
<P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
public <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
if (StreamOpFlag.DISTINCT.isKnown(helper.getStreamAndOpFlags())) {
// No-op
return helper.wrapSpliterator(spliterator);
Expand All @@ -116,7 +116,7 @@ else if (StreamOpFlag.ORDERED.isKnown(helper.getStreamAndOpFlags())) {
}

@Override
Sink<T> opWrapSink(int flags, Sink<T> sink) {
public Sink<T> opWrapSink(int flags, Sink<T> sink) {
Objects.requireNonNull(sink);

if (StreamOpFlag.DISTINCT.isKnown(flags)) {
Expand Down
Loading

0 comments on commit 6037000

Please sign in to comment.