From 3d22af6253d31cffd2171ccfbd5bc321279f8716 Mon Sep 17 00:00:00 2001 From: Nikos Armenatzoglou Date: Tue, 7 Jun 2016 14:33:43 -0700 Subject: [PATCH] Fix broken zlib unittests --- .../storage/file/test/compress_zlib_test.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/file/test/compress_zlib_test.c b/src/backend/storage/file/test/compress_zlib_test.c index f94275c474..68d80b2851 100644 --- a/src/backend/storage/file/test/compress_zlib_test.c +++ b/src/backend/storage/file/test/compress_zlib_test.c @@ -80,11 +80,13 @@ test__bfz_zlib_init__palloc_write(void **state) bfz.mode = BFZ_MODE_APPEND; bfz.fd = -1; - Size beforeAlloc = MemoryContextGetPeakSpace(TopMemoryContext); + Size beforeAlloc = MemoryContextGetPeakSpace(TopTransactionContext); + assert_true(TopTransactionContext != CurrentMemoryContext); bfz_zlib_init(&bfz); - Size afterAlloc = MemoryContextGetPeakSpace(TopMemoryContext); + Size afterAlloc = MemoryContextGetPeakSpace(TopTransactionContext); + assert_true(TopTransactionContext != CurrentMemoryContext); int memZlib = zlib_memory_needed(true /* isWrite */); @@ -100,11 +102,13 @@ test__bfz_zlib_init__palloc_read(void **state) bfz.mode = BFZ_MODE_SCAN; bfz.fd = -1; - Size beforeAlloc = MemoryContextGetPeakSpace(TopMemoryContext); + Size beforeAlloc = MemoryContextGetPeakSpace(TopTransactionContext); + assert_true(TopTransactionContext != CurrentMemoryContext); bfz_zlib_init(&bfz); - Size afterAlloc = MemoryContextGetPeakSpace(TopMemoryContext); + Size afterAlloc = MemoryContextGetPeakSpace(TopTransactionContext); + assert_true(TopTransactionContext != CurrentMemoryContext); int memZlib = zlib_memory_needed(false /* isWrite */); @@ -116,6 +120,13 @@ main(int argc, char* argv[]) { cmockery_parse_arguments(argc, argv); + TopTransactionContext = + AllocSetContextCreate(TopMemoryContext, + "TopTransactionContext", + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); + const UnitTest tests[] = { unit_test(test__bfz_zlib_init__palloc_write), unit_test(test__bfz_zlib_init__palloc_read) -- GitLab