summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/localization
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-22 22:38:59 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-22 22:38:59 +0000
commit2cbc654d93bc9f1f3e6dd59166c7e1f8750738d1 (patch)
treeab539fa3fe99f12333428aa427c6c41cdf28e5e7 /libcxx/test/std/localization
parentbad65c3b708accec8c6e85346dabc7967cb3d7ca (diff)
downloadbcm5719-llvm-2cbc654d93bc9f1f3e6dd59166c7e1f8750738d1.tar.gz
bcm5719-llvm-2cbc654d93bc9f1f3e6dd59166c7e1f8750738d1.zip
[libcxx] Consolidate new/delete replacement in tests and disable it when using sanitizers.
Summary: MSAN and ASAN also replace new/delete which leads to a link error in these tests. Currently they are unsupported but I think it would be useful if these tests could run with sanitizers. This patch creates a support header that consolidates the new/delete replacement functionality and checking. When we are using sanitizers new and delete are no longer replaced and the checks always return true. Reviewers: mclow.lists, danalbert, jroelofs, EricWF Reviewed By: EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6562 llvm-svn: 224741
Diffstat (limited to 'libcxx/test/std/localization')
-rw-r--r--libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp31
-rw-r--r--libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp27
-rw-r--r--libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp27
-rw-r--r--libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp33
-rw-r--r--libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp34
-rw-r--r--libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp21
6 files changed, 38 insertions, 135 deletions
diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
index f7c957baecc..9fcedddbd43 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
@@ -13,45 +13,28 @@
// ~ctype();
-// UNSUPPORTED: asan, msan
-
#include <locale>
#include <cassert>
-#include <new>
-
-unsigned delete_called = 0;
-void* operator new[](size_t sz) throw(std::bad_alloc)
-{
- return operator new(sz);
-}
-
-void operator delete[](void* p) throw()
-{
- operator delete(p);
- ++delete_called;
-}
+#include "count_new.hpp"
int main()
{
{
- delete_called = 0;
std::locale l(std::locale::classic(), new std::ctype<char>);
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
}
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
{
std::ctype<char>::mask table[256];
- delete_called = 0;
std::locale l(std::locale::classic(), new std::ctype<char>(table));
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
}
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
{
- delete_called = 0;
std::locale l(std::locale::classic(),
new std::ctype<char>(new std::ctype<char>::mask[256], true));
- assert(delete_called == 0);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(0));
}
- assert(delete_called == 1);
+ assert(globalMemCounter.checkDeleteArrayCalledEq(1));
}
diff --git a/libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp b/libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
index 7e38021ba9a..a61a9c928d7 100644
--- a/libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
+++ b/libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
@@ -17,43 +17,26 @@
// // unspecified
// };
-// UNSUPPORTED: asan, msan
-
// Not a portable test
#include <codecvt>
#include <cstdlib>
#include <cassert>
-int outstanding_news = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++outstanding_news;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- if (p)
- {
- --outstanding_news;
- std::free(p);
- }
-}
+#include "count_new.hpp"
int main()
{
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
typedef std::codecvt_utf16<wchar_t> C;
C c;
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
{
typedef std::codecvt_utf16<wchar_t> C;
std::locale loc(std::locale::classic(), new C);
- assert(outstanding_news != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
diff --git a/libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp b/libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
index cc06e95f406..5fa0eaaf8eb 100644
--- a/libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
+++ b/libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
@@ -17,43 +17,26 @@
// // unspecified
// };
-// UNSUPPORTED: asan, msan
-
// Not a portable test
#include <codecvt>
#include <cstdlib>
#include <cassert>
-int outstanding_news = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++outstanding_news;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- if (p)
- {
- --outstanding_news;
- std::free(p);
- }
-}
+#include "count_new.hpp"
int main()
{
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
typedef std::codecvt_utf8<wchar_t> C;
C c;
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
{
typedef std::codecvt_utf8<wchar_t> C;
std::locale loc(std::locale::classic(), new C);
- assert(outstanding_news != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(outstanding_news == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
diff --git a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
index 3649f157d04..5f57df12f02 100644
--- a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
+++ b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
@@ -14,27 +14,12 @@
// wbuffer_convert(streambuf *bytebuf = 0, Codecvt *pcvt = new Codecvt,
// state_type state = state_type());
-// UNSUPPORTED: asan, msan
-
#include <locale>
#include <codecvt>
#include <sstream>
#include <cassert>
-#include <new>
-
-int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
int main()
{
@@ -46,28 +31,28 @@ int main()
{
B b;
assert(b.rdbuf() == nullptr);
- assert(new_called != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::stringstream s;
B b(s.rdbuf());
assert(b.rdbuf() == s.rdbuf());
- assert(new_called != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::stringstream s;
B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>);
assert(b.rdbuf() == s.rdbuf());
- assert(new_called != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
{
std::stringstream s;
B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>, std::mbstate_t());
assert(b.rdbuf() == s.rdbuf());
- assert(new_called != 0);
+ assert(globalMemCounter.checkOutstandingNewNotEq(0));
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp
index 25db9bbf1ac..1efc939f3c2 100644
--- a/libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp
+++ b/libcxx/test/std/localization/locales/locale/locale.cons/default.pass.cpp
@@ -11,27 +11,11 @@
// locale() throw();
-// UNSUPPORTED: asan, msan
-
#include <locale>
-#include <new>
#include <cassert>
#include "platform_support.h" // locale name macros
-
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
void check(const std::locale& loc)
{
@@ -73,19 +57,19 @@ int main()
int ok;
{
std::locale loc;
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(loc.name() == "C");
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
check(loc);
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
assert(std::locale::global(std::locale(LOCALE_en_US_UTF_8)) == loc);
- ok = new_called;
+ ok = globalMemCounter.outstanding_new;
std::locale loc2;
- assert(new_called == ok);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
check(loc2);
- assert(new_called == ok);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
assert(loc2 == std::locale(LOCALE_en_US_UTF_8));
- assert(new_called == ok);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
}
- assert(new_called == ok);
+ assert(globalMemCounter.checkOutstandingNewEq(ok));
}
diff --git a/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp
index 8f189c70f81..e956102c08f 100644
--- a/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp
+++ b/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp
@@ -11,25 +11,10 @@
// template <class Facet> locale combine(const locale& other) const;
-// UNSUPPORTED: asan, msan
-
#include <locale>
-#include <new>
#include <cassert>
-int new_called = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- ++new_called;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --new_called;
- std::free(p);
-}
+#include "count_new.hpp"
void check(const std::locale& loc)
{
@@ -89,7 +74,7 @@ int main()
const my_facet& f = std::use_facet<my_facet>(loc3);
assert(f.test() == 5);
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
{
{
@@ -104,6 +89,6 @@ int main()
{
}
}
- assert(new_called == 0);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
}
}
OpenPOWER on IntegriCloud