zone_table_segment_mapped_unittest.cc 19.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.

#include <datasrc/memory/zone_writer.h>
#include <datasrc/memory/zone_table_segment_mapped.h>
17
18
#include <util/random/random_number_generator.h>
#include <util/unittests/check_valgrind.h>
19
20

#include <gtest/gtest.h>
21
#include <boost/format.hpp>
22
23
24
#include <boost/scoped_ptr.hpp>
#include <boost/interprocess/file_mapping.hpp>

25
#include <memory>
26
27
#include <cerrno>

28
29
#include <sys/stat.h>

30
31
32
33
using namespace isc::dns;
using namespace isc::datasrc::memory;
using namespace isc::data;
using namespace isc::util;
34
using namespace isc::util::random;
35
36
37
38
39
using namespace std;
using boost::scoped_ptr;

namespace {

40
const char* const mapped_file  = TEST_DATA_BUILDDIR "/test.mapped";
41
const char* const mapped_file2 = TEST_DATA_BUILDDIR "/test2.mapped";
42
43
44
45

class ZoneTableSegmentMappedTest : public ::testing::Test {
protected:
    ZoneTableSegmentMappedTest() :
46
47
        ztable_segment_(
            ZoneTableSegment::create(RRClass::IN(), "mapped")),
48
        config_params_(
49
            Element::fromJSON(
Mukund Sivaraman's avatar
Mukund Sivaraman committed
50
51
52
53
                "{\"mapped-file\": \"" + std::string(mapped_file) + "\"}")),
        config_params2_(
            Element::fromJSON(
                "{\"mapped-file\": \"" + std::string(mapped_file2) + "\"}"))
54
    {
55
        EXPECT_NE(static_cast<void*>(NULL), ztable_segment_.get());
56
57
        // Verify that a ZoneTableSegmentMapped is created.
        ZoneTableSegmentMapped* mapped_segment =
58
            dynamic_cast<ZoneTableSegmentMapped*>(ztable_segment_.get());
59
        EXPECT_NE(static_cast<void*>(NULL), mapped_segment);
60
61

        createTestData();
62
    }
63
64

    ~ZoneTableSegmentMappedTest() {
65
        ZoneTableSegment::destroy(ztable_segment_.release());
66
        boost::interprocess::file_mapping::remove(mapped_file);
Mukund Sivaraman's avatar
Mukund Sivaraman committed
67
        boost::interprocess::file_mapping::remove(mapped_file2);
68
69
    }

70
71
72
73
74
75
76
77
78
79
80
    typedef std::pair<std::string, int> TestDataElement;

