Fix run-test on host.
Change-Id: I44ebb4cdc2f5966be51a063e3c7256ab3016c404
diff --git a/src/logging.h b/src/logging.h
index 7c04777..c1ea3ab 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -262,6 +262,15 @@
bool startup;
bool third_party_jni; // Enabled with "-verbose:third-party-jni".
bool threads;
+ std::ostream* logging_stream;
+
+ void SetLoggingStream(std::ostream* new_logging_stream) {
+ DCHECK(new_logging_stream->good());
+ if (logging_stream != NULL) {
+ delete logging_stream;
+ }
+ logging_stream = new_logging_stream;
+ }
};
extern LogVerbosity gLogVerbosity;
diff --git a/src/logging_linux.cc b/src/logging_linux.cc
index e781a00..4e7c796 100644
--- a/src/logging_linux.cc
+++ b/src/logging_linux.cc
@@ -34,9 +34,11 @@
}
void LogMessage::LogLine(const char* message) {
- std::cerr << "VDIWEFF"[data_->severity] << ' '
- << StringPrintf("%5d %5d", getpid(), ::art::GetTid()) << ' '
- << data_->file << ':' << data_->line_number << "] " << message << std::endl;
+ std::ostream &out =
+ (gLogVerbosity.logging_stream == NULL ? std::cerr : *gLogVerbosity.logging_stream);
+ out << "VDIWEFF"[data_->severity] << ' '
+ << StringPrintf("%5d %5d", getpid(), ::art::GetTid()) << ' '
+ << data_->file << ':' << data_->line_number << "] " << message << std::endl;
}
} // namespace art
diff --git a/src/runtime.cc b/src/runtime.cc
index 12f7c8b..014ce6b 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -22,6 +22,7 @@
#include <cstdlib>
#include <limits>
#include <vector>
+#include <fstream>
#include "class_linker.h"
#include "class_loader.h"
@@ -421,6 +422,15 @@
gLogVerbosity.third_party_jni = true;
} else if (verbose_options[i] == "threads") {
gLogVerbosity.threads = true;
+ } else if (StartsWith(verbose_options[i], "log-to=")) {
+ std::string log_file_name(verbose_options[i].substr(strlen("log-to=")));
+ std::ofstream* log_file = new std::ofstream(log_file_name.c_str());
+ if (log_file->is_open() && log_file->good()) {
+ gLogVerbosity.SetLoggingStream(log_file);
+ } else {
+ LOG(ERROR) << "Fail to open log file: \"" << log_file_name << "\","
+ << " use default logging stream.";
+ }
} else {
LOG(WARNING) << "Ignoring unknown -verbose option: " << verbose_options[i];
}
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 0a1cf8f..d6efe1d 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -221,8 +221,8 @@
return result;
}
-static inline std::string ClassNameFromIndex(const Method* method, uint32_t ref,
- verifier::VerifyErrorRefType ref_type, bool access) {
+static std::string ClassNameFromIndex(const Method* method, uint32_t ref,
+ verifier::VerifyErrorRefType ref_type, bool access) {
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
const DexFile& dex_file = class_linker->FindDexFile(method->GetDeclaringClass()->GetDexCache());
diff --git a/test/003-omnibus-opcodes/build b/test/003-omnibus-opcodes/build
index 0671a32..bb9c4f8 100644
--- a/test/003-omnibus-opcodes/build
+++ b/test/003-omnibus-opcodes/build
@@ -24,4 +24,4 @@
dx -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
zip $TEST_NAME.jar classes.dex
-dex2oatd --boot-image=${ANDROID_PRODUCT_OUT}/data/art-test/core.art --dex-file=$TEST_NAME.jar --dex-location=/data/run-test/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat
+dex2oatd --boot-image=$IMAGE --dex-file=$TEST_NAME.jar --dex-location=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat $DEX2OAT_ARGS
diff --git a/test/022-interface/build b/test/022-interface/build
index 24b32bb..1841f0622d 100644
--- a/test/022-interface/build
+++ b/test/022-interface/build
@@ -21,4 +21,4 @@
# issue when interfaces override methods in Object
dx --debug --dex --dump-to=classes.lst --output=classes.dex classes
zip $TEST_NAME.jar classes.dex
-dex2oatd --boot-image=${ANDROID_PRODUCT_OUT}/data/art-test/core.art --dex-file=$TEST_NAME.jar --dex-location=/data/run-test/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat
+dex2oatd --boot-image=$IMAGE --dex-file=$TEST_NAME.jar --dex-location=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat $DEX2OAT_ARGS
diff --git a/test/023-many-interfaces/build b/test/023-many-interfaces/build
index b28ab88..5d981f4 100644
--- a/test/023-many-interfaces/build
+++ b/test/023-many-interfaces/build
@@ -26,4 +26,4 @@
dx --debug --dex --dump-to=classes.lst --output=classes.dex classes
zip $TEST_NAME.jar classes.dex
-dex2oatd --boot-image=${ANDROID_PRODUCT_OUT}/data/art-test/core.art --dex-file=$TEST_NAME.jar --dex-location=/data/run-test/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat
+dex2oatd --boot-image=$IMAGE --dex-file=$TEST_NAME.jar --dex-location=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat $DEX2OAT_ARGS
diff --git a/test/056-const-string-jumbo/build b/test/056-const-string-jumbo/build
index d052831..b3d9aad 100644
--- a/test/056-const-string-jumbo/build
+++ b/test/056-const-string-jumbo/build
@@ -44,4 +44,4 @@
dx -JXmx500m --debug --dex --no-optimize --positions=none --no-locals --dump-to=classes.lst --output=classes.dex classes
zip $TEST_NAME.jar classes.dex
-dex2oatd --boot-image=${ANDROID_PRODUCT_OUT}/data/art-test/core.art --dex-file=$TEST_NAME.jar --dex-location=/data/run-test/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat
+dex2oatd --boot-image=$IMAGE --dex-file=$TEST_NAME.jar --dex-location=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat $DEX2OAT_ARGS
diff --git a/test/085-old-style-inner-class/build b/test/085-old-style-inner-class/build
index daf615d..b771e6c 100644
--- a/test/085-old-style-inner-class/build
+++ b/test/085-old-style-inner-class/build
@@ -26,4 +26,4 @@
dx --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes 2>/dev/null
zip $TEST_NAME.jar classes.dex
-dex2oatd --boot-image=${ANDROID_PRODUCT_OUT}/data/art-test/core.art --dex-file=$TEST_NAME.jar --dex-location=/data/run-test/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat
+dex2oatd --boot-image=$IMAGE --dex-file=$TEST_NAME.jar --dex-location=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat $DEX2OAT_ARGS
diff --git a/test/etc/default-build b/test/etc/default-build
index 3e5ccd3..01bac6b 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -26,7 +26,8 @@
dx -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes
zip $TEST_NAME.jar classes.dex
-dex2oatd --boot-image=${ANDROID_PRODUCT_OUT}/data/art-test/core.art --dex-file=$TEST_NAME.jar --dex-location=/data/run-test/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat
+
+dex2oatd --boot-image=$IMAGE --dex-file=$TEST_NAME.jar --dex-location=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$TEST_NAME.jar.oat $DEX2OAT_ARGS
if [ -r src-ex ]; then
mkdir classes-ex
@@ -37,7 +38,7 @@
mv classes.dex classes-1.dex
mv classes-ex.dex classes.dex
zip $TEST_NAME-ex.jar classes.dex
- dex2oatd --boot-image=${ANDROID_PRODUCT_OUT}/data/art-test/core.art --dex-file=$TEST_NAME-ex.jar --dex-location=/data/run-test/$TEST_NAME-ex.jar --oat-file=$TEST_NAME-ex.jar.oat
+ dex2oatd --boot-image=$IMAGE --dex-file=$TEST_NAME-ex.jar --dex-location=$DEX_LOCATION/$TEST_NAME-ex.jar --oat-file=$TEST_NAME-ex.jar.oat $DEX2OAT_ARGS
mv classes.dex classes-ex.dex
mv classes-1.dex classes.dex
fi
diff --git a/test/etc/host-run-test-jar b/test/etc/host-run-test-jar
index f424487..b56549e 100755
--- a/test/etc/host-run-test-jar
+++ b/test/etc/host-run-test-jar
@@ -61,7 +61,7 @@
HOSTBASE="${ANDROID_BUILD_TOP}/out/host"
DATA_DIR=/tmp
-DEBUG_OPTS="-Xcheck:jni -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
+DEBUG_OPTS="-Xcheck:jni"
if [ ! -d $DATA_DIR/art-cache ]; then
mkdir -p $DATA_DIR/art-cache
@@ -84,7 +84,10 @@
if [ "$DEBUG" = "y" ]; then
PORT=8000
msg "Waiting for debugger to connect on localhost:$PORT"
- DEX_DEBUG="-agentlib:jdwp=transport=dt_socket,addres=$PORT,server=y,suspend=y"
+ # This is for jdb:
+ DEX_DEBUG="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
+ # Connect thus:
+ # jdb -attach localhost:12345
fi
if [ "$GDB" = "y" ]; then
@@ -94,5 +97,5 @@
cd $ANDROID_BUILD_TOP
$INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \
- $DEX_DEBUG ${DEBUG_OPTS} \
- -cp test.jar Main "$@"
+ $DEBUG_OPTS $DEX_DEBUG -verbose:log-to=$DEX_LOCATION/log.txt\
+ -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"
diff --git a/test/run-all-tests b/test/run-all-tests
index 18ffa17..3176f02 100755
--- a/test/run-all-tests
+++ b/test/run-all-tests
@@ -103,15 +103,19 @@
# wait for all the tests, collecting the failures
failure_count=0
+succeeded_count=0
failed_test_names=""
for pid in ${test_pids[@]}; do
wait $pid
if [ "$?" != "0" ]; then
let failure_count+=1
- failed_test_names="$failed_test_names $test_names[$pid]"
+ failed_test_names="$failed_test_names ${test_names[$pid]}[pid=$pid]"
+ else
+ let succeeded_count+=1
fi
done
+echo "succeeded tests: $succeeded_count"
echo "failed tests: $failure_count"
for i in $failed_test_names; do
diff --git a/test/run-test b/test/run-test
index 0c31c31..c3170b6 100755
--- a/test/run-test
+++ b/test/run-test
@@ -32,10 +32,14 @@
cd "${progdir}"
progdir=`pwd`
prog="${progdir}"/`basename "${prog}"`
+tmp_dir="/tmp/test-$$"
export JAVA="java"
export JAVAC="javac -g -target 1.5"
export RUN="${progdir}/etc/push-and-run-test-jar"
+export IMAGE=${ANDROID_PRODUCT_OUT}/data/art-test/core.art
+export DEX_LOCATION=/data/run-test
+export DEX2OAT_ARGS=""
info="info.txt"
build="build"
@@ -53,6 +57,9 @@
while true; do
if [ "x$1" = "x--host" ]; then
RUN="${progdir}/etc/host-run-test-jar"
+ IMAGE=${ANDROID_BUILD_TOP}/out/host/linux-x86/framework/core.art
+ DEX_LOCATION=$tmp_dir
+ DEX2OAT_ARGS="--instruction-set=X86 --host-prefix=$ANDROID_BUILD_TOP/"
shift
elif [ "x$1" = "x--jvm" ]; then
RUN="${progdir}/etc/reference-run-test-classes"
@@ -164,8 +171,6 @@
td_info="${test_dir}/${info}"
td_expected="${test_dir}/${expected}"
-tmp_dir="/tmp/test-$$"
-
if [ '!' '(' -r "$td_info" -a -r "$td_expected" ')' ]; then
echo "${test_dir}: missing files" 1>&2
exit 1