summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-09-17 20:36:46 -0700
committerElliott Hughes <enh@google.com>2014-09-17 20:36:46 -0700
commit6fad0fc09c48a441600cfd749b00aff1c11039be (patch)
tree322ef1bc1c4f06a7a5a452e32fdd7efb008c8f97
parent95060c896455b6975733bd135bab61497000e7df (diff)
downloadextras-6fad0fc09c48a441600cfd749b00aff1c11039be.tar.gz
Remove some obviously useless tests (and fix the others so they build).
Some of these tests are stupid (hello_world.cpp), others are already replaced by more complete tests in bionic (test_cpu_set.cpp). Change-Id: Ie6d2723b049b4e9bb1b98ae0166be2c19551fdd0
-rw-r--r--tests/bionic/libc/Android.mk4
-rw-r--r--tests/bionic/libc/bionic/test_pthread_cond.c10
-rw-r--r--tests/bionic/libc/bionic/test_pthread_create.c30
-rw-r--r--tests/bionic/libc/common/hello_world.cpp8
-rw-r--r--tests/bionic/libc/common/test_clock.c56
-rw-r--r--tests/bionic/libc/common/test_cpu_set.c225
-rw-r--r--tests/bionic/libc/common/test_pthread_cleanup_push.c17
-rw-r--r--tests/bionic/libc/common/test_pthread_join.c8
-rw-r--r--tests/bionic/libc/other/test_vfprintf_leak.c55
9 files changed, 18 insertions, 395 deletions
diff --git a/tests/bionic/libc/Android.mk b/tests/bionic/libc/Android.mk
index 1e64591d..3fc3c399 100644
--- a/tests/bionic/libc/Android.mk
+++ b/tests/bionic/libc/Android.mk
@@ -61,8 +61,6 @@ endef
# First, the tests in 'common'
sources := \
- common/test_clock.c \
- common/test_cpu_set.c \
common/test_executable_destructor.c \
common/test_getaddrinfo.c \
common/test_gethostbyname.c \
@@ -130,7 +128,6 @@ sources := \
bionic/test_getgrouplist.c \
bionic/test_netinet_icmp.c \
bionic/test_pthread_cond.c \
- bionic/test_pthread_create.c \
bionic/test_setjmp.c \
$(call device-test, $(sources))
@@ -139,7 +136,6 @@ $(call device-test, $(sources))
sources := \
other/test_sysconf.c \
- other/test_vfprintf_leak.c \
$(call device-test, $(sources))
diff --git a/tests/bionic/libc/bionic/test_pthread_cond.c b/tests/bionic/libc/bionic/test_pthread_cond.c
index 26746fa7..6b13d77f 100644
--- a/tests/bionic/libc/bionic/test_pthread_cond.c
+++ b/tests/bionic/libc/bionic/test_pthread_cond.c
@@ -12,7 +12,7 @@ static pthread_mutex_t test_lock = PTHREAD_MUTEX_INITIALIZER;
static void *
thread1_func(void* arg)
{
- printf("Thread 1 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid());
+ printf("Thread 1 (arg=%p tid=%d) entered.\n", arg, gettid());
printf("1 waiting for cond1\n");
pthread_mutex_lock(&test_lock);
pthread_cond_wait(&cond1, &test_lock );
@@ -24,7 +24,7 @@ thread1_func(void* arg)
static void *
thread2_func(void* arg)
{
- printf("Thread 2 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid());
+ printf("Thread 2 (arg=%p tid=%d) entered.\n", arg, gettid());
printf("2 waiting for cond2\n");
pthread_mutex_lock(&test_lock);
pthread_cond_wait(&cond2, &test_lock );
@@ -37,7 +37,7 @@ thread2_func(void* arg)
static void *
thread3_func(void* arg)
{
- printf("Thread 3 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid());
+ printf("Thread 3 (arg=%p tid=%d) entered.\n", arg, gettid());
printf("3 waiting for cond1\n");
pthread_mutex_lock(&test_lock);
pthread_cond_wait(&cond1, &test_lock );
@@ -54,7 +54,7 @@ thread3_func(void* arg)
static void *
thread4_func(void* arg)
{
- printf("Thread 4 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid());
+ printf("Thread 4 (arg=%p tid=%d) entered.\n", arg, gettid());
printf("4 Sleeping\n");
sleep(5);
@@ -64,7 +64,7 @@ thread4_func(void* arg)
return 0;
}
-int main(int argc, const char *argv[])
+int main(int argc __unused, const char *argv[] __unused)
{
pthread_t t[4];
diff --git a/tests/bionic/libc/bionic/test_pthread_create.c b/tests/bionic/libc/bionic/test_pthread_create.c
deleted file mode 100644
index edac0ff1..00000000
--- a/tests/bionic/libc/bionic/test_pthread_create.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-
-static void *
-thread1_func(void* arg)
-{
- printf("Thread 1 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid());
- return 0;
-}
-
-static void *
-thread2_func(void* arg)
-{
- printf("thread 2 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid());
- return 1;
-}
-
-
-int main( void )
-{
- pthread_t t1, t2;
-
- pthread_create( &t1, NULL, thread1_func, (void *)1 );
-
- pthread_join(t1, NULL);
-
- printf("OK\n");
- return 0;
-}
diff --git a/tests/bionic/libc/common/hello_world.cpp b/tests/bionic/libc/common/hello_world.cpp
deleted file mode 100644
index 0578d7d8..00000000
--- a/tests/bionic/libc/common/hello_world.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <iostream>
-using namespace std;
-
-int main()
-{
- cout << "Hello World" << endl;
- return 0;
-}
diff --git a/tests/bionic/libc/common/test_clock.c b/tests/bionic/libc/common/test_clock.c
deleted file mode 100644
index 6d3752e3..00000000
--- a/tests/bionic/libc/common/test_clock.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// Minimal test program for clock
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-
-// this thread soaks the CPU so that clock() function will advance
-void *cpu_hog(void *arg)
-{
- for (;;) {
- // the system call should not be optimized away by the compiler
- (void) getpid();
- }
-}
-
-int main(int argc, char **argv)
-{
- pthread_t thread;
- clock_t ticks10, ticks15;
-
- // do not call clock() here so we can test initialization
-
- // soak the CPU for 10 seconds, then read clock
- pthread_create(&thread, NULL, cpu_hog, NULL);
- sleep(10);
- ticks10 = clock();
-
- // soak the CPU for 5 more seconds, then read clock
- sleep(5);
- ticks15 = clock();
-
- // print the results
- printf("CLOCKS_PER_SEC = %ld ticks/sec\n", (clock_t) CLOCKS_PER_SEC);
- printf("At 10 secs clock=%lu, at 15 secs clock=%lu\n", ticks10, ticks15);
-
- // exit could wait for the other thread to complete
- _exit(EXIT_SUCCESS);
-}
diff --git a/tests/bionic/libc/common/test_cpu_set.c b/tests/bionic/libc/common/test_cpu_set.c
deleted file mode 100644
index bb26492f..00000000
--- a/tests/bionic/libc/common/test_cpu_set.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2010 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 _GNU_SOURCE 1
-#include <sched.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int failures = 0;
-
-#define TEST_INT_EQ(cond,exp) \
- do {\
- int _cond = (cond); \
- int _exp = (exp); \
- if ((_cond) != (_exp)) {\
- fprintf(stderr, "Assertion failure:%s:%d: '%s' returned %d (%d expected)\n", \
- __FUNCTION__, __LINE__, #cond, _cond, _exp);\
- }\
- }while(0)
-
-#define T(cond) \
- do {\
- if (!(cond)) {\
- fprintf(stderr,"Assertion failure:%s:%d: %s is not TRUE\n",\
- __FUNCTION__, __LINE__, #cond);\
- failures++;\
- }\
- } while(0)
-
-#define F(cond) \
- do {\
- if (!!(cond)) {\
- fprintf(stderr,"Assertion failure:%s:%d: %s is not FALSE\n",\
- __FUNCTION__, __LINE__, #cond);\
- failures++;\
- }\
- } while (0)
-
-
-static void
-test_1(cpu_set_t* set)
-{
- cpu_set_t other[1];
- int nn, nnMax = CPU_SETSIZE;
-
- memset(other, 0, sizeof *other);
- TEST_INT_EQ(CPU_COUNT(other),0);
-
- /* First, cheeck against zero */
- CPU_ZERO(set);
- TEST_INT_EQ(CPU_COUNT(set),0);
- T(CPU_EQUAL(set, other));
- T(CPU_EQUAL(other, set));
-
- for (nn = 0; nn < nnMax; nn++)
- F(CPU_ISSET(nn, set));
-
- /* Check individual bits */
- for (nn = 0; nn < nnMax; nn++) {
- int mm;
- CPU_SET(nn, set);
- TEST_INT_EQ(CPU_COUNT(set),1);
- for (mm = 0; mm < nnMax; mm++) {
- T(CPU_ISSET(mm, set) == (mm == nn));
- }
- CPU_CLR(nn, set);
- T(CPU_EQUAL(set, other));
- }
-
- /* Check cumulative bits, incrementing */
- for (nn = 0; nn < nnMax; nn++) {
- int mm;
- CPU_SET(nn, set);
- TEST_INT_EQ(CPU_COUNT(set), nn+1);
- for (mm = 0; mm < nnMax; mm++) {
- T(CPU_ISSET(mm, set) == (mm <= nn));
- }
- }
-
- /* Check individual clear bits */
- for (nn = 0; nn < nnMax; nn++) {
- int mm;
- CPU_CLR(nn, set);
- TEST_INT_EQ(CPU_COUNT(set), nnMax-1);
- for (mm = 0; mm < nnMax; mm++) {
- T(CPU_ISSET(mm, set) == (mm != nn));
- }
- CPU_SET(nn, set);
- }
-
- /* Check cumulative bits, decrementing */
- for (nn = nnMax-1; nn >= 0; nn--) {
- int mm;
- CPU_CLR(nn, set);
- TEST_INT_EQ(CPU_COUNT(set), nn);
- for (mm = 0; mm < nnMax; mm++) {
- T(CPU_ISSET(mm, set) == (mm < nn));
- }
- }
- T(CPU_EQUAL(set, other));
-}
-
-static void
-test_1_s(size_t setsize, cpu_set_t* set)
-{
- int nn, nnMax;
- cpu_set_t* other;
-
- /* First, cheeck against zero */
- other = calloc(1,setsize);
- TEST_INT_EQ(CPU_COUNT(other),0);
- CPU_ZERO_S(setsize, set);
- T(CPU_EQUAL_S(setsize, set, other));
- T(CPU_EQUAL_S(setsize, other, set));
-
- nnMax = setsize*8;
- for (nn = 0; nn < nnMax; nn++)
- F(CPU_ISSET_S(nn, setsize, set));
-
- /* Check individual bits */
- for (nn = 0; nn < nnMax; nn++) {
- int mm;
- CPU_SET_S(nn, setsize, set);
- TEST_INT_EQ(CPU_COUNT_S(setsize, set), 1);
- for (mm = 0; mm < nnMax; mm++) {
- T(CPU_ISSET_S(mm, setsize, set) == (mm == nn));
- }
- CPU_CLR_S(nn, setsize, set);
- T(CPU_EQUAL_S(setsize, set, other));
- }
-
- /* Check cumulative bits, incrementing */
- for (nn = 0; nn < nnMax; nn++) {
- int mm;
- CPU_SET_S(nn, setsize, set);
- TEST_INT_EQ(CPU_COUNT_S(setsize, set), nn+1);
- for (mm = 0; mm < nnMax; mm++) {
- T(CPU_ISSET_S(mm, setsize, set) == (mm <= nn));
- }
- }
-
- /* Check individual clear bits */
- for (nn = 0; nn < nnMax; nn++) {
- int mm;
- CPU_CLR_S(nn, setsize, set);
- TEST_INT_EQ(CPU_COUNT_S(setsize, set), nnMax-1);
- for (mm = 0; mm < nnMax; mm++) {
- T(CPU_ISSET_S(mm, setsize, set) == (mm != nn));
- }
- CPU_SET_S(nn, setsize, set);
- }
-
- /* Check cumulative bits, decrementing */
- for (nn = nnMax-1; nn >= 0; nn--) {
- int mm;
- CPU_CLR_S(nn, setsize, set);
- TEST_INT_EQ(CPU_COUNT_S(setsize, set), nn);
- for (mm = 0; mm < nnMax; mm++) {
- T(CPU_ISSET_S(mm, setsize, set) == (mm < nn));
- }
- }
- T(CPU_EQUAL_S(setsize, set, other));
-
- free(other);
-}
-
-
-int main(void)
-{
- cpu_set_t set0;
- int cpu;
- test_1(&set0);
- test_1_s(sizeof(set0), &set0);
-
- size_t count;
- for (count = 32; count <= 1024; count *= 2) {
- cpu_set_t* set = CPU_ALLOC(count);
- test_1_s(count/8, set);
- CPU_FREE(set);
- }
-
- T((cpu = sched_getcpu()) >= 0);
-
- int ret;
- TEST_INT_EQ((ret = sched_getaffinity(getpid(), sizeof(cpu_set_t), &set0)), 0);
-
- CPU_ZERO(&set0);
- CPU_SET(cpu, &set0);
-
- TEST_INT_EQ((ret = sched_setaffinity(getpid(), sizeof(cpu_set_t), &set0)), 0);
-
- if (failures == 0) {
- printf("OK\n");
- return 0;
- } else {
- printf("KO: %d failures\n", failures);
- return 1;
- }
-}
diff --git a/tests/bionic/libc/common/test_pthread_cleanup_push.c b/tests/bionic/libc/common/test_pthread_cleanup_push.c
index 87634adf..f2afa14a 100644
--- a/tests/bionic/libc/common/test_pthread_cleanup_push.c
+++ b/tests/bionic/libc/common/test_pthread_cleanup_push.c
@@ -25,14 +25,15 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#include <pthread.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-
-#define MAGIC1 0xcafebabeU
-#define MAGIC2 0x8badf00dU
-#define MAGIC3 0x12345667U
+#define MAGIC1 (void*)0xcafebabeU
+#define MAGIC2 (void*)0x8badf00dU
+#define MAGIC3 (void*)0x12345667U
static int g_ok1 = 0;
static int g_ok2 = 0;
@@ -41,7 +42,7 @@ static int g_ok3 = 0;
static void
cleanup1( void* arg )
{
- if ((unsigned)arg != MAGIC1)
+ if (arg != MAGIC1)
g_ok1 = -1;
else
g_ok1 = +1;
@@ -50,7 +51,7 @@ cleanup1( void* arg )
static void
cleanup2( void* arg )
{
- if ((unsigned)arg != MAGIC2) {
+ if (arg != MAGIC2) {
g_ok2 = -1;
} else
g_ok2 = +1;
@@ -59,7 +60,7 @@ cleanup2( void* arg )
static void
cleanup3( void* arg )
{
- if ((unsigned)arg != MAGIC3)
+ if (arg != MAGIC3)
g_ok3 = -1;
else
g_ok3 = +1;
@@ -83,7 +84,7 @@ thread1_func( void* arg )
return NULL;
}
-static int test( int do_exit )
+static int test( uintptr_t do_exit )
{
pthread_t t;
diff --git a/tests/bionic/libc/common/test_pthread_join.c b/tests/bionic/libc/common/test_pthread_join.c
index 4fe2561a..3b6e24f2 100644
--- a/tests/bionic/libc/common/test_pthread_join.c
+++ b/tests/bionic/libc/common/test_pthread_join.c
@@ -30,7 +30,7 @@
#include <unistd.h>
static void*
-thread1_func(void* arg)
+thread1_func(void* arg __attribute__((unused)))
{
usleep( 2000*1000 );
printf("thread 1 exited\n");
@@ -44,19 +44,19 @@ thread2_func(void* arg)
void* result;
pthread_join(t1, &result);
- printf("thread2 received code %08x from thread1\n", (int)result);
+ printf("thread2 received code %p from thread1\n", result);
return NULL;
}
static void*
-thread3_func(void* arg)
+thread3_func(void* arg __attribute__((unused)))
{
pthread_t t1 = (pthread_t)arg;
void* result;
pthread_join(t1, &result);
- printf("thread3 received code %08x from thread1\n", (int)result);
+ printf("thread3 received code %p from thread1\n", result);
return NULL;
}
diff --git a/tests/bionic/libc/other/test_vfprintf_leak.c b/tests/bionic/libc/other/test_vfprintf_leak.c
deleted file mode 100644
index 4e94c51b..00000000
--- a/tests/bionic/libc/other/test_vfprintf_leak.c
+++ /dev/null
@@ -1,55 +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.
- */
-/* this test is used to check that a memory-leak in vfprintf was fixed.
- * the initial code leaked heap memory each time a formatted double was printed
- */
-#include <stdio.h>
-
-extern size_t dlmalloc_footprint();
-
-int main(void)
-{
- size_t initial = dlmalloc_footprint();
- size_t final;
- char temp[64];
- int n;
-
- for (n = 0; n < 10000; n++)
- snprintf( temp, sizeof(temp), "%g", n*0.647287623 );
-
- final = dlmalloc_footprint();
- /* vfprintf uses temporary heap blocks to do the formatting, so */
- /* it's OK to have one page in there */
- if (final <= 4096) {
- printf( "OK: initial = %ld, final == %ld\n", (long)initial, (long)final );
- return 0;
- } else {
- fprintf(stderr, "KO: initial == %ld, final == %ld\n", (long)initial, (long)final );
- return 1;
- }
-}