Build run-test files.
Change-Id: I5b300d88b347b4c566186551594a30df09959e2e
diff --git a/test/Android.mk b/test/Android.mk
new file mode 100644
index 0000000..83d4399
--- /dev/null
+++ b/test/Android.mk
@@ -0,0 +1,45 @@
+# Copyright (C) 2012 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+TEST_ART_RUN_TEST_MAKE_TARGETS :=
+
+# Helper to create individual build targets for tests.
+# Must be called with $(eval)
+# $(1): the test number
+define declare-make-art-run-test
+dmart_target := $(TARGET_OUT_DATA)/art-run-tests/$(1)/touch
+$$(dmart_target):
+ $(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
+ $(hide) $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1)
+ $(hide) touch $$@
+
+TEST_ART_RUN_TEST_MAKE_TARGETS += $$(dmart_target)
+dmart_target :=
+endef
+
+# Expand all tests.
+$(foreach test, $(wildcard art/test/[0-9]*), $(eval $(call declare-make-art-run-test,$(notdir $(test)))))
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE := art-run-tests
+LOCAL_ADDITIONAL_DEPENDENCIES := $(TEST_ART_RUN_TEST_MAKE_TARGETS)
+include $(BUILD_PHONY_PACKAGE)
+
+# clear temp vars
+TEST_ART_RUN_TEST_MAKE_TARGETS :=
+declare-make-art-run-test :=
diff --git a/test/run-test b/test/run-test
index 7a97479..f7a5827 100755
--- a/test/run-test
+++ b/test/run-test
@@ -55,6 +55,7 @@
update_mode="no"
debug_mode="no"
usage="no"
+build_only="no"
while true; do
if [ "x$1" = "x--host" ]; then
@@ -99,6 +100,13 @@
run_args="${run_args} --dev"
dev_mode="yes"
shift
+ elif [ "x$1" = "x--build-only" ]; then
+ build_only="yes"
+ shift
+ elif [ "x$1" = "x--output-path" ]; then
+ shift
+ tmp_dir=$1
+ shift
elif [ "x$1" = "x--update" ]; then
update_mode="yes"
shift
@@ -134,7 +142,6 @@
fi
test_dir="$td2"
fi
-
# Shift to get rid of the test name argument. The rest of the arguments
# will get passed to the test run.
shift
@@ -156,6 +163,7 @@
echo " -O Run oatexec rather than oatexecd (off by default)."
echo " --debug Wait for a debugger to attach."
#echo " --gdb Run under gdb; incompatible with some tests."
+ echo " --build-only Build test files only (off by default)."
echo " --no-verify Turn off verification (on by default)."
echo " --no-optimize Turn off optimization (on by default)."
echo " --no-precise Turn off precise GC (on by default)."
@@ -165,6 +173,8 @@
echo " --host Use the host-mode virtual machine."
echo " --valgrind Use valgrind when running locally."
echo " --jvm Use a host-local RI virtual machine."
+ echo " --output-path [path] Location where to store the build" \
+ "files."
) 1>&2
exit 1
fi
@@ -224,6 +234,20 @@
cat "$build_output" 1>&2
echo "build exit status: $build_exit" 1>&2
fi
+elif [ "$build_only" = "yes" ]; then
+ good="yes"
+ "./${build}" >"$build_output" 2>&1
+ build_exit="$?"
+ if [ "$build_exit" '!=' '0' ]; then
+ cp "$build_output" "$output"
+ echo "build exit status: $build_exit" >>"$output"
+ diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
+ if [ "$?" '!=' "0" ]; then
+ good="no"
+ echo "BUILD FAILED For ${TEST_NAME}"
+ fi
+ fi
+ exit 0
else
"./${build}" >"$build_output" 2>&1
build_exit="$?"
@@ -241,7 +265,8 @@
fi
fi
-if [ "$good" = "yes" ]; then
+# Clean up test files.
+if [ "$good" == "yes" ]; then
cd "$oldwd"
rm -rf "$tmp_dir"
if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
@@ -250,8 +275,9 @@
exit 0
fi
+
(
- if [ "$update_mode" '!=' "yes" ]; then
+ if [ "$update_mode" != "yes" ]; then
echo "${test_dir}: FAILED!"
echo ' '
echo '#################### info'
@@ -262,7 +288,7 @@
echo ' '
fi
echo "${TEST_NAME} files left in ${tmp_dir} on host"
- if [ "$target_mode" = "yes" ]; then
+ if [ "$target_mode" == "yes" ]; then
echo "and in ${DEX_LOCATION} on target"
fi