]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2831] Use chmod() function instead of calling a program
authorMukund Sivaraman <muks@isc.org>
Tue, 9 Apr 2013 08:02:26 +0000 (13:32 +0530)
committerMukund Sivaraman <muks@isc.org>
Tue, 9 Apr 2013 08:02:26 +0000 (13:32 +0530)
src/lib/util/tests/memory_segment_mapped_unittest.cc

index aee50b4b194920b7d0ac2cf154f9a3b5e3f1ad21..71f3e0721fb5369e5ccd2cb6b0e4094e800debb1 100644 (file)
@@ -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);
 }