diff --git a/configure.py b/configure.py index 915729f11..3d5f046cd 100755 --- a/configure.py +++ b/configure.py @@ -133,6 +133,7 @@ def debug_flag(compiler): 'tests/timertest', 'tests/tcp_test', 'tests/futures_test', + 'tests/alloc_test', 'tests/foreign_ptr_test', 'tests/smp_test', 'tests/thread_test', @@ -295,6 +296,7 @@ def have_xen(): 'tests/tcp_test': ['tests/tcp_test.cc'] + core + libnet, 'tests/timertest': ['tests/timertest.cc'] + core, 'tests/futures_test': ['tests/futures_test.cc'] + core + boost_test_lib, + 'tests/alloc_test': ['tests/alloc_test.cc'] + core + boost_test_lib, 'tests/foreign_ptr_test': ['tests/foreign_ptr_test.cc'] + core + boost_test_lib, 'tests/semaphore_test': ['tests/semaphore_test.cc'] + core + boost_test_lib, 'tests/smp_test': ['tests/smp_test.cc'] + core, diff --git a/test.py b/test.py index 018016ff2..62bf880cd 100755 --- a/test.py +++ b/test.py @@ -24,6 +24,7 @@ import re boost_tests = [ + 'alloc_test', 'futures_test', 'thread_test', 'memcached/test_ascii_parser', diff --git a/tests/alloc_test.cc b/tests/alloc_test.cc new file mode 100644 index 000000000..ee9ac15d0 --- /dev/null +++ b/tests/alloc_test.cc @@ -0,0 +1,37 @@ +/* + * This file is open source software, licensed to you under the terms + * of the Apache License, Version 2.0 (the "License"). See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. 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. + */ +/* + * Copyright (C) 2015 Cloudius Systems, Ltd. + */ + +#include "tests/test-utils.hh" +#include "core/memory.hh" + + +SEASTAR_TEST_CASE(alloc_almost_all_and_realloc_it_with_a_smaller_size) { +#ifndef DEFAULT_ALLOCATOR + auto all = memory::stats().total_memory(); + auto obj = malloc(all - (10 << 20)); + BOOST_REQUIRE(obj != nullptr); + auto obj2 = realloc(obj, all - (11 << 20)); + BOOST_REQUIRE(obj == obj2); + free(obj2); +#endif + return make_ready_future<>(); +} +