1// Copyright 2016 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include <threads.h> 6#include <unittest/unittest.h> 7#include <stdbool.h> 8#include <stdint.h> 9 10#include <zircon/thread_annotations.h> 11 12static mtx_t big_lock; 13 14int block_forever(void *arg) TA_ACQ(&big_lock) { 15 mtx_lock(&big_lock); 16 return 0; 17} 18 19bool mutex_block(void) TA_ACQ(&big_lock) { 20 BEGIN_TEST; 21 mtx_init(&big_lock, mtx_plain); 22 mtx_lock(&big_lock); 23 24 thrd_t thread; 25 thrd_create_with_name(&thread, block_forever, NULL, "block_forever"); 26 thrd_detach(thread); 27 END_TEST; 28} 29 30BEGIN_TEST_CASE(hard_to_exit) 31RUN_TEST(mutex_block) 32END_TEST_CASE(hard_to_exit) 33 34int main(int argc, char** argv) { 35 return unittest_run_all_tests(argc, argv) ? 0 : -1; 36} 37