summaryrefslogtreecommitdiff
path: root/runtime/runtime_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/runtime_test.cc')
-rw-r--r--runtime/runtime_test.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/runtime/runtime_test.cc b/runtime/runtime_test.cc
index 282e43071e..3fe281bd5f 100644
--- a/runtime/runtime_test.cc
+++ b/runtime/runtime_test.cc
@@ -14,10 +14,13 @@
* limitations under the License.
*/
+#include "common_runtime_test.h"
+
+#include <thread>
+
#include "android-base/logging.h"
#include "base/locks.h"
#include "base/mutex.h"
-#include "common_runtime_test.h"
#include "runtime.h"
#include "thread-current-inl.h"
@@ -54,4 +57,22 @@ TEST_F(RuntimeTest, AbortWithThreadSuspendCountLockHeld) {
}, kDeathRegex);
}
+TEST_F(RuntimeTest, AbortFromUnattachedThread) {
+ // This assumes the test is run single-threaded: do not start the runtime to avoid daemon threads.
+
+ constexpr const char* kDeathRegex = "Going down";
+ ASSERT_EXIT({
+ // The regex only works if we can ensure output goes to stderr.
+ android::base::SetLogger(android::base::StderrLogger);
+
+ Thread::Current()->TransitionFromSuspendedToRunnable();
+ runtime_->Start();
+
+ std::thread t([]() {
+ LOG(FATAL) << "Going down";
+ });
+ t.join();
+ }, ::testing::KilledBySignal(SIGABRT), kDeathRegex);
+}
+
} // namespace art