    void createTestData() {
        UniformRandomIntegerGenerator gen(0, INT_MAX);
        for (int i = 0; i < 256; ++i) {
            const string name(boost::str(boost::format("name%d") % i));
            const int value = gen();
            test_data_.push_back(TestDataElement(name, value));
        }
    }

Mukund Sivaraman's avatar
Mukund Sivaraman committed
81
    void setupMappedFiles();
82
83
    void addData(MemorySegment& segment);
    bool verifyData(const MemorySegment& segment);
Mukund Sivaraman's avatar
Mukund Sivaraman committed
84

85
86
87
    // Ideally, this should be something similar to a
    // SegmentObjectHolder, not an auto_ptr.
    std::auto_ptr<ZoneTableSegment> ztable_segment_;
88
    const ConstElementPtr config_params_;
Mukund Sivaraman's avatar
Mukund Sivaraman committed
89
    const ConstElementPtr config_params2_;
90
    std::vector<TestDataElement> test_data_;
91
92
};

93
94
95
96
97
98
99
100
101
102
103
bool
fileExists(const char* path) {
    struct stat sb;
    const int status = stat(path, &sb);
    if (status != 0) {
        EXPECT_EQ(ENOENT, errno);
        return (false);
    }
    return (true);
}

Mukund Sivaraman's avatar
Mukund Sivaraman committed
104
105
106
107
108
109
110
111
112
113
114
115
void
deleteChecksum(MemorySegment& segment) {
    segment.clearNamedAddress("zone_table_checksum");
}

void
corruptChecksum(MemorySegment& segment) {
    const MemorySegment::NamedAddressResult result =
        segment.getNamedAddress("zone_table_checksum");
    ASSERT_TRUE(result.first);

    size_t checksum = *static_cast<size_t*>(result.second);
116
    ++checksum;
Mukund Sivaraman's avatar
Mukund Sivaraman committed
117
118
119
120
121
122
123
124
    *static_cast<size_t*>(result.second) = checksum;
}

void
deleteHeader(MemorySegment& segment) {
    segment.clearNamedAddress("zone_table_header");
}

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
void
ZoneTableSegmentMappedTest::addData(MemorySegment& segment) {
    // For purposes of this test, we assume that the following
    // allocations do not resize the mapped segment. For this, we have
    // to keep the size of test data reasonably small in
    // createTestData().

    // One by one, add all the elements in test_data_.
    for (int i = 0; i < test_data_.size(); ++i) {
        void* ptr = segment.allocate(sizeof(int));
        ASSERT_TRUE(ptr);
        *static_cast<int*>(ptr) = test_data_[i].second;
        const bool grew = segment.setNamedAddress(test_data_[i].first.c_str(),
                                                  ptr);
        ASSERT_FALSE(grew);
    }
}

bool
ZoneTableSegmentMappedTest::verifyData(const MemorySegment& segment) {
    // One by one, verify all the elements in test_data_ exist and have
    // the expected values.
    for (int i = 0; i < test_data_.size(); ++i) {
        const MemorySegment::NamedAddressResult result =
            segment.getNamedAddress(test_data_[i].first.c_str());
        if (!result.first) {
            return (false);
        }
        if (*static_cast<int*>(result.second) != test_data_[i].second) {
            return (false);
        }
    }

    return (true);
}

Mukund Sivaraman's avatar
Mukund Sivaraman committed
161
162
163
void
ZoneTableSegmentMappedTest::setupMappedFiles() {
    ztable_segment_->reset(ZoneTableSegment::CREATE, config_params_);
164
    addData(ztable_segment_->getMemorySegment());
Mukund Sivaraman's avatar
Mukund Sivaraman committed
165
166
167
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

    ztable_segment_->reset(ZoneTableSegment::CREATE, config_params2_);
168
    addData(ztable_segment_->getMemorySegment());
Mukund Sivaraman's avatar
Mukund Sivaraman committed
169
170
171
172
173
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

    // Now, clear the segment, closing the underlying mapped file.
    ztable_segment_->clear();
}
174

175
176
TEST_F(ZoneTableSegmentMappedTest, getHeaderUninitialized) {
    // This should throw as we haven't called reset() yet.
177
    EXPECT_THROW(ztable_segment_->getHeader(), isc::InvalidOperation);
178
179
180
181
}

TEST_F(ZoneTableSegmentMappedTest, getMemorySegmentUninitialized) {
    // This should throw as we haven't called reset() yet.
182
    EXPECT_THROW(ztable_segment_->getMemorySegment(), isc::InvalidOperation);
183
184
185
}

TEST_F(ZoneTableSegmentMappedTest, isWritableUninitialized) {
186
187
188
    // isWritable() must return false by default, when the segment has
    // not been reset() yet.
    EXPECT_FALSE(ztable_segment_->isWritable());
189
190
191
}

TEST_F(ZoneTableSegmentMappedTest, resetBadConfig) {
192
193
194
195
    // Open a mapped file in create mode.
    ztable_segment_->reset(ZoneTableSegment::CREATE, config_params_);

    // Populate it with some data.
196
    addData(ztable_segment_->getMemorySegment());
197
198
199
200
201
202
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

    // All the following resets() with invalid configuration must
    // provide a strong exception guarantee that the segment is still
    // usable as before.

203
204
205
206
207
208
    // NULL is passed in config params
    EXPECT_THROW({
        ztable_segment_->reset(ZoneTableSegment::CREATE,
                               ConstElementPtr());
    }, isc::InvalidParameter);

209
210
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

211
212
    // Not a map
    EXPECT_THROW({
213
        ztable_segment_->reset(ZoneTableSegment::CREATE,
214
215
216
                               Element::fromJSON("42"));
    }, isc::InvalidParameter);

217
218
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

219
220
    // Empty map
    EXPECT_THROW({
221
        ztable_segment_->reset(ZoneTableSegment::CREATE,
222
223
224
                               Element::fromJSON("{}"));
    }, isc::InvalidParameter);

225
226
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

227
228
    // No "mapped-file" key
    EXPECT_THROW({
229
        ztable_segment_->reset(ZoneTableSegment::CREATE,
230
231
232
                               Element::fromJSON("{\"foo\": \"bar\"}"));
    }, isc::InvalidParameter);

233
234
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

235
236
    // Value of "mapped-file" key is not a string
    EXPECT_THROW({
237
        ztable_segment_->reset(ZoneTableSegment::CREATE,
238
239
240
                               Element::fromJSON("{\"mapped-file\": 42}"));
    }, isc::InvalidParameter);

241
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));
242
243
244
245
246
247
}

