From e3b5cf69b08286bd808048051c58f8b225595a28 Mon Sep 17 00:00:00 2001 From: Yongqin Liu Date: Fri, 24 Oct 2014 15:03:06 +0800 Subject: bionic libc test: clean up pthread mutex type test clean up the pthread mutex types related tests implemented in tests/bionic/libc/bionic/test_mutex.c and related settings, since the tests will be migrated into file bionic/tests/pthread_test.cpp Change-Id: Icbbac40c42de7df49ff19bae54d71b455cafb987 Signed-off-by: Yongqin Liu --- tests/bionic/libc/Android.mk | 1 - tests/bionic/libc/bionic/test_mutex.c | 109 ---------------------------------- 2 files changed, 110 deletions(-) delete mode 100644 tests/bionic/libc/bionic/test_mutex.c (limited to 'tests') diff --git a/tests/bionic/libc/Android.mk b/tests/bionic/libc/Android.mk index f52ff854..07375d1a 100644 --- a/tests/bionic/libc/Android.mk +++ b/tests/bionic/libc/Android.mk @@ -79,7 +79,6 @@ $(call device-test, $(sources)) # Second, the Bionic-specific tests sources := \ - bionic/test_mutex.c \ bionic/test_cond.c \ bionic/test_getgrouplist.c \ bionic/test_netinet_icmp.c \ diff --git a/tests/bionic/libc/bionic/test_mutex.c b/tests/bionic/libc/bionic/test_mutex.c deleted file mode 100644 index 02257ba3..00000000 --- a/tests/bionic/libc/bionic/test_mutex.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#define __USE_UNIX98 1 /* necessary to define pthread_mutexattr_set/gettype in Linux GLIBC headers. doh ! */ -#include -#include -#include -#include -#include - -static void panic( const char* format, ... ) -{ - va_list args; - va_start(args, format); - vfprintf(stderr, format, args); - va_end(args); - exit(1); -} - -#define assert(cond) do { if ( !(cond) ) panic( "%s:%d: assertion failure: %s\n", __FILE__, __LINE__, #cond ); } while (0) - -#define expect(call,result) \ - do { \ - int ret = (call); \ - if (ret != (result)) { \ - panic( "%s:%d: call returned %d instead of %d: %s\n", \ - __FILE__, __LINE__, ret, (result), #call ); \ - } \ - } while (0) - - -int main( void ) -{ - pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - pthread_mutexattr_t attr; - int attr_type; - - expect( pthread_mutexattr_init( &attr ), 0 ); - - expect( pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_NORMAL ), 0 ); - expect( pthread_mutexattr_gettype( &attr, &attr_type ), 0 ); - assert( attr_type == PTHREAD_MUTEX_NORMAL ); - - expect( pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK ), 0 ); - expect( pthread_mutexattr_gettype( &attr, &attr_type ), 0 ); - assert( attr_type == PTHREAD_MUTEX_ERRORCHECK ); - - expect( pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE ), 0 ); - expect( pthread_mutexattr_gettype( &attr, &attr_type ), 0 ); - assert( attr_type == PTHREAD_MUTEX_RECURSIVE ); - - /* standard mutexes */ - expect( pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_NORMAL ), 0 ); - expect( pthread_mutex_init( &lock, &attr ), 0 ); - expect( pthread_mutex_lock( &lock ), 0 ); - expect( pthread_mutex_unlock( &lock ), 0 ); - expect( pthread_mutex_destroy( &lock ), 0 ); - - /* error-check mutex */ - expect( pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK ), 0 ); - expect( pthread_mutex_init( &lock, &attr ), 0 ); - expect( pthread_mutex_lock( &lock ), 0 ); - expect( pthread_mutex_lock( &lock ), EDEADLK ); - expect( pthread_mutex_unlock( &lock ), 0 ); - expect( pthread_mutex_trylock( &lock ), 0 ); - expect( pthread_mutex_trylock( &lock ), EDEADLK ); - expect( pthread_mutex_unlock( &lock ), 0 ); - expect( pthread_mutex_unlock( &lock ), EPERM ); - expect( pthread_mutex_destroy( &lock ), 0 ); - - /* recursive mutex */ - expect( pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE ), 0 ); - expect( pthread_mutex_init( &lock, &attr ), 0 ); - expect( pthread_mutex_lock( &lock ), 0 ); - expect( pthread_mutex_lock( &lock ), 0 ); - expect( pthread_mutex_unlock( &lock ), 0 ); - expect( pthread_mutex_unlock( &lock ), 0 ); - expect( pthread_mutex_trylock( &lock ), 0 ); - expect( pthread_mutex_unlock( &lock ), 0 ); - expect( pthread_mutex_unlock( &lock ), EPERM ); - expect( pthread_mutex_destroy( &lock ), 0 ); - - printf( "ok\n" ); - return 0; -} -- cgit v1.2.3