The test case “TestPathUtil.TestODirectFileCreationInDir” fail to pass when I run it with root access.
The error is:
138: TEST FAILURE
...
138: Relevant log lines:
138: [----------] 1 test from TestPathUtil
138: [ RUN ] TestPathUtil.TestODirectFileCreationInDir
138: ../../../../../src/yb/util/path_util-test.cc:88: Failure
138: Value of: (CheckODirectTempFileCreationInDir(env_test, dir)).ok()
138: Actual: true
138: Expected: false
138: Test failure stack trace:
138: ../../../../../src/yb/util/path_util-test.cc:88:
After I added ‘LOG(INFO) << fname.get()<< " fd:"<<fd;’ in function CheckODirectTempFileCreationInDir, I got these:
[----------] 1 test from TestPathUtil
[ RUN ] TestPathUtil.TestODirectFileCreationInDir
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0419 23:32:18.368190 9414 path_util.cc:128] /var/run.tmp.JTD0gl fd:3
../../../../../src/yb/util/path_util-test.cc:88: Failure
Value of: (CheckODirectTempFileCreationInDir(env_test, dir)).ok()
Actual: true
Expected: false
Test failure stack trace:
The /var/run.tmp.JTD0gl was created successfully,
but I guess the fname should have been /var/run/.tmp.JTD0gl, because the relevant code is
string dir = "/var/run"; // in TEST(TestPathUtil, TestODirectFileCreationInDir)
...
ASSERT_NOK(CheckODirectTempFileCreationInDir(env_test, dir)); //in same function as before
...
string name_template = dir_path + kTmpTemplateSuffix;// dir_path==dir, kTmpTemplateSuffix==.tmp.XXXXXX in CheckODirectTempFileCreationInDir
ThreadRestrictions::AssertIOAllowed(); //in same function as before
std::unique_ptr<char[]> fname(new char[name_template.size() + 1]); //in same function as before
::snprintf(fname.get(), name_template.size() + 1, "%s", name_template.c_str()); //in same function as before
I seems that “dir_path + kTmpTemplateSuffix” should be “dir_path + “/”+kTmpTemplateSuffix” because you call “/var/run” a dir not a file prefix.
Plus: Sorry for my poor english(哈哈)