TEST_F(ZoneTableSegmentMappedTest, reset) {
    // By default, the mapped file doesn't exist, so we cannot open it
    // in READ_ONLY mode (which does not create the file).
    EXPECT_THROW({
248
        ztable_segment_->reset(ZoneTableSegment::READ_ONLY, config_params_);
249
250
251
    }, MemorySegmentOpenError);

    // The following should still throw, unaffected by the failed open.
252
253
    EXPECT_THROW(ztable_segment_->getHeader(), isc::InvalidOperation);
    EXPECT_THROW(ztable_segment_->getMemorySegment(), isc::InvalidOperation);
254
255
256
257

    // isWritable() must still return false, because the segment has not
    // been successfully reset() yet.
    EXPECT_FALSE(ztable_segment_->isWritable());
258
259
260

    // READ_WRITE mode must create the mapped file if it doesn't exist
    // (and must not result in an exception).
261
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);
262
263
264
265
266
267
268
269
    EXPECT_TRUE(ztable_segment_->isWritable());

    // The following method calls should no longer throw:
    EXPECT_NO_THROW(ztable_segment_->getHeader());
    EXPECT_NO_THROW(ztable_segment_->getMemorySegment());

    // Let's try to re-open the mapped file in READ_ONLY mode. It should
    // not fail now.
270
    ztable_segment_->reset(ZoneTableSegment::READ_ONLY, config_params_);
271
272
273
274
275
    EXPECT_FALSE(ztable_segment_->isWritable());

    // Re-creating the mapped file should erase old data and should not
    // trigger any exceptions inside reset() due to old data (such as
    // named addresses).
276
    ztable_segment_->reset(ZoneTableSegment::CREATE, config_params_);
277
278
    EXPECT_TRUE(ztable_segment_->isWritable());

279
280
    // When we reset() with an invalid paramter and it fails, then the
    // segment should still be usable.
281
    EXPECT_THROW({
282
        ztable_segment_->reset(ZoneTableSegment::CREATE,
283
284
                               Element::fromJSON("{}"));
    }, isc::InvalidParameter);
285
286
287
288
    EXPECT_TRUE(ztable_segment_->isWritable());
    // The following should not throw.
    EXPECT_NO_THROW(ztable_segment_->getHeader());
    EXPECT_NO_THROW(ztable_segment_->getMemorySegment());
289
290

    // READ_WRITE with an existing map file ought to work too. This
291
292
    // would use existing named addresses. This actually re-opens the
    // currently open map.
293
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);
294
    EXPECT_TRUE(ztable_segment_->isWritable());
295
296
}

297
298
299
300
301
302
303
304
305
TEST_F(ZoneTableSegmentMappedTest, resetCreate) {
    // At this point, the underlying file must not exist.
    ASSERT_FALSE(fileExists(mapped_file));

    // Open the underlying mapped file in create mode.
    ztable_segment_->reset(ZoneTableSegment::CREATE, config_params_);

    ASSERT_TRUE(ztable_segment_->isWritable());

306
307
    // Add the data.
    addData(ztable_segment_->getMemorySegment());
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

    // Close the segment.
    ztable_segment_->clear();

    // At this point, the underlying file must still exist.
    ASSERT_TRUE(fileExists(mapped_file));

    // Open the underlying mapped file in create mode again.
    ztable_segment_->reset(ZoneTableSegment::CREATE, config_params_);

    // The old data should be gone.
    EXPECT_FALSE(verifyData(ztable_segment_->getMemorySegment()));
}

TEST_F(ZoneTableSegmentMappedTest, resetReadWrite) {
    // At this point, the underlying file must not exist.
    ASSERT_FALSE(fileExists(mapped_file));

    // Open the underlying mapped file in read+write mode.
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);

    ASSERT_TRUE(ztable_segment_->isWritable());

