BIND 10 trac2831, updated. b215e58d58791c27f6116f65b66243b7a54ec14b [2831] Make some more minor comment updates
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Apr 9 08:42:46 UTC 2013
The branch, trac2831 has been updated
via b215e58d58791c27f6116f65b66243b7a54ec14b (commit)
via 58825bde4cbb00eb52ff5bc31a1d170594a26d87 (commit)
from 5d1b066a7702c075d7934a3ce88181b1c02da878 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b215e58d58791c27f6116f65b66243b7a54ec14b
Author: Mukund Sivaraman <muks at isc.org>
Date: Tue Apr 9 14:12:34 2013 +0530
[2831] Make some more minor comment updates
commit 58825bde4cbb00eb52ff5bc31a1d170594a26d87
Author: Mukund Sivaraman <muks at isc.org>
Date: Tue Apr 9 13:32:26 2013 +0530
[2831] Use chmod() function instead of calling a program
-----------------------------------------------------------------------
Summary of changes:
.../util/tests/memory_segment_mapped_unittest.cc | 36 ++++++++++++--------
1 file changed, 21 insertions(+), 15 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/util/tests/memory_segment_mapped_unittest.cc b/src/lib/util/tests/memory_segment_mapped_unittest.cc
index aee50b4..cf736a9 100644
--- a/src/lib/util/tests/memory_segment_mapped_unittest.cc
+++ b/src/lib/util/tests/memory_segment_mapped_unittest.cc
@@ -31,6 +31,7 @@
#include <stdexcept>
#include <fstream>
#include <string>
+#include <sys/stat.h>
using namespace isc::util;
using boost::scoped_ptr;
@@ -170,8 +171,9 @@ TEST_F(MemorySegmentMappedTest, allocate) {
TEST_F(MemorySegmentMappedTest, badAllocate) {
// Make the mapped file non-writable; managed_mapped_file::grow() will
// fail, resulting in std::bad_alloc
- const std::string chmod_cmd = "chmod 444 " + std::string(mapped_file);
- std::system(chmod_cmd.c_str());
+ const int ret = chmod(mapped_file, 0444);
+ ASSERT_EQ(0, ret);
+
EXPECT_THROW(segment_->allocate(DEFAULT_INITIAL_SIZE * 2), std::bad_alloc);
}
@@ -248,26 +250,27 @@ TEST_F(MemorySegmentMappedTest, nullDeallocate) {
TEST_F(MemorySegmentMappedTest, shrink) {
segment_->shrinkToFit();
- // Normally we should be able to expect the resulting size is the smaller
- // than the initial default size. It's not really guaranteed by the API,
- // however, so we may have to disable this check.
+ // Normally we should be able to expect that the resulting size is
+ // smaller than the initial default size. But it's not really
+ // guaranteed by the API, so we may have to disable this check (or
+ // use EXPECT_GE).
const size_t shrinked_size = segment_->getSize();
EXPECT_GT(DEFAULT_INITIAL_SIZE, shrinked_size);
- // Another shrink shouldn't cause disruption, and the size shouldn't change
+ // Another shrink shouldn't cause disruption, and the size shouldn't
+ // change.
segment_->shrinkToFit();
EXPECT_EQ(shrinked_size, segment_->getSize());
- // Check the segment is still usable after shrink.
+ // Check that the segment is still usable after shrink.
void* p = segment_->allocate(sizeof(uint32_t));
segment_->deallocate(p, sizeof(uint32_t));
}
TEST_F(MemorySegmentMappedTest, violateReadOnly) {
- // If the segment is opened in the read only mode, modification attempts
- // are prohibited. when detectable it's result in an exception;
- // an attempt of not directly through the segment class will result in
- // crash.
+ // If the segment is opened in the read-only mode, modification
+ // attempts are prohibited. When detectable it must result in an
+ // exception.
EXPECT_THROW(MemorySegmentMapped(mapped_file).allocate(16),
isc::InvalidOperation);
// allocation that would otherwise require growing the segment; permission
@@ -285,6 +288,8 @@ TEST_F(MemorySegmentMappedTest, violateReadOnly) {
void* ptr = segment_->allocate(sizeof(uint32_t));
segment_->setNamedAddress("test address", ptr);
+ // Attempts to modify memory from the read-only segment directly
+ // will result in a crash.
if (!isc::util::unittests::runningOnValgrind()) {
EXPECT_DEATH_IF_SUPPORTED({
MemorySegmentMapped segment_ro(mapped_file);
@@ -301,10 +306,11 @@ TEST_F(MemorySegmentMappedTest, violateReadOnly) {
TEST_F(MemorySegmentMappedTest, getCheckSum) {
const size_t old_cksum = segment_->getCheckSum();
- // We assume the initial segment size is sufficiently larger than the
- // page size. We'll allocate memory of the page size, and increment all
- // bytes in that region by one. It will increase our simple checksum value
- // by one, too.
+ // We assume the initial segment size is sufficiently larger than
+ // the page size. We'll allocate memory of the page size, and
+ // increment all bytes in that page by one. It will increase our
+ // simple checksum value (which just uses the first byte of each
+ // page) by one, too.
const size_t page_sz = boost::interprocess::mapped_region::get_page_size();
uint8_t* cp0 = static_cast<uint8_t*>(segment_->allocate(page_sz));
for (uint8_t* cp = cp0; cp < cp0 + page_sz; ++cp) {
More information about the bind10-changes
mailing list