[libcxxabi] r226691 - Rename all of the tests in preparation for merging lit configs with libcxx
Jonathan Roelofs
jonathan at codesourcery.com
Wed Jan 21 11:05:38 PST 2015
Removed: libcxxabi/trunk/test/test_exception_storage.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_storage.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/test_exception_storage.cpp (original)
+++ libcxxabi/trunk/test/test_exception_storage.cpp (removed)
@@ -1,87 +0,0 @@
-//===-------------------- test_exception_storage.cpp ----------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "../src/config.h"
-
-#include <cstdlib>
-#include <algorithm>
-#include <iostream>
-#if !LIBCXXABI_HAS_NO_THREADS
-# include <pthread.h>
-#endif
-#include <unistd.h>
-
-#include "../src/cxa_exception.hpp"
-
-typedef __cxxabiv1::__cxa_eh_globals globals_t ;
-
-void *thread_code (void *parm) {
- size_t *result = (size_t *) parm;
- globals_t *glob1, *glob2;
-
- glob1 = __cxxabiv1::__cxa_get_globals ();
- if ( NULL == glob1 )
- std::cerr << "Got null result from __cxa_get_globals" << std::endl;
-
- glob2 = __cxxabiv1::__cxa_get_globals_fast ();
- if ( glob1 != glob2 )
- std::cerr << "Got different globals!" << std::endl;
-
- *result = (size_t) glob1;
- sleep ( 1 );
- return parm;
- }
-
-#if !LIBCXXABI_HAS_NO_THREADS
-#define NUMTHREADS 10
-size_t thread_globals [ NUMTHREADS ] = { 0 };
-pthread_t threads [ NUMTHREADS ];
-#endif
-
-void print_sizes ( size_t *first, size_t *last ) {
- std::cout << "{ " << std::hex;
- for ( size_t *iter = first; iter != last; ++iter )
- std::cout << *iter << " ";
- std::cout << "}" << std::dec << std::endl;
- }
-
-int main ( int argc, char *argv [] ) {
- int retVal = 0;
-
-#if LIBCXXABI_HAS_NO_THREADS
- size_t thread_globals;
- // Check that __cxa_get_globals() is not NULL.
- if (thread_code(&thread_globals) == 0) {
- retVal = 1;
- }
-#else
-// Make the threads, let them run, and wait for them to finish
- for ( int i = 0; i < NUMTHREADS; ++i )
- pthread_create( threads + i, NULL, thread_code, (void *) (thread_globals + i));
- for ( int i = 0; i < NUMTHREADS; ++i )
- pthread_join ( threads [ i ], NULL );
-
- for ( int i = 0; i < NUMTHREADS; ++i )
- if ( 0 == thread_globals [ i ] ) {
- std::cerr << "Thread #" << i << " had a zero global" << std::endl;
- retVal = 1;
- }
-
-// print_sizes ( thread_globals, thread_globals + NUMTHREADS );
- std::sort ( thread_globals, thread_globals + NUMTHREADS );
- for ( int i = 1; i < NUMTHREADS; ++i )
- if ( thread_globals [ i - 1 ] == thread_globals [ i ] ) {
- std::cerr << "Duplicate thread globals (" << i-1 << " and " << i << ")" << std::endl;
- retVal = 2;
- }
-// print_sizes ( thread_globals, thread_globals + NUMTHREADS );
-
-#endif
- return retVal;
- }
Removed: libcxxabi/trunk/test/test_fallback_malloc.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_fallback_malloc.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/test_fallback_malloc.cpp (original)
+++ libcxxabi/trunk/test/test_fallback_malloc.cpp (removed)
@@ -1,189 +0,0 @@
-//===--------------------- test_fallback_malloc.cpp -----------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <iostream>
-#include <deque>
-
-#include <pthread.h>
-
-typedef std::deque<void *> container;
-
-// #define DEBUG_FALLBACK_MALLOC
-#define INSTRUMENT_FALLBACK_MALLOC
-#include "../src/fallback_malloc.ipp"
-
-container alloc_series ( size_t sz ) {
- container ptrs;
- void *p;
-
- while ( NULL != ( p = fallback_malloc ( sz )))
- ptrs.push_back ( p );
- return ptrs;
- }
-
-container alloc_series ( size_t sz, float growth ) {
- container ptrs;
- void *p;
-
- while ( NULL != ( p = fallback_malloc ( sz ))) {
- ptrs.push_back ( p );
- sz *= growth;
- }
-
- return ptrs;
- }
-
-container alloc_series ( const size_t *first, size_t len ) {
- container ptrs;
- const size_t *last = first + len;
- void * p;
-
- for ( const size_t *iter = first; iter != last; ++iter ) {
- if ( NULL == (p = fallback_malloc ( *iter )))
- break;
- ptrs.push_back ( p );
- }
-
- return ptrs;
- }
-
-void *pop ( container &c, bool from_end ) {
- void *ptr;
- if ( from_end ) {
- ptr = c.back ();
- c.pop_back ();
- }
- else {
- ptr = c.front ();
- c.pop_front ();
- }
- return ptr;
- }
-
-void exhaustion_test1 () {
- container ptrs;
-
- init_heap ();
- std::cout << "Constant exhaustion tests" << std::endl;
-
-// Delete in allocation order
- ptrs = alloc_series ( 32 );
- std::cout << "Allocated " << ptrs.size () << " 32 byte chunks" << std::endl;
- print_free_list ();
- for ( container::iterator iter = ptrs.begin (); iter != ptrs.end (); ++iter )
- fallback_free ( *iter );
- print_free_list ();
- std::cout << "----" << std::endl;
-
-// Delete in reverse order
- ptrs = alloc_series ( 32 );
- std::cout << "Allocated " << ptrs.size () << " 32 byte chunks" << std::endl;
- for ( container::reverse_iterator iter = ptrs.rbegin (); iter != ptrs.rend (); ++iter )
- fallback_free ( *iter );
- print_free_list ();
- std::cout << "----" << std::endl;
-
-// Alternate deletions
- ptrs = alloc_series ( 32 );
- std::cout << "Allocated " << ptrs.size () << " 32 byte chunks" << std::endl;
- while ( ptrs.size () > 0 )
- fallback_free ( pop ( ptrs, ptrs.size () % 1 == 1 ));
- print_free_list ();
- }
-
-void exhaustion_test2 () {
- container ptrs;
- init_heap ();
-
- std::cout << "Growing exhaustion tests" << std::endl;
-
-// Delete in allocation order
- ptrs = alloc_series ( 32, 1.5 );
- std::cout << "Allocated " << ptrs.size () << " { 32, 48, 72, 108, 162 ... } byte chunks" << std::endl;
- print_free_list ();
- for ( container::iterator iter = ptrs.begin (); iter != ptrs.end (); ++iter )
- fallback_free ( *iter );
- print_free_list ();
- std::cout << "----" << std::endl;
-
-// Delete in reverse order
- print_free_list ();
- ptrs = alloc_series ( 32, 1.5 );
- std::cout << "Allocated " << ptrs.size () << " { 32, 48, 72, 108, 162 ... } byte chunks" << std::endl;
- for ( container::reverse_iterator iter = ptrs.rbegin (); iter != ptrs.rend (); ++iter )
- fallback_free ( *iter );
- print_free_list ();
- std::cout << "----" << std::endl;
-
-// Alternate deletions
- ptrs = alloc_series ( 32, 1.5 );
- std::cout << "Allocated " << ptrs.size () << " { 32, 48, 72, 108, 162 ... } byte chunks" << std::endl;
- while ( ptrs.size () > 0 )
- fallback_free ( pop ( ptrs, ptrs.size () % 1 == 1 ));
- print_free_list ();
-
- }
-
-void exhaustion_test3 () {
- const size_t allocs [] = { 124, 60, 252, 60, 4 };
- container ptrs;
- init_heap ();
-
- std::cout << "Complete exhaustion tests" << std::endl;
-
-// Delete in allocation order
- ptrs = alloc_series ( allocs, sizeof ( allocs ) / sizeof ( allocs[0] ));
- std::cout << "Allocated " << ptrs.size () << " chunks" << std::endl;
- print_free_list ();
- for ( container::iterator iter = ptrs.begin (); iter != ptrs.end (); ++iter )
- fallback_free ( *iter );
- print_free_list ();
- std::cout << "----" << std::endl;
-
-// Delete in reverse order
- print_free_list ();
- ptrs = alloc_series ( allocs, sizeof ( allocs ) / sizeof ( allocs[0] ));
- std::cout << "Allocated " << ptrs.size () << " chunks" << std::endl;
- for ( container::reverse_iterator iter = ptrs.rbegin (); iter != ptrs.rend (); ++iter )
- fallback_free ( *iter );
- print_free_list ();
- std::cout << "----" << std::endl;
-
-// Alternate deletions
- ptrs = alloc_series ( allocs, sizeof ( allocs ) / sizeof ( allocs[0] ));
- std::cout << "Allocated " << ptrs.size () << " chunks" << std::endl;
- while ( ptrs.size () > 0 )
- fallback_free ( pop ( ptrs, ptrs.size () % 1 == 1 ));
- print_free_list ();
-
- }
-
-
-int main ( int argc, char *argv [] ) {
- print_free_list ();
-
- char *p = (char *) fallback_malloc ( 1024 ); // too big!
- std::cout << "fallback_malloc ( 1024 ) --> " << (unsigned long ) p << std::endl;
- print_free_list ();
-
- p = (char *) fallback_malloc ( 32 );
- std::cout << "fallback_malloc ( 32 ) --> " << (unsigned long) (p - heap) << std::endl;
- if ( !is_fallback_ptr ( p ))
- std::cout << "### p is not a fallback pointer!!" << std::endl;
-
- print_free_list ();
- fallback_free ( p );
- print_free_list ();
-
- std::cout << std::endl;
- exhaustion_test1 (); std::cout << std::endl;
- exhaustion_test2 (); std::cout << std::endl;
- exhaustion_test3 (); std::cout << std::endl;
- return 0;
- }
Removed: libcxxabi/trunk/test/test_guard.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_guard.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/test_guard.cpp (original)
+++ libcxxabi/trunk/test/test_guard.cpp (removed)
@@ -1,142 +0,0 @@
-//===----------------------------- test_guard.cpp -------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "../src/config.h"
-#include "cxxabi.h"
-
-#include <cassert>
-
-#if !LIBCXXABI_HAS_NO_THREADS
-#include <thread>
-#endif
-
-// Ensure that we initialize each variable once and only once.
-namespace test1 {
- static int run_count = 0;
- int increment() {
- ++run_count;
- return 0;
- }
- void helper() {
- static int a = increment();
- }
- void test() {
- static int a = increment();
- assert(run_count == 1);
- static int b = increment();
- assert(run_count == 2);
- helper();
- assert(run_count == 3);
- helper();
- assert(run_count == 3);
- }
-}
-
-// When initialization fails, ensure that we try to initialize it again next
-// time.
-namespace test2 {
- static int run_count = 0;
- int increment() {
- ++run_count;
- throw 0;
- }
- void helper() {
- try {
- static int a = increment();
- assert(0);
- } catch (...) {}
- }
- void test() {
- helper();
- assert(run_count == 1);
- helper();
- assert(run_count == 2);
- }
-}
-
-// Check that we can initialize a second value while initializing a first.
-namespace test3 {
- int zero() {
- return 0;
- }
-
- int one() {
- static int b = zero();
- return 0;
- }
-
- void test() {
- static int a = one();
- }
-}
-
-#if !LIBCXXABI_HAS_NO_THREADS
-// A simple thread test of two threads racing to initialize a variable. This
-// isn't guaranteed to catch any particular threading problems.
-namespace test4 {
- static int run_count = 0;
- int increment() {
- ++run_count;
- return 0;
- }
-
- void helper() {
- static int a = increment();
- }
-
- void test() {
- std::thread t1(helper), t2(helper);
- t1.join();
- t2.join();
- assert(run_count == 1);
- }
-}
-
-// Check that we don't re-initialize a static variable even when it's
-// encountered from two different threads.
-namespace test5 {
- static int run_count = 0;
- int zero() {
- ++run_count;
- return 0;
- }
-
- int one() {
- static int b = zero();
- return 0;
- }
-
- void another_helper() {
- static int a = one();
- }
-
- void helper() {
- static int a = one();
- std::thread t(another_helper);
- t.join();
- }
-
- void test() {
- std::thread t(helper);
- t.join();
- assert(run_count == 1);
- }
-}
-#endif /* LIBCXXABI_HAS_NO_THREADS */
-
-int main()
-{
- test1::test();
- test2::test();
- test3::test();
-#if !LIBCXXABI_HAS_NO_THREADS
- test4::test();
- test5::test();
-#endif
-}
Removed: libcxxabi/trunk/test/test_vector1.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_vector1.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/test_vector1.cpp (original)
+++ libcxxabi/trunk/test/test_vector1.cpp (removed)
@@ -1,264 +0,0 @@
-//===---------------------------- test_vector.cpp -------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "cxxabi.h"
-
-#include <iostream>
-#include <cstdlib>
-#include <cassert>
-
-// Wrapper routines
-void *my_alloc2 ( size_t sz ) {
- void *p = std::malloc ( sz );
-// std::printf ( "Allocated %ld bytes at %lx\n", sz, (unsigned long) p );
- return p;
- }
-
-void my_dealloc2 ( void *p ) {
-// std::printf ( "Freeing %lx\n", (unsigned long) p );
- std::free ( p );
- }
-
-void my_dealloc3 ( void *p, size_t sz ) {
-// std::printf ( "Freeing %lx (size %ld)\n", (unsigned long) p, sz );
- std::free ( p );
- }
-
-void my_construct ( void *p ) {
-// std::printf ( "Constructing %lx\n", (unsigned long) p );
- }
-
-void my_destruct ( void *p ) {
-// std::printf ( "Destructing %lx\n", (unsigned long) p );
- }
-
-int gCounter;
-void count_construct ( void *p ) { ++gCounter; }
-void count_destruct ( void *p ) { --gCounter; }
-
-
-int gConstructorCounter;
-int gConstructorThrowTarget;
-int gDestructorCounter;
-int gDestructorThrowTarget;
-void throw_construct ( void *p ) { if ( gConstructorCounter == gConstructorThrowTarget ) throw 1; ++gConstructorCounter; }
-void throw_destruct ( void *p ) { if ( ++gDestructorCounter == gDestructorThrowTarget ) throw 2; }
-
-#if __cplusplus >= 201103L
-# define CAN_THROW noexcept(false)
-#else
-# define CAN_THROW
-#endif
-
-struct vec_on_stack {
- void *storage;
- vec_on_stack () : storage ( __cxxabiv1::__cxa_vec_new ( 10, 40, 8, throw_construct, throw_destruct )) {}
- ~vec_on_stack () CAN_THROW {__cxxabiv1::__cxa_vec_delete ( storage, 40, 8, throw_destruct ); }
- };
-
-// Test calls with empty constructors and destructors
-int test_empty ( ) {
- void *one, *two, *three;
-
-// Try with no padding and no con/destructors
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 0, NULL, NULL );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 0, NULL, NULL, my_alloc2, my_dealloc2 );
- three = __cxxabiv1::__cxa_vec_new3( 10, 40, 0, NULL, NULL, my_alloc2, my_dealloc3 );
-
- __cxxabiv1::__cxa_vec_delete ( one, 40, 0, NULL );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 0, NULL, my_dealloc2 );
- __cxxabiv1::__cxa_vec_delete3( three, 40, 0, NULL, my_dealloc3 );
-
-// Try with no padding
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 0, my_construct, my_destruct );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 0, my_construct, my_destruct, my_alloc2, my_dealloc2 );
- three = __cxxabiv1::__cxa_vec_new3( 10, 40, 0, my_construct, my_destruct, my_alloc2, my_dealloc3 );
-
- __cxxabiv1::__cxa_vec_delete ( one, 40, 0, my_destruct );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 0, my_destruct, my_dealloc2 );
- __cxxabiv1::__cxa_vec_delete3( three, 40, 0, my_destruct, my_dealloc3 );
-
-// Padding and no con/destructors
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 8, NULL, NULL );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 8, NULL, NULL, my_alloc2, my_dealloc2 );
- three = __cxxabiv1::__cxa_vec_new3( 10, 40, 8, NULL, NULL, my_alloc2, my_dealloc3 );
-
- __cxxabiv1::__cxa_vec_delete ( one, 40, 8, NULL );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 8, NULL, my_dealloc2 );
- __cxxabiv1::__cxa_vec_delete3( three, 40, 8, NULL, my_dealloc3 );
-
-// Padding with con/destructors
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 8, my_construct, my_destruct );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 8, my_construct, my_destruct, my_alloc2, my_dealloc2 );
- three = __cxxabiv1::__cxa_vec_new3( 10, 40, 8, my_construct, my_destruct, my_alloc2, my_dealloc3 );
-
- __cxxabiv1::__cxa_vec_delete ( one, 40, 8, my_destruct );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 8, my_destruct, my_dealloc2 );
- __cxxabiv1::__cxa_vec_delete3( three, 40, 8, my_destruct, my_dealloc3 );
-
- return 0;
- }
-
-// Make sure the constructors and destructors are matched
-int test_counted ( ) {
- int retVal = 0;
- void *one, *two, *three;
-
-// Try with no padding
- gCounter = 0;
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 0, count_construct, count_destruct );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 0, count_construct, count_destruct, my_alloc2, my_dealloc2 );
- three = __cxxabiv1::__cxa_vec_new3( 10, 40, 0, count_construct, count_destruct, my_alloc2, my_dealloc3 );
-
- __cxxabiv1::__cxa_vec_delete ( one, 40, 0, count_destruct );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 0, count_destruct, my_dealloc2 );
- __cxxabiv1::__cxa_vec_delete3( three, 40, 0, count_destruct, my_dealloc3 );
-
-// Since there was no padding, the # of elements in the array are not stored
-// and the destructors are not called.
- if ( gCounter != 30 ) {
- std::cerr << "Mismatched Constructor/Destructor calls (1)" << std::endl;
- std::cerr << " Expected 30, got " << gCounter << std::endl;
- retVal = 1;
- }
-
- gCounter = 0;
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 8, count_construct, count_destruct );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 8, count_construct, count_destruct, my_alloc2, my_dealloc2 );
- three = __cxxabiv1::__cxa_vec_new3( 10, 40, 8, count_construct, count_destruct, my_alloc2, my_dealloc3 );
-
- __cxxabiv1::__cxa_vec_delete ( one, 40, 8, count_destruct );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 8, count_destruct, my_dealloc2 );
- __cxxabiv1::__cxa_vec_delete3( three, 40, 8, count_destruct, my_dealloc3 );
-
- if ( gCounter != 0 ) {
- std::cerr << "Mismatched Constructor/Destructor calls (2)" << std::endl;
- std::cerr << " Expected 0, got " << gCounter << std::endl;
- retVal = 1;
- }
-
- return retVal;
- }
-
-// Make sure the constructors and destructors are matched
-int test_exception_in_constructor ( ) {
- int retVal = 0;
- void *one, *two, *three;
-
-// Try with no padding
- gConstructorCounter = gDestructorCounter = 0;
- gConstructorThrowTarget = 15;
- gDestructorThrowTarget = -1;
- try {
- one = two = three = NULL;
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 0, throw_construct, throw_destruct );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 0, throw_construct, throw_destruct, my_alloc2, my_dealloc2 );
- three = __cxxabiv1::__cxa_vec_new3( 10, 40, 0, throw_construct, throw_destruct, my_alloc2, my_dealloc3 );
- }
- catch ( int i ) {}
-
- __cxxabiv1::__cxa_vec_delete ( one, 40, 0, throw_destruct );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 0, throw_destruct, my_dealloc2 );
- __cxxabiv1::__cxa_vec_delete3( three, 40, 0, throw_destruct, my_dealloc3 );
-
-// Since there was no padding, the # of elements in the array are not stored
-// and the destructors are not called.
-// Since we threw after 15 calls to the constructor, we should see 5 calls to
-// the destructor from the partially constructed array.
- if ( gConstructorCounter - gDestructorCounter != 10 ) {
- std::cerr << "Mismatched Constructor/Destructor calls (1C)" << std::endl;
- std::cerr << gConstructorCounter << " constructors, but " <<
- gDestructorCounter << " destructors" << std::endl;
- retVal = 1;
- }
-
- gConstructorCounter = gDestructorCounter = 0;
- gConstructorThrowTarget = 15;
- gDestructorThrowTarget = -1;
- try {
- one = two = three = NULL;
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 8, throw_construct, throw_destruct );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 8, throw_construct, throw_destruct, my_alloc2, my_dealloc2 );
- three = __cxxabiv1::__cxa_vec_new3( 10, 40, 8, throw_construct, throw_destruct, my_alloc2, my_dealloc3 );
- }
- catch ( int i ) {}
-
- __cxxabiv1::__cxa_vec_delete ( one, 40, 8, throw_destruct );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 8, throw_destruct, my_dealloc2 );
- __cxxabiv1::__cxa_vec_delete3( three, 40, 8, throw_destruct, my_dealloc3 );
-
- if ( gConstructorCounter != gDestructorCounter ) {
- std::cerr << "Mismatched Constructor/Destructor calls (2C)" << std::endl;
- std::cerr << gConstructorCounter << " constructors, but " <<
- gDestructorCounter << " destructors" << std::endl;
- retVal = 1;
- }
-
- return retVal;
- }
-
-// Make sure the constructors and destructors are matched
-int test_exception_in_destructor ( ) {
- int retVal = 0;
- void *one, *two, *three;
- one = two = three = NULL;
-
-// Throw from within a destructor
- gConstructorCounter = gDestructorCounter = 0;
- gConstructorThrowTarget = -1;
- gDestructorThrowTarget = 15;
- try {
- one = two = NULL;
- one = __cxxabiv1::__cxa_vec_new ( 10, 40, 8, throw_construct, throw_destruct );
- two = __cxxabiv1::__cxa_vec_new2( 10, 40, 8, throw_construct, throw_destruct, my_alloc2, my_dealloc2 );
- }
- catch ( int i ) {}
-
- try {
- __cxxabiv1::__cxa_vec_delete ( one, 40, 8, throw_destruct );
- __cxxabiv1::__cxa_vec_delete2( two, 40, 8, throw_destruct, my_dealloc2 );
- assert(false);
- }
- catch ( int i ) {}
-
-// We should have thrown in the middle of cleaning up "two", which means that
-// there should be 20 calls to the destructor and the try block should exit
-// before the assertion.
- if ( gConstructorCounter != 20 || gDestructorCounter != 20 ) {
- std::cerr << "Unexpected Constructor/Destructor calls (1D)" << std::endl;
- std::cerr << "Expected (20, 20), but got (" << gConstructorCounter << ", " <<
- gDestructorCounter << ")" << std::endl;
- retVal = 1;
- }
-
-// Try throwing from a destructor - should be fine.
- gConstructorCounter = gDestructorCounter = 0;
- gConstructorThrowTarget = -1;
- gDestructorThrowTarget = 5;
- try { vec_on_stack v; }
- catch ( int i ) {}
-
- if ( gConstructorCounter != gDestructorCounter ) {
- std::cerr << "Mismatched Constructor/Destructor calls (2D)" << std::endl;
- std::cerr << gConstructorCounter << " constructors, but " <<
- gDestructorCounter << " destructors" << std::endl;
- retVal = 1;
- }
-
- return retVal;
- }
-
-int main ( int argc, char *argv [] ) {
- int retVal = 0;
- retVal += test_empty ();
- retVal += test_counted ();
- retVal += test_exception_in_constructor ();
- retVal += test_exception_in_destructor ();
- return retVal;
- }
Removed: libcxxabi/trunk/test/test_vector2.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_vector2.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/test_vector2.cpp (original)
+++ libcxxabi/trunk/test/test_vector2.cpp (removed)
@@ -1,83 +0,0 @@
-//===--------------------------- test_vector2.cpp -------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "cxxabi.h"
-
-#include <iostream>
-#include <cstdlib>
-
-void my_terminate () { exit ( 0 ); }
-
-// Wrapper routines
-void *my_alloc2 ( size_t sz ) {
- void *p = std::malloc ( sz );
-// std::printf ( "Allocated %ld bytes at %lx\n", sz, (unsigned long) p );
- return p;
- }
-
-void my_dealloc2 ( void *p ) {
-// std::printf ( "Freeing %lx\n", (unsigned long) p );
- std::free ( p );
- }
-
-void my_dealloc3 ( void *p, size_t sz ) {
-// std::printf ( "Freeing %lx (size %ld)\n", (unsigned long) p, sz );
- std::free ( p );
- }
-
-void my_construct ( void *p ) {
-// std::printf ( "Constructing %lx\n", (unsigned long) p );
- }
-
-void my_destruct ( void *p ) {
-// std::printf ( "Destructing %lx\n", (unsigned long) p );
- }
-
-int gCounter;
-void count_construct ( void *p ) { ++gCounter; }
-void count_destruct ( void *p ) { --gCounter; }
-
-
-int gConstructorCounter;
-int gConstructorThrowTarget;
-int gDestructorCounter;
-int gDestructorThrowTarget;
-void throw_construct ( void *p ) { if ( gConstructorCounter == gConstructorThrowTarget ) throw 1; ++gConstructorCounter; }
-void throw_destruct ( void *p ) { if ( ++gDestructorCounter == gDestructorThrowTarget ) throw 2; }
-
-struct vec_on_stack {
- void *storage;
- vec_on_stack () : storage ( __cxxabiv1::__cxa_vec_new ( 10, 40, 8, throw_construct, throw_destruct )) {}
- ~vec_on_stack () { __cxxabiv1::__cxa_vec_delete ( storage, 40, 8, throw_destruct ); }
- };
-
-
-// Make sure the constructors and destructors are matched
-void test_exception_in_destructor ( ) {
-
-// Try throwing from a destructor while unwinding the stack -- should abort
- gConstructorCounter = gDestructorCounter = 0;
- gConstructorThrowTarget = -1;
- gDestructorThrowTarget = 5;
- try {
- vec_on_stack v;
- throw 3;
- }
- catch ( int i ) {}
-
- std::cerr << "should never get here" << std::endl;
- }
-
-
-
-int main ( int argc, char *argv [] ) {
- std::set_terminate ( my_terminate );
- test_exception_in_destructor ();
- return 1; // we failed if we get here
- }
Removed: libcxxabi/trunk/test/test_vector3.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_vector3.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/test_vector3.cpp (original)
+++ libcxxabi/trunk/test/test_vector3.cpp (removed)
@@ -1,58 +0,0 @@
-//===------------------------- test_vector3.cpp ---------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "cxxabi.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <exception>
-
-#include <memory>
-
-// use dtors instead of try/catch
-namespace test1 {
- struct B {
- ~B() {
- printf("should not be run\n");
- exit(10);
- }
-};
-
-struct A {
- ~A()
-#if __has_feature(cxx_noexcept)
- noexcept(false)
-#endif
- {
- B b;
- throw 0;
- }
-};
-} // test1
-
-void my_terminate() { exit(0); }
-
-template <class T>
-void destroy(void* v)
-{
- T* t = static_cast<T*>(v);
- t->~T();
-}
-
-int main( int argc, char *argv [])
-{
- std::set_terminate(my_terminate);
- {
- typedef test1::A Array[10];
- Array a[10]; // calls _cxa_vec_dtor
- __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>);
- assert(false);
- }
-}
Modified: libcxxabi/trunk/test/testit
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/testit?rev=226691&r1=226690&r2=226691&view=diff
==============================================================================
--- libcxxabi/trunk/test/testit (original)
+++ libcxxabi/trunk/test/testit Wed Jan 21 13:05:37 2015
@@ -53,7 +53,7 @@ afunc()
if (ls *.cpp > /dev/null 2>&1)
then
- for FILE in $(ls *.cpp); do
+ for FILE in $(ls *.pass.cpp); do
if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE
then
if ./$TEST_EXE
Removed: libcxxabi/trunk/test/unwind_01.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_01.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_01.cpp (original)
+++ libcxxabi/trunk/test/unwind_01.cpp (removed)
@@ -1,96 +0,0 @@
-//===------------------------- unwind_01.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <assert.h>
-
-struct A
-{
- static int count;
- int id_;
- A() : id_(++count) {}
- ~A() {assert(id_ == count--);}
-
-private:
- A(const A&);
- A& operator=(const A&);
-};
-
-int A::count = 0;
-
-struct B
-{
- static int count;
- int id_;
- B() : id_(++count) {}
- ~B() {assert(id_ == count--);}
-
-private:
- B(const B&);
- B& operator=(const B&);
-};
-
-int B::count = 0;
-
-struct C
-{
- static int count;
- int id_;
- C() : id_(++count) {}
- ~C() {assert(id_ == count--);}
-
-private:
- C(const C&);
- C& operator=(const C&);
-};
-
-int C::count = 0;
-
-void f2()
-{
- C c;
- A a;
- throw 55;
- B b;
-}
-
-void f1()
-{
- A a;
- B b;
- f2();
- C c;
-}
-
-int main()
-{
- try
- {
- f1();
- assert(false);
- }
- catch (int* i)
- {
- assert(false);
- }
- catch (long i)
- {
- assert(false);
- }
- catch (int i)
- {
- assert(i == 55);
- }
- catch (...)
- {
- assert(false);
- }
- assert(A::count == 0);
- assert(B::count == 0);
- assert(C::count == 0);
-}
Removed: libcxxabi/trunk/test/unwind_02.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_02.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_02.cpp (original)
+++ libcxxabi/trunk/test/unwind_02.cpp (removed)
@@ -1,96 +0,0 @@
-//===------------------------- unwind_02.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <assert.h>
-
-struct A
-{
- static int count;
- int id_;
- A() : id_(++count) {}
- ~A() {assert(id_ == count--);}
-
-private:
- A(const A&);
- A& operator=(const A&);
-};
-
-int A::count = 0;
-
-struct B
-{
- static int count;
- int id_;
- B() : id_(++count) {}
- ~B() {assert(id_ == count--);}
-
-private:
- B(const B&);
- B& operator=(const B&);
-};
-
-int B::count = 0;
-
-struct C
-{
- static int count;
- int id_;
- C() : id_(++count) {}
- ~C() {assert(id_ == count--);}
-
-private:
- C(const C&);
- C& operator=(const C&);
-};
-
-int C::count = 0;
-
-void f2()
-{
- C c;
- A a;
- throw 55;
- B b;
-}
-
-void f1() throw (long, char, int, double)
-{
- A a;
- B b;
- f2();
- C c;
-}
-
-int main()
-{
- try
- {
- f1();
- assert(false);
- }
- catch (int* i)
- {
- assert(false);
- }
- catch (long i)
- {
- assert(false);
- }
- catch (int i)
- {
- assert(i == 55);
- }
- catch (...)
- {
- assert(false);
- }
- assert(A::count == 0);
- assert(B::count == 0);
- assert(C::count == 0);
-}
Removed: libcxxabi/trunk/test/unwind_03.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_03.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_03.cpp (original)
+++ libcxxabi/trunk/test/unwind_03.cpp (removed)
@@ -1,102 +0,0 @@
-//===------------------------- unwind_03.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <exception>
-#include <stdlib.h>
-#include <assert.h>
-
-struct A
-{
- static int count;
- int id_;
- A() : id_(++count) {}
- ~A() {assert(id_ == count--);}
-
-private:
- A(const A&);
- A& operator=(const A&);
-};
-
-int A::count = 0;
-
-struct B
-{
- static int count;
- int id_;
- B() : id_(++count) {}
- ~B() {assert(id_ == count--);}
-
-private:
- B(const B&);
- B& operator=(const B&);
-};
-
-int B::count = 0;
-
-struct C
-{
- static int count;
- int id_;
- C() : id_(++count) {}
- ~C() {assert(id_ == count--);}
-
-private:
- C(const C&);
- C& operator=(const C&);
-};
-
-int C::count = 0;
-
-void f2()
-{
- C c;
- A a;
- throw 55;
- B b;
-}
-
-void f1() throw (long, char, double)
-{
- A a;
- B b;
- f2();
- C c;
-}
-
-void u_handler()
-{
- exit(0);
-}
-
-int main()
-{
- std::set_unexpected(u_handler);
- try
- {
- f1();
- assert(false);
- }
- catch (int* i)
- {
- assert(false);
- }
- catch (long i)
- {
- assert(false);
- }
- catch (int i)
- {
- assert(i == 55);
- }
- catch (...)
- {
- assert(false);
- }
- assert(false);
-}
Removed: libcxxabi/trunk/test/unwind_04.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_04.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_04.cpp (original)
+++ libcxxabi/trunk/test/unwind_04.cpp (removed)
@@ -1,108 +0,0 @@
-//===------------------------- unwind_04.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <exception>
-#include <stdlib.h>
-#include <assert.h>
-
-struct A
-{
- static int count;
- int id_;
- A() : id_(++count) {}
- ~A() {assert(id_ == count--);}
-
-private:
- A(const A&);
- A& operator=(const A&);
-};
-
-int A::count = 0;
-
-struct B
-{
- static int count;
- int id_;
- B() : id_(++count) {}
- ~B() {assert(id_ == count--);}
-
-private:
- B(const B&);
- B& operator=(const B&);
-};
-
-int B::count = 0;
-
-struct C
-{
- static int count;
- int id_;
- C() : id_(++count) {}
- ~C() {assert(id_ == count--);}
-
-private:
- C(const C&);
- C& operator=(const C&);
-};
-
-int C::count = 0;
-
-void f2()
-{
- C c;
- A a;
- throw 55;
- B b;
-}
-
-void f1() throw (long, char, double)
-{
- A a;
- B b;
- f2();
- C c;
-}
-
-void u_handler()
-{
- throw 'a';
-}
-
-int main()
-{
- std::set_unexpected(u_handler);
- try
- {
- f1();
- assert(false);
- }
- catch (int* i)
- {
- assert(false);
- }
- catch (long i)
- {
- assert(false);
- }
- catch (int i)
- {
- assert(false);
- }
- catch (char c)
- {
- assert(c == 'a');
- }
- catch (...)
- {
- assert(false);
- }
- assert(A::count == 0);
- assert(B::count == 0);
- assert(C::count == 0);
-}
Removed: libcxxabi/trunk/test/unwind_05.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_05.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_05.cpp (original)
+++ libcxxabi/trunk/test/unwind_05.cpp (removed)
@@ -1,112 +0,0 @@
-//===------------------------- unwind_05.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <exception>
-#include <stdlib.h>
-#include <assert.h>
-
-struct A
-{
- static int count;
- int id_;
- A() : id_(++count) {}
- ~A() {assert(id_ == count--);}
-
-private:
- A(const A&);
- A& operator=(const A&);
-};
-
-int A::count = 0;
-
-struct B
-{
- static int count;
- int id_;
- B() : id_(++count) {}
- ~B() {assert(id_ == count--);}
-
-private:
- B(const B&);
- B& operator=(const B&);
-};
-
-int B::count = 0;
-
-struct C
-{
- static int count;
- int id_;
- C() : id_(++count) {}
- ~C() {assert(id_ == count--);}
-
-private:
- C(const C&);
- C& operator=(const C&);
-};
-
-int C::count = 0;
-
-void f2()
-{
- C c;
- A a;
- throw 55;
- B b;
-}
-
-void f1() throw (long, char, double, std::bad_exception)
-{
- A a;
- B b;
- f2();
- C c;
-}
-
-void u_handler()
-{
- throw;
-}
-
-int main()
-{
- std::set_unexpected(u_handler);
- try
- {
- f1();
- assert(false);
- }
- catch (int* i)
- {
- assert(false);
- }
- catch (long i)
- {
- assert(false);
- }
- catch (int i)
- {
- assert(false);
- }
- catch (char c)
- {
- assert(false);
- }
- catch (const std::bad_exception& e)
- {
- assert(true);
- }
- catch (...)
- {
- assert(false);
- }
- assert(A::count == 0);
- assert(B::count == 0);
- assert(C::count == 0);
-}
Removed: libcxxabi/trunk/test/unwind_06.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_06.cpp?rev=226690&view=auto
==============================================================================
--- libcxxabi/trunk/test/unwind_06.cpp (original)
+++ libcxxabi/trunk/test/unwind_06.cpp (removed)
@@ -1,257 +0,0 @@
-//===------------------------- unwind_06.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <exception>
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-
-// Compile with -Os to get compiler uses float registers to hold float variables
-
-double get_(int x) { return (double)x; }
-
-double (* volatile get)(int) = get_;
-
-volatile int counter;
-
-double try1(bool v) {
- double a = get(0);
- double b = get(1);
- for (counter = 100; counter; --counter)
- a += get(1) + b;
- if (v) throw 10;
- return get(0)+a+b;
-}
-
-double try2(bool v) {
- double a = get(0);
- double b = get(1);
- double c = get(2);
- for (counter = 100; counter; --counter)
- a += get(1) + b + c;
- if (v) throw 10;
- return get(0)+a+b+c;
-}
-
-double try3(bool v) {
- double a = get(0);
- double b = get(1);
- double c = get(2);
- double d = get(3);
- for (counter = 100; counter; --counter)
- a += get(1) + b + c + d;
- if (v) throw 10;
- return get(0)+a+b+c+d;
-}
-
-double try4(bool v) {
- double a = get(0);
- double b = get(0);
- double c = get(0);
- double d = get(0);
- double e = get(0);
- for (counter = 100; counter; --counter)
- a += get(1) + b+c+d+e;
- if (v) throw 10;
- return get(0)+a+b+c+d+e;
-}
-
-double try5(bool v) {
- double a = get(0);
- double b = get(0);
- double c = get(0);
- double d = get(0);
- double e = get(0);
- double f = get(0);
- for (counter = 100; counter; --counter)
- a += get(1) + b+c+d+e+f;
- if (v) throw 10;
- return get(0)+a+b+c+d+e+f;
-}
-
-double try6(bool v) {
- double a = get(0);
- double b = get(0);
- double c = get(0);
- double d = get(0);
- double e = get(0);
- double f = get(0);
- double g = get(0);
- for (counter = 100; counter; --counter)
- a += get(1) + b+c+d+e+f+g;
- if (v) throw 10;
- return get(0)+a+b+c+d+e+f+g;
-}
-
-double try7(bool v) {
- double a = get(0);
- double b = get(0);
- double c = get(0);
- double d = get(0);
- double e = get(0);
- double f = get(0);
- double g = get(0);
- double h = get(0);
- for (counter = 100; counter; --counter)
- a += get(1) + b+c+d+e+f+g;
- if (v) throw 10;
- return get(0)+a+b+c+d+e+f+g;
-}
-
-double try8(bool v) {
- double a = get(0);
- double b = get(0);
- double c = get(0);
- double d = get(0);
- double e = get(0);
- double f = get(0);
- double g = get(0);
- double h = get(0);
- double i = get(0);
- for (counter = 100; counter; --counter)
- a += get(1) + b+c+d+e+f+g+i;
- if (v) throw 10;
- return get(0)+a+b+c+d+e+f+g+i;
-}
-
-
-
-
-
-double foo()
-{
- double a = get(1);
- double b = get(2);
- double c = get(3);
- double d = get(4);
- double e = get(5);
- double f = get(6);
- double g = get(7);
- double h = get(8);
- try {
- try1(true);
- }
- catch (int e) {
- }
- assert(a == get(1));
- assert(b == get(2));
- assert(c == get(3));
- assert(d == get(4));
- assert(e == get(5));
- assert(f == get(6));
- assert(g == get(7));
- assert(h == get(8));
-
- try {
- try2(true);
- }
- catch (int e) {
- }
- assert(a == get(1));
- assert(b == get(2));
- assert(c == get(3));
- assert(d == get(4));
- assert(e == get(5));
- assert(f == get(6));
- assert(g == get(7));
- assert(h == get(8));
-
- try {
- try3(true);
- }
- catch (int e) {
- }
- assert(a == get(1));
- assert(b == get(2));
- assert(c == get(3));
- assert(d == get(4));
- assert(e == get(5));
- assert(f == get(6));
- assert(g == get(7));
- assert(h == get(8));
-
- try {
- try4(true);
- }
- catch (int e) {
- }
- assert(a == get(1));
- assert(b == get(2));
- assert(c == get(3));
- assert(d == get(4));
- assert(e == get(5));
- assert(f == get(6));
- assert(g == get(7));
- assert(h == get(8));
-
- try {
- try5(true);
- }
- catch (int e) {
- }
- assert(a == get(1));
- assert(b == get(2));
- assert(c == get(3));
- assert(d == get(4));
- assert(e == get(5));
- assert(f == get(6));
- assert(g == get(7));
- assert(h == get(8));
-
- try {
- try6(true);
- }
- catch (int e) {
- }
- assert(a == get(1));
- assert(b == get(2));
- assert(c == get(3));
- assert(d == get(4));
- assert(e == get(5));
- assert(f == get(6));
- assert(g == get(7));
- assert(h == get(8));
-
- try {
- try7(true);
- }
- catch (int e) {
- }
- assert(a == get(1));
- assert(b == get(2));
- assert(c == get(3));
- assert(d == get(4));
- assert(e == get(5));
- assert(f == get(6));
- assert(g == get(7));
- assert(h == get(8));
-
- try {
- try8(true);
- }
- catch (int e) {
- }
- assert(a == get(1));
- assert(b == get(2));
- assert(c == get(3));
- assert(d == get(4));
- assert(e == get(5));
- assert(f == get(6));
- assert(g == get(7));
- assert(h == get(8));
-
- return a+b+c+d+e+f+g+h;
-}
-
-
-
-int main()
-{
- foo();
-}
More information about the cfe-commits
mailing list