Skip to content

Commit

Permalink
Removed flaky UT cases (vesoft-inc#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
sherman-the-tank authored and dutor committed May 7, 2019
1 parent 5560562 commit 5f5eaa7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 45 deletions.
12 changes: 3 additions & 9 deletions src/common/fs/test/FileUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ namespace nebula {
namespace fs {

TEST(FileUtils, readLink) {
{
auto result = FileUtils::readLink("/proc/self/exe");
ASSERT_TRUE(result.ok()) << result.status();
ASSERT_NE(std::string::npos, result.value().find("file_utils_test")) << result.value();
}
{
auto result = FileUtils::readLink("/proc/1/exe");
ASSERT_FALSE(result.ok());
}
auto result = FileUtils::readLink("/proc/self/exe");
ASSERT_TRUE(result.ok()) << result.status();
ASSERT_NE(std::string::npos, result.value().find("file_utils_test")) << result.value();
}


Expand Down
47 changes: 11 additions & 36 deletions src/common/process/test/ProcessTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,18 @@
namespace nebula {

TEST(ProcessUtils, getExePath) {
{
auto result = ProcessUtils::getExePath();
ASSERT_TRUE(result.ok()) << result.status();
ASSERT_NE(std::string::npos, result.value().find("process_test")) << result.value();
}
{
auto result = ProcessUtils::getExePath(1); // systemd
ASSERT_FALSE(result.ok());
}
auto result = ProcessUtils::getExePath();
ASSERT_TRUE(result.ok()) << result.status();
ASSERT_NE(std::string::npos, result.value().find("process_test")) << result.value();
}


TEST(ProcessUtils, getExeCWD) {
{
auto result = ProcessUtils::getExeCWD();
ASSERT_TRUE(result.ok()) << result.status();
char buffer[PATH_MAX];
::getcwd(buffer, sizeof(buffer));
ASSERT_EQ(buffer, result.value());
}
{
auto result = ProcessUtils::getExeCWD(1); // systemd
ASSERT_FALSE(result.ok());
}
auto result = ProcessUtils::getExeCWD();
ASSERT_TRUE(result.ok()) << result.status();
char buffer[PATH_MAX];
::getcwd(buffer, sizeof(buffer));
ASSERT_EQ(buffer, result.value());
}


Expand Down Expand Up @@ -68,12 +56,6 @@ TEST(ProcessUtils, isPidAvailable) {
auto status = ProcessUtils::isPidAvailable(pidFile);
ASSERT_TRUE(status.ok()) << status;
}
{
// pid file not readable
auto pidFile = "/proc/sys/vm/compact_memory";
auto status = ProcessUtils::isPidAvailable(pidFile);
ASSERT_FALSE(status.ok());
}
{
// choose an available pid
auto genPid = [] () {
Expand All @@ -99,16 +81,9 @@ TEST(ProcessUtils, isPidAvailable) {


TEST(ProcessUtils, getProcessName) {
{
auto result = ProcessUtils::getProcessName();
ASSERT_TRUE(result.ok()) << result.status();
ASSERT_NE(std::string::npos, result.value().find("process_test")) << result.value();
}
{
auto result = ProcessUtils::getProcessName(1);
ASSERT_TRUE(result.ok()) << result.status();
ASSERT_EQ("systemd", result.value()) << result.value();
}
auto result = ProcessUtils::getProcessName();
ASSERT_TRUE(result.ok()) << result.status();
ASSERT_NE(std::string::npos, result.value().find("process_test")) << result.value();
}


Expand Down

0 comments on commit 5f5eaa7

Please sign in to comment.