Make things generally quieter.
* Give run-test a --quiet flag that causes it to only print on errors.
* Give cpplint a --quiet flag that causes it to not print anything
when there are no errors.
* Add a ART_TEST_QUIET flag to build/Android.common_test.mk which
makes run-test targets much quieter when true (the default). With
this flag only failures will be printed.
* Make build/Android.cpplint.mk pass the new cpplint --quiet flag so
that only failures will be printed.
Before:
[ 96% 5715/5906] build test-art-host-run-test-debug-prebuild-interpreter-relocate-ntrace-cms-checkjni-image-npictest-ndebuggable-461-get-reference-vreg32
test-art-host-run-test-debug-prebuild-interpreter-relocate-ntrace-cms-checkjni-image-npictest-ndebuggable-448-multiple-returns32 RUNNING
/usr/local/google/buildbot/src/googleplex-android/master-art-host/art/test/448-multiple-returns: building...
/usr/local/google/buildbot/src/googleplex-android/master-art-host/art/test/448-multiple-returns: running...
/usr/local/google/buildbot/src/googleplex-android/master-art-host/art/test/448-multiple-returns: succeeded!
test-art-host-run-test-debug-prebuild-interpreter-relocate-ntrace-cms-checkjni-image-npictest-ndebuggable-448-multiple-returns32 PASSED
After:
[ 96% 5715/5906] build test-art-host-run-test-debug-prebuild-interpreter-relocate-ntrace-cms-checkjni-image-npictest-ndebuggable-461-get-reference-vreg32
Change-Id: Idf6fce7f48a619f83254b48861dbd7f8eb4ebdbf
diff --git a/test/run-test b/test/run-test
index f2bbaa7..9b0261e 100755
--- a/test/run-test
+++ b/test/run-test
@@ -110,6 +110,7 @@
run_args="--quiet"
build_args=""
+quiet="no"
debuggable="no"
prebuild_mode="yes"
target_mode="yes"
@@ -142,6 +143,9 @@
DEX_LOCATION=$tmp_dir
run_args="${run_args} --host"
shift
+ elif [ "x$1" = "x--quiet" ]; then
+ quiet="yes"
+ shift
elif [ "x$1" = "x--use-java-home" ]; then
if [ -n "${JAVA_HOME}" ]; then
export JAVA="${JAVA_HOME}/bin/java"
@@ -351,6 +355,29 @@
fi
done
+# Allocate file descriptor real_stderr and redirect it to the shell's error
+# output (fd 2).
+if [ ${BASH_VERSINFO[1]} -ge 4 ] && [ ${BASH_VERSINFO[2]} -ge 1 ]; then
+ exec {real_stderr}>&2
+else
+ # In bash before version 4.1 we need to do a manual search for free file
+ # descriptors.
+ FD=3
+ while [ -e /dev/fd/$FD ]; do FD=$((FD + 1)); done
+ real_stderr=$FD
+ eval "exec ${real_stderr}>&2"
+fi
+if [ "$quiet" = "yes" ]; then
+ # Force the default standard output and error to go to /dev/null so we will
+ # not print them.
+ exec 1>/dev/null
+ exec 2>/dev/null
+fi
+
+function err_echo() {
+ echo "$@" 1>&${real_stderr}
+}
+
# tmp_dir may be relative, resolve.
#
# Cannot use realpath, as it does not exist on Mac.
@@ -383,7 +410,7 @@
run_args="${run_args} --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin"
fi
elif [ "$trace_stream" = "true" ]; then
- echo "Cannot use --stream without --trace."
+ err_echo "Cannot use --stream without --trace."
exit 1
fi
@@ -410,7 +437,7 @@
if [ "$target_mode" = "no" ]; then
if [ "$runtime" = "jvm" ]; then
if [ "$prebuild_mode" = "yes" ]; then
- echo "--prebuild with --jvm is unsupported";
+ err_echo "--prebuild with --jvm is unsupported"
exit 1;
fi
fi
@@ -462,7 +489,7 @@
if [ "$have_image" = "no" ]; then
if [ "$runtime" != "art" ]; then
- echo "--no-image is only supported on the art runtime"
+ err_echo "--no-image is only supported on the art runtime"
exit 1
fi
if [ "$target_mode" = "no" ]; then
@@ -485,7 +512,12 @@
fi
if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
- echo "--dev and --update are mutually exclusive" 1>&2
+ err_echo "--dev and --update are mutually exclusive"
+ usage="yes"
+fi
+
+if [ "$dev_mode" = "yes" -a "$quiet" = "yes" ]; then
+ err_echo "--dev and --quiet are mutually exclusive"
usage="yes"
fi
@@ -499,7 +531,7 @@
if [ '!' -d "$test_dir" ]; then
td2=`echo ${test_dir}-*`
if [ '!' -d "$td2" ]; then
- echo "${test_dir}: no such test directory" 1>&2
+ err_echo "${test_dir}: no such test directory"
usage="yes"
fi
test_dir="$td2"
@@ -580,7 +612,8 @@
echo " --pic-image Use an image compiled with position independent code for the"
echo " boot class path."
echo " --pic-test Compile the test code position independent."
- ) 1>&2
+ echo " --quiet Don't print anything except failure messages"
+ ) 1>&2 # Direct to stderr so usage is not printed if --quiet is set.
exit 1
fi
@@ -591,12 +624,12 @@
td_expected="${test_dir}/${expected}"
if [ ! -r $td_info ]; then
- echo "${test_dir}: missing file $td_info" 1>&2
+ err_echo "${test_dir}: missing file $td_info"
exit 1
fi
if [ ! -r $td_expected ]; then
- echo "${test_dir}: missing file $td_expected" 1>&2
+ err_echo "${test_dir}: missing file $td_expected"
exit 1
fi
@@ -691,7 +724,7 @@
if [ ${USE_JACK} = "false" ]; then
# Set ulimit if we build with dx only, Jack can generate big temp files.
if ! ulimit -S "$build_file_size_limit"; then
- echo "ulimit file size setting failed"
+ err_echo "ulimit file size setting failed"
fi
fi
@@ -704,7 +737,7 @@
echo "build exit status: $build_exit" 1>&2
if [ "$build_exit" = '0' ]; then
if ! ulimit -S "$run_file_size_limit"; then
- echo "ulimit file size setting failed"
+ err_echo "ulimit file size setting failed"
fi
echo "${test_dir}: running..." 1>&2
"./${run}" $run_args "$@" 2>&1
@@ -720,7 +753,7 @@
if [ "$checker_exit" = "0" ]; then
good="yes"
fi
- echo "checker exit status: $checker_exit" 1>&2
+ err_echo "checker exit status: $checker_exit"
else
good="yes"
fi
@@ -732,7 +765,7 @@
build_exit="$?"
if [ "$build_exit" = '0' ]; then
if ! ulimit -S "$run_file_size_limit"; then
- echo "ulimit file size setting failed"
+ err_echo "ulimit file size setting failed"
fi
echo "${test_dir}: running..." 1>&2
"./${run}" $run_args "$@" >"$output" 2>&1
@@ -745,8 +778,8 @@
sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
good="yes"
else
- cat "$build_output" 1>&2
- echo "build exit status: $build_exit" 1>&2
+ cat "$build_output" 1>&${real_stderr} 1>&2
+ err_echo "build exit status: $build_exit"
fi
elif [ "$build_only" = "yes" ]; then
good="yes"
@@ -758,7 +791,7 @@
diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
if [ "$?" '!=' "0" ]; then
good="no"
- echo "BUILD FAILED For ${TEST_NAME}"
+ err_echo "BUILD FAILED For ${TEST_NAME}"
fi
fi
# Clean up extraneous files that are not used by tests.
@@ -769,13 +802,13 @@
build_exit="$?"
if [ "$build_exit" = '0' ]; then
if ! ulimit -S "$run_file_size_limit"; then
- echo "ulimit file size setting failed"
+ err_echo "ulimit file size setting failed"
fi
echo "${test_dir}: running..." 1>&2
"./${run}" $run_args "$@" >"$output" 2>&1
run_exit="$?"
if [ "$run_exit" != "0" ]; then
- echo "run exit status: $run_exit" 1>&2
+ err_echo "run exit status: $run_exit"
good_run="no"
elif [ "$run_checker" = "yes" ]; then
if [ "$target_mode" = "yes" ]; then
@@ -784,7 +817,7 @@
"$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
checker_exit="$?"
if [ "$checker_exit" != "0" ]; then
- echo "checker exit status: $checker_exit" 1>&2
+ err_echo "checker exit status: $checker_exit"
good_run="no"
else
good_run="yes"
@@ -831,7 +864,7 @@
echo ' '
fi
-) 1>&2
+) 2>&${real_stderr} 1>&2
# Clean up test files.
if [ "$always_clean" = "yes" -o "$good" = "yes" ] && [ "$never_clean" = "no" ]; then
@@ -859,6 +892,6 @@
fi
fi
-) 1>&2
+) 2>&${real_stderr} 1>&2
exit 1