Skip to content

Commit

Permalink
Revert "Revert "ojluni: Downstream OJ tests""
Browse files Browse the repository at this point in the history
This reverts commit 6b74f41.

Change-Id: I06fd28baa6e4793b3e3d3639745a3a68f89b2582
  • Loading branch information
iam committed Mar 24, 2016
1 parent 6b74f41 commit 4c65c01
Show file tree
Hide file tree
Showing 89 changed files with 16,270 additions and 0 deletions.
16 changes: 16 additions & 0 deletions JavaLibrary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ core_resource_dirs := \
ojluni/src/main/resources/
test_resource_dirs := $(call all-core-resource-dirs,test)
test_src_files := $(call all-test-java-files-under,dalvik dom harmony-tests json luni xml)
ojtest_src_files := $(call all-test-java-files-under,ojluni)

ifeq ($(EMMA_INSTRUMENT),true)
ifneq ($(EMMA_INSTRUMENT_STATIC),true)
Expand Down Expand Up @@ -326,6 +327,21 @@ ifeq ($(LIBCORE_SKIP_TESTS),)
include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
endif

# Make the core-ojtests library.
ifeq ($(LIBCORE_SKIP_TESTS),)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(ojtest_src_files)
LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex core-lambda-stubs-hostdex okhttp-hostdex bouncycastle-hostdex
LOCAL_STATIC_JAVA_LIBRARIES := testng-hostdex
LOCAL_JAVACFLAGS := $(local_javac_flags)
LOCAL_MODULE_TAGS := optional
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
LOCAL_MODULE := core-ojtests-hostdex
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
endif

endif # HOST_OS == linux

#
Expand Down
126 changes: 126 additions & 0 deletions ojluni/src/test/artrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/usr/bin/env bash

# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



###
### Change the BOOTCLASSPATH to pick up bootlib classes.
### Export ANDROID_DATA=something else (it should have dalvik-cache dir in it)
### Point the image to something else that's not existing.
###
### Actually run dalvikvm now...
###

if [[ -z $ANDROID_BUILD_TOP ]]; then
echo "Run source build/envsetup.sh first" >& 2
exit 1
fi

invoke_with=
DALVIKVM=dalvikvm
LIBART=libart.so

function follow_links() {
if [ z"$BASH_SOURCE" != z ]; then
file="$BASH_SOURCE"
else
file="$0"
fi
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}

function find_libdir() {
# Use realpath instead of readlink because Android does not have a readlink.
if [ "$(realpath "$ANDROID_ROOT/bin/$DALVIKVM")" = "$(realpath "$ANDROID_ROOT/bin/dalvikvm64")" ]; then
echo "lib64"
else
echo "lib"
fi
}

function join { local IFS="$1"; shift; echo "$*"; }

PROG_NAME="$(follow_links)"
PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"

if [[ -z $ANDROID_ROOT ]]; then
# Already set to /system for actual android devices
ANDROID_ROOT=$ANDROID_HOST_OUT
fi
LIBDIR=$(find_libdir)
LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBDIR
DEBUG_OPTION=""


DELETE_ANDROID_DATA=false
# If ANDROID_DATA is the system ANDROID_DATA or is not set, use our own,
# and ensure we delete it at the end.
if [ "$ANDROID_DATA" = "/data" ] || [ "$ANDROID_DATA" = "" ]; then
ANDROID_DATA=$PWD/android-data$$
IMAGE_DIRECTORY=$ANDROID_DATA/image
mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64}
mkdir -p $IMAGE_DIRECTORY
DELETE_ANDROID_DATA=true
fi


IMAGE_LOCATION=$IMAGE_DIRECTORY/core-extrabootclasspath.art

BOOT_DEXJARS=(
bouncycastle-hostdex.jar
apache-xml-hostdex.jar
core-tests-hostdex.jar
core-libart-hostdex.jar
core-lambda-stubs-hostdex.jar
conscrypt-hostdex.jar
core-ojtests-hostdex.jar
core-oj-hostdex.jar
okhttp-hostdex.jar)

BOOT_DEXJAR_PREFIX="$ANDROID_ROOT/framework"

BOOT_DEXJARS_ABS=()
for dexjar in ${BOOT_DEXJARS[@]}; do
BOOT_DEXJARS_ABS=(${BOOT_DEXJARS_ABS[@]} $BOOT_DEXJAR_PREFIX/$dexjar)
done

export BOOTCLASSPATH=$(join ":" "${BOOT_DEXJARS_ABS[@]}") # a,b,c

echo "BOOTCLASSPATH=$BOOTCLASSPATH"
echo "PROG_NAME=$PROG_NAME"
echo "PROG_DIR=$PROG_DIR"
echo "ANDROID_ROOT=$ANDROID_ROOT"
echo "LIBDIR=$LIBDIR"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
echo "DEBUG_OPTION=$DEBUG_OPTION"

echo "export BOOTCLASSPATH=$BOOTCLASSPATH"
echo export ANDROID_ROOT="$ANDROID_ROOT"
ANDROID_DATA=$ANDROID_DATA \
ANDROID_ROOT=$ANDROID_ROOT \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
PATH=$ANDROID_ROOT/bin:$PATH \
LD_USE_LOAD_BIAS=1 \
$invoke_with $ANDROID_ROOT/bin/$DALVIKVM $lib \
-XXlib:$LIBART \
-Xnorelocate \
-Ximage:$IMAGE_LOCATION \
$DEBUG_OPTION \
"$@"
17 changes: 17 additions & 0 deletions ojluni/src/test/artrun-testng
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

./artrun org.testng.TestNG -verbose 3 ./testng.xml
86 changes: 86 additions & 0 deletions ojluni/src/test/gen-test-list
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash

# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

###
### Scan this directory for any testng classes
### Outputs a testng.xml formatted list of classes
###

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
test_property_files="$(find "$DIR" -name TEST.properties)"

function debug_print {
if [[ $DEBUG == "true" ]]; then
echo "DEBUG:" "$@" >& 2
fi
}

function error_print {
echo "ERROR:" "$@" >& 2
exit 1
}

function class_name_from_class_file {
# Reads a list of .java files from stdin, spits out their fully qualified class name.
local file_name
local package_string
local package_name
local class_name
while read file_name; do
package_string="$(grep "package" "$file_name")"
[[ $? -ne 0 ]] && error_print "File $file_name missing package declaration."
debug_print "File: $file_name"

# Parse the package name by looking inside of the file.
package_name=${package_string#package[[:space:]]*} # remove package followed by any spaces
package_name=${package_name%;} # remove semicolon at the end

# Assumes class name == file name. Almost always the case.
class_name="$(basename "$file_name")"
class_name="${class_name%.java}" # remove ".java" from the end
debug_print "Package: <$package_name>"

echo "$package_name.$class_name"
done
}

function list_classes_in_dir {
find "$1" -name "*.java" | class_name_from_class_file
}

function list_all_classes {
local file
for file in $test_property_files; do
debug_print "File: $file"

if ! grep "TestNG.dirs" "$file" > /dev/null; then
continue
fi

debug_print "Has TestNG files"

list_classes_in_dir "$(dirname "$file")"
done
}

function class_name_to_testng_entry {
local class_name
while read class_name; do
echo "<class name=\"$class_name\" />"
done
}

list_all_classes | class_name_to_testng_entry
Loading

0 comments on commit 4c65c01

Please sign in to comment.