~codership/galera/2.x

« back to all changes in this revision

Viewing changes to galerautils/tests/gu_mem_pool_test.cpp

  • Committer: Alexey Yurchenko
  • Date: 2014-01-29 14:43:26 UTC
  • mto: This revision was merged to the branch mainline in revision 167.
  • Revision ID: alexey.yurchenko@codership.com-20140129144326-aa70nhzofl0smkm8
Fixes:
* provider pause() is fixed to avoid potential deadlock with replicating threads.
* lp:1099478 - handle own address in the address list properly (do not throw exception)
* lp:1259952 - fixed allocation of multiple of pages when posix_fallocate() is unavailable
* lp:1261996 - fixed compilation on Solaris 11
* lp:1232747 - fixed group remerge after partitioning event

Synced with SVN r3450

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2013 Codership Oy <info@codership.com>
 
2
 
 
3
// $Id: gu_mem_pool_test.cpp 3446 2014-01-13 01:33:30Z teemu $
 
4
 
 
5
#define TEST_SIZE 1024
 
6
 
 
7
#include "gu_mem_pool.hpp"
 
8
 
 
9
#include "gu_mem_pool_test.hpp"
 
10
 
 
11
START_TEST (unsafe)
 
12
{
 
13
    gu::MemPoolUnsafe mp(10, 1, "unsafe");
 
14
 
 
15
    void* const buf0(mp.acquire());
 
16
    fail_if(NULL == buf0);
 
17
 
 
18
    void* const buf1(mp.acquire());
 
19
    fail_if(NULL == buf1);
 
20
    fail_if(buf0 == buf1);
 
21
 
 
22
    mp.recycle(buf0);
 
23
 
 
24
    void* const buf2(mp.acquire());
 
25
    fail_if(NULL == buf2);
 
26
    fail_if(buf0 != buf2);
 
27
 
 
28
    log_info << mp;
 
29
 
 
30
    mp.recycle(buf1);
 
31
    mp.recycle(buf2);
 
32
}
 
33
END_TEST
 
34
 
 
35
START_TEST (safe)
 
36
{
 
37
    gu::MemPoolSafe mp(10, 1, "safe");
 
38
 
 
39
    void* const buf0(mp.acquire());
 
40
    fail_if(NULL == buf0);
 
41
 
 
42
    void* const buf1(mp.acquire());
 
43
    fail_if(NULL == buf1);
 
44
    fail_if(buf0 == buf1);
 
45
 
 
46
    mp.recycle(buf0);
 
47
 
 
48
    void* const buf2(mp.acquire());
 
49
    fail_if(NULL == buf2);
 
50
    fail_if(buf0 != buf2);
 
51
 
 
52
    log_info << mp;
 
53
 
 
54
    mp.recycle(buf1);
 
55
    mp.recycle(buf2);
 
56
}
 
57
END_TEST
 
58
 
 
59
Suite *gu_mem_pool_suite(void)
 
60
{
 
61
    Suite *s = suite_create("gu::MemPool");
 
62
    TCase *tc_mem = tcase_create("gu_mem_pool");
 
63
 
 
64
    suite_add_tcase (s, tc_mem);
 
65
    tcase_add_test(tc_mem, unsafe);
 
66
    tcase_add_test(tc_mem, safe);
 
67
 
 
68
    return s;
 
69
}
 
70