Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2020-08-07 17:43:42 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-08-10 19:14:00 +0300
commit53d203dea8230da4e80f3cc61468a4e24ff6759c (patch)
tree3f1b7498fb1a3108e60a4355bec0e4eef76110e4 /tests/gtests/guardedalloc/guardedalloc_overflow_test.cc
parentaf77bf1f0f94cb07d5bf681d1f771d4106873780 (diff)
Tests: move remaining gtests into their own module folders
And make them part of the blender_test runner. The one exception is blenlib performance tests, which we don't want to run by default. They remain in their own executable. Differential Revision: https://developer.blender.org/D8498
Diffstat (limited to 'tests/gtests/guardedalloc/guardedalloc_overflow_test.cc')
-rw-r--r--tests/gtests/guardedalloc/guardedalloc_overflow_test.cc60
1 files changed, 0 insertions, 60 deletions
diff --git a/tests/gtests/guardedalloc/guardedalloc_overflow_test.cc b/tests/gtests/guardedalloc/guardedalloc_overflow_test.cc
deleted file mode 100644
index bd47482d033..00000000000
--- a/tests/gtests/guardedalloc/guardedalloc_overflow_test.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Apache License, Version 2.0 */
-
-#include "testing/testing.h"
-
-#include "MEM_guardedalloc.h"
-
-/* We expect to abort on integer overflow, to prevent possible exploits. */
-#ifdef _WIN32
-# define ABORT_PREDICATE ::testing::ExitedWithCode(3)
-#else
-# define ABORT_PREDICATE ::testing::KilledBySignal(SIGABRT)
-#endif
-
-namespace {
-
-void MallocArray(size_t len, size_t size)
-{
- void *mem = MEM_malloc_arrayN(len, size, "MallocArray");
- if (mem) {
- MEM_freeN(mem);
- }
-}
-
-void CallocArray(size_t len, size_t size)
-{
- void *mem = MEM_calloc_arrayN(len, size, "CallocArray");
- if (mem) {
- MEM_freeN(mem);
- }
-}
-
-} // namespace
-
-TEST(guardedalloc, LockfreeIntegerOverflow)
-{
- MallocArray(1, SIZE_MAX);
- CallocArray(SIZE_MAX, 1);
- MallocArray(SIZE_MAX / 2, 2);
- CallocArray(SIZE_MAX / 1234567, 1234567);
-
- EXPECT_EXIT(MallocArray(SIZE_MAX, 2), ABORT_PREDICATE, "");
- EXPECT_EXIT(CallocArray(7, SIZE_MAX), ABORT_PREDICATE, "");
- EXPECT_EXIT(MallocArray(SIZE_MAX, 12345567), ABORT_PREDICATE, "");
- EXPECT_EXIT(CallocArray(SIZE_MAX, SIZE_MAX), ABORT_PREDICATE, "");
-}
-
-TEST(guardedalloc, GuardedIntegerOverflow)
-{
- MEM_use_guarded_allocator();
-
- MallocArray(1, SIZE_MAX);
- CallocArray(SIZE_MAX, 1);
- MallocArray(SIZE_MAX / 2, 2);
- CallocArray(SIZE_MAX / 1234567, 1234567);
-
- EXPECT_EXIT(MallocArray(SIZE_MAX, 2), ABORT_PREDICATE, "");
- EXPECT_EXIT(CallocArray(7, SIZE_MAX), ABORT_PREDICATE, "");
- EXPECT_EXIT(MallocArray(SIZE_MAX, 12345567), ABORT_PREDICATE, "");
- EXPECT_EXIT(CallocArray(SIZE_MAX, SIZE_MAX), ABORT_PREDICATE, "");
-}