Add FinalizerTimeoutMs argument, and respect it

Add -XX:FinalizerTimeoutMs commandline argument, and make it
available for libcore.

Add 1336-short-finalizer-timeout to test it. Blacklist it for
the cases in which 030-bad-finalizers was known not to work,
since it's largely a clone. Disable it for gcstress, since timeout
margins are tight.

Increase timeout in 030-bad-finalizers due to gcstress issues.

Use the result in 004-NativeAllocations and 030-bad-finalizers
to avoid timeouts. Make 004-NativeAllocations more proactive in
avoiding timeout.

This is intended as a replacement for aosp/836642 .

Bug: 129350738
Bug: 68792448
Test: Boot AOSP, TreeHugger
Change-Id: I9aef9c9bacb7e8d851bd2c879ed9fb5b596abc60
diff --git a/test/1336-short-finalizer-timeout/run b/test/1336-short-finalizer-timeout/run
new file mode 100755
index 0000000..3e33524
--- /dev/null
+++ b/test/1336-short-finalizer-timeout/run
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Copyright 2017 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.
+
+# Squash the exit status and put it in expected
+./default-run "$@" --runtime-option -XX:FinalizerTimeoutMs=500
+echo "exit status:" $?