332
333
    // Add the data.
    addData(ztable_segment_->getMemorySegment());
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

    // Close the segment.
    ztable_segment_->clear();

    // At this point, the underlying file must still exist.
    ASSERT_TRUE(fileExists(mapped_file));

    // Open the underlying mapped file in read+write mode again.
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);

    // The old data should still be available.
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));
}

TEST_F(ZoneTableSegmentMappedTest, resetReadOnly) {
    // At this point, the underlying file must not exist.
    ASSERT_FALSE(fileExists(mapped_file));

    // Open the underlying mapped file in read+write mode.
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);

    ASSERT_TRUE(ztable_segment_->isWritable());

358
359
    // Add the data.
    addData(ztable_segment_->getMemorySegment());
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

    // Close the segment.
    ztable_segment_->clear();

    // At this point, the underlying file must still exist.
    ASSERT_TRUE(fileExists(mapped_file));

    // Open the underlying mapped file in read-only mode again.
    ztable_segment_->reset(ZoneTableSegment::READ_ONLY, config_params_);

    // The old data should still be available.
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));

    // But trying to allocate new data should result in an exception as
    // the segment is read-only!
376
    EXPECT_THROW(addData(ztable_segment_->getMemorySegment()),
377
378
379
                 MemorySegmentError);
}

380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
TEST_F(ZoneTableSegmentMappedTest, clearUninitialized) {
    // Clearing a segment that has not been reset() is a nop, as clear()
    // returns it to a fresh uninitialized state anyway.
    EXPECT_NO_THROW(ztable_segment_->clear());

    // The following should still throw, because the segment has not
    // been successfully reset() yet.
    EXPECT_THROW(ztable_segment_->getHeader(), isc::InvalidOperation);
    EXPECT_THROW(ztable_segment_->getMemorySegment(), isc::InvalidOperation);

    // isWritable() must still return false, because the segment has not
    // been successfully reset() yet.
    EXPECT_FALSE(ztable_segment_->isWritable());
}

395
TEST_F(ZoneTableSegmentMappedTest, clear) {
396
397
    // First, open an underlying mapped file in read+write mode (doesn't
    // exist yet)
398
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413

    EXPECT_TRUE(ztable_segment_->isWritable());
    // The following method calls should no longer throw:
    EXPECT_NO_THROW(ztable_segment_->getHeader());
    EXPECT_NO_THROW(ztable_segment_->getMemorySegment());

    // Now, clear the segment.
    ztable_segment_->clear();

    EXPECT_FALSE(ztable_segment_->isWritable());
    // The following method calls should now throw.
    EXPECT_THROW(ztable_segment_->getHeader(), isc::InvalidOperation);
    EXPECT_THROW(ztable_segment_->getMemorySegment(), isc::InvalidOperation);
}

Mukund Sivaraman's avatar
Mukund Sivaraman committed
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
TEST_F(ZoneTableSegmentMappedTest, resetFailedCorruptedChecksum) {
    setupMappedFiles();

    // Open mapped file 1 in read-write mode
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);

    // Corrupt mapped file 2.
    scoped_ptr<MemorySegmentMapped> segment
        (new MemorySegmentMapped(mapped_file2,
                                 MemorySegmentMapped::OPEN_OR_CREATE));
    EXPECT_TRUE(verifyData(*segment));
    corruptChecksum(*segment);
    segment.reset();

    // Opening mapped file 2 in read-write mode should fail
    EXPECT_THROW({
430
        ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params2_);
Mukund Sivaraman's avatar
Mukund Sivaraman committed
431
    }, ResetFailed);
432
433
434
435

    // Check for the old data in the segment to make sure it is still
    // available and correct.
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));
Mukund Sivaraman's avatar
Mukund Sivaraman committed
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
}

TEST_F(ZoneTableSegmentMappedTest, resetFailedMissingChecksum) {
    setupMappedFiles();

    // Open mapped file 1 in read-write mode
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);

    // Corrupt mapped file 2.
    scoped_ptr<MemorySegmentMapped> segment
        (new MemorySegmentMapped(mapped_file2,
                                 MemorySegmentMapped::OPEN_OR_CREATE));
    EXPECT_TRUE(verifyData(*segment));
    deleteChecksum(*segment);
    segment.reset();

    // Opening mapped file 2 in read-only mode should fail
    EXPECT_THROW({
454
        ztable_segment_->reset(ZoneTableSegment::READ_ONLY, config_params2_);
Mukund Sivaraman's avatar
Mukund Sivaraman committed
455
    }, ResetFailed);
456
457
458
459

    // Check for the old data in the segment to make sure it is still
    // available and correct.
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));
Mukund Sivaraman's avatar
Mukund Sivaraman committed
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
}

TEST_F(ZoneTableSegmentMappedTest, resetFailedMissingHeader) {
    setupMappedFiles();

    // Open mapped file 1 in read-write mode
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);

    // Corrupt mapped file 2.
    scoped_ptr<MemorySegmentMapped> segment
        (new MemorySegmentMapped(mapped_file2,
                                 MemorySegmentMapped::OPEN_OR_CREATE));
    EXPECT_TRUE(verifyData(*segment));
    deleteHeader(*segment);
    segment.reset();

    // Opening mapped file 2 in read-only mode should fail
    EXPECT_THROW({
478
        ztable_segment_->reset(ZoneTableSegment::READ_ONLY, config_params2_);
Mukund Sivaraman's avatar
Mukund Sivaraman committed
479
    }, ResetFailed);
480
481
482
483

    // Check for the old data in the segment to make sure it is still
    // available and correct.
    EXPECT_TRUE(verifyData(ztable_segment_->getMemorySegment()));
Mukund Sivaraman's avatar
Mukund Sivaraman committed
484
485
}

486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
TEST_F(ZoneTableSegmentMappedTest, resetCreateOverCorruptedFile) {
    setupMappedFiles();

    // Corrupt mapped file 1.
    scoped_ptr<MemorySegmentMapped> segment
        (new MemorySegmentMapped(mapped_file,
                                 MemorySegmentMapped::OPEN_OR_CREATE));
    EXPECT_TRUE(verifyData(*segment));
    corruptChecksum(*segment);
    segment.reset();

    // Resetting mapped file 1 in CREATE mode over a corrupted file
    // should pass.
    EXPECT_NO_THROW(ztable_segment_->reset(ZoneTableSegment::CREATE,
                                           config_params_));

    // Check for the old data in the segment. It should not be present
    // (as we opened the segment in CREATE mode).
    EXPECT_FALSE(verifyData(ztable_segment_->getMemorySegment()));

    // Now try the same with missing checksum.
    setupMappedFiles();

    // Corrupt mapped file 1.
    segment.reset(new MemorySegmentMapped(mapped_file,
                                          MemorySegmentMapped::OPEN_OR_CREATE));
    EXPECT_TRUE(verifyData(*segment));
    deleteChecksum(*segment);
    segment.reset();

    // Resetting mapped file 1 in CREATE mode over a file missing
    // checksum should pass.
    EXPECT_NO_THROW(ztable_segment_->reset(ZoneTableSegment::CREATE,
                                           config_params_));

    // Check for the old data in the segment. It should not be present
    // (as we opened the segment in CREATE mode).
    EXPECT_FALSE(verifyData(ztable_segment_->getMemorySegment()));
}

526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
TEST_F(ZoneTableSegmentMappedTest, resetHeaderUninitialized) {
    // This should throw as we haven't called reset() yet.
    EXPECT_THROW(ztable_segment_->resetHeader(), isc::InvalidOperation);
}

TEST_F(ZoneTableSegmentMappedTest, resetHeader) {
    // First, open an underlying mapped file in read+write mode (doesn't
    // exist yet)
    ztable_segment_->reset(ZoneTableSegment::READ_WRITE, config_params_);

    // Check if a valid ZoneTable is found.
    {
        const ZoneTableHeader& header = ztable_segment_->getHeader();
        const ZoneTable* table = header.getTable();
        EXPECT_EQ(0, table->getZoneCount());
    }

    // Grow the segment by allocating something large.
    EXPECT_THROW(ztable_segment_->getMemorySegment().allocate(1<<16),
                 MemorySegmentGrown);

    // Reset the header address. This should not throw now.
    EXPECT_NO_THROW(ztable_segment_->resetHeader());

    // Check if a valid ZoneTable is found.
    {
        const ZoneTableHeader& header = ztable_segment_->getHeader();
        const ZoneTable* table = header.getTable();
        EXPECT_EQ(0, table->getZoneCount());
    }
}

558
} // anonymous namespace