~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to storage/tokudb/ft-index/ft/tests/subblock-test-index.cc

  • Committer: Package Import Robot
  • Author(s): James Page, Otto Kekäläinen
  • Date: 2014-02-17 16:51:52 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140217165152-k315d3175g865kkx
Tags: 5.5.35-1
[ Otto Kekäläinen ]
* New upstream release, fixing the following security issues:
  - Buffer overflow in client/mysql.cc (Closes: #737597).
    - CVE-2014-0001
  - http://www.oracle.com/technetwork/topics/security/cpujan2014-1972949.html
    - CVE-2013-5891
    - CVE-2013-5908
    - CVE-2014-0386
    - CVE-2014-0393
    - CVE-2014-0401
    - CVE-2014-0402
    - CVE-2014-0412
    - CVE-2014-0420
    - CVE-2014-0437
* Upstream https://mariadb.atlassian.net/browse/MDEV-4902
  fixes compatibility with Bison 3.0 (Closes: #733002)
* Updated Russian debconf translation (Closes: #734426)
* Updated Japanese debconf translation (Closes: #735284)
* Updated French debconf translation (Closes: #736480)
* Renamed SONAME properly (Closes: #732967)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 
2
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
 
3
// test the sub block index function
 
4
#ident "$Id$"
 
5
/*
 
6
COPYING CONDITIONS NOTICE:
 
7
 
 
8
  This program is free software; you can redistribute it and/or modify
 
9
  it under the terms of version 2 of the GNU General Public License as
 
10
  published by the Free Software Foundation, and provided that the
 
11
  following conditions are met:
 
12
 
 
13
      * Redistributions of source code must retain this COPYING
 
14
        CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
 
15
        DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
 
16
        PATENT MARKING NOTICE (below), and the PATENT RIGHTS
 
17
        GRANT (below).
 
18
 
 
19
      * Redistributions in binary form must reproduce this COPYING
 
20
        CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
 
21
        DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
 
22
        PATENT MARKING NOTICE (below), and the PATENT RIGHTS
 
23
        GRANT (below) in the documentation and/or other materials
 
24
        provided with the distribution.
 
25
 
 
26
  You should have received a copy of the GNU General Public License
 
27
  along with this program; if not, write to the Free Software
 
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
29
  02110-1301, USA.
 
30
 
 
31
COPYRIGHT NOTICE:
 
32
 
 
33
  TokuDB, Tokutek Fractal Tree Indexing Library.
 
34
  Copyright (C) 2007-2013 Tokutek, Inc.
 
35
 
 
36
DISCLAIMER:
 
37
 
 
38
  This program is distributed in the hope that it will be useful, but
 
39
  WITHOUT ANY WARRANTY; without even the implied warranty of
 
40
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
41
  General Public License for more details.
 
42
 
 
43
UNIVERSITY PATENT NOTICE:
 
44
 
 
45
  The technology is licensed by the Massachusetts Institute of
 
46
  Technology, Rutgers State University of New Jersey, and the Research
 
47
  Foundation of State University of New York at Stony Brook under
 
48
  United States of America Serial No. 11/760379 and to the patents
 
49
  and/or patent applications resulting from it.
 
50
 
 
51
PATENT MARKING NOTICE:
 
52
 
 
53
  This software is covered by US Patent No. 8,185,551.
 
54
  This software is covered by US Patent No. 8,489,638.
 
55
 
 
56
PATENT RIGHTS GRANT:
 
57
 
 
58
  "THIS IMPLEMENTATION" means the copyrightable works distributed by
 
59
  Tokutek as part of the Fractal Tree project.
 
60
 
 
61
  "PATENT CLAIMS" means the claims of patents that are owned or
 
62
  licensable by Tokutek, both currently or in the future; and that in
 
63
  the absence of this license would be infringed by THIS
 
64
  IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
 
65
 
 
66
  "PATENT CHALLENGE" shall mean a challenge to the validity,
 
67
  patentability, enforceability and/or non-infringement of any of the
 
68
  PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
 
69
 
 
70
  Tokutek hereby grants to you, for the term and geographical scope of
 
71
  the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
 
72
  irrevocable (except as stated in this section) patent license to
 
73
  make, have made, use, offer to sell, sell, import, transfer, and
 
74
  otherwise run, modify, and propagate the contents of THIS
 
75
  IMPLEMENTATION, where such license applies only to the PATENT
 
76
  CLAIMS.  This grant does not include claims that would be infringed
 
77
  only as a consequence of further modifications of THIS
 
78
  IMPLEMENTATION.  If you or your agent or licensee institute or order
 
79
  or agree to the institution of patent litigation against any entity
 
80
  (including a cross-claim or counterclaim in a lawsuit) alleging that
 
81
  THIS IMPLEMENTATION constitutes direct or contributory patent
 
82
  infringement, or inducement of patent infringement, then any rights
 
83
  granted to you under this License shall terminate as of the date
 
84
  such litigation is filed.  If you or your agent or exclusive
 
85
  licensee institute or order or agree to the institution of a PATENT
 
86
  CHALLENGE, then Tokutek may terminate any rights granted to you
 
87
  under this License.
 
88
*/
 
89
 
 
90
#ident "Copyright (c) 2007-2013 Tokutek Inc.  All rights reserved."
 
91
 
 
92
#include <toku_portability.h>
 
93
#include "test.h"
 
94
#include <stdio.h>
 
95
#include <errno.h>
 
96
#include <string.h>
 
97
 
 
98
#include "sub_block.h"
 
99
 
 
100
static void
 
101
test_sub_block_index(void) {
 
102
    if (verbose)
 
103
        printf("%s:%d\n", __FUNCTION__, __LINE__);
 
104
    
 
105
    const int n_sub_blocks = max_sub_blocks;
 
106
    struct sub_block sub_block[n_sub_blocks];
 
107
    
 
108
    size_t max_offset = 0;
 
109
    for (int i = 0 ; i < n_sub_blocks; i++) {
 
110
        size_t size = i+1;
 
111
        sub_block_init(&sub_block[i]);
 
112
        sub_block[i].uncompressed_size = size;
 
113
        max_offset += size;
 
114
    }
 
115
    
 
116
    int offset_to_sub_block[max_offset];
 
117
    for (int i = 0; i < (int) max_offset; i++)
 
118
        offset_to_sub_block[i] = -1;
 
119
 
 
120
    size_t start_offset = 0;
 
121
    for (int i = 0; i < n_sub_blocks; i++) {
 
122
        size_t size = sub_block[i].uncompressed_size;
 
123
        for (int j = 0; j < (int) (start_offset + size); j++) {
 
124
            if (offset_to_sub_block[j] == -1)
 
125
                offset_to_sub_block[j] = i;
 
126
        }
 
127
        start_offset += size;
 
128
    }
 
129
 
 
130
    int r;
 
131
    for (size_t offset = 0; offset < max_offset; offset++) {
 
132
        r = get_sub_block_index(n_sub_blocks, sub_block, offset);
 
133
        if (verbose)
 
134
            printf("%s:%d %u %d\n", __FUNCTION__, __LINE__, (unsigned int) offset, r);
 
135
        assert(0 <= r && r < n_sub_blocks);
 
136
        assert(r == offset_to_sub_block[offset]);
 
137
    }
 
138
    
 
139
    r = get_sub_block_index(n_sub_blocks, sub_block, max_offset);
 
140
    assert(r == -1);
 
141
}
 
142
 
 
143
int
 
144
test_main (int argc, const char *argv[]) {
 
145
    int i;
 
146
    for (i=1; i<argc; i++) {
 
147
        const char *arg = argv[i];
 
148
        if (strcmp(arg, "-v") == 0)
 
149
            verbose++;
 
150
    }
 
151
    test_sub_block_index();
 
152
    return 0;
 
153
}