From 7330c1aae9b7309a15366eaf1fcc1fd71e204713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=A4=A9=E5=B3=B0-Rango?= Date: Thu, 8 Apr 2021 18:43:23 +0800 Subject: [PATCH] fix core tests (#4138) --- core-tests/src/coroutine/hook.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core-tests/src/coroutine/hook.cpp b/core-tests/src/coroutine/hook.cpp index 83d49119bb7..cb55525a4a5 100644 --- a/core-tests/src/coroutine/hook.cpp +++ b/core-tests/src/coroutine/hook.cpp @@ -215,18 +215,23 @@ TEST(coroutine_hook, flock) { } TEST(coroutine_hook, read_dir) { - auto fn = []() { + auto fp = opendir("/tmp"); + std::string dir1(readdir(fp)->d_name); + std::string dir2(readdir(fp)->d_name); + closedir(fp); + + auto fn = [&]() { auto fp = swoole_coroutine_opendir("/tmp"); ASSERT_NE(fp, nullptr); struct dirent *entry; entry = swoole_coroutine_readdir(fp); ASSERT_NE(entry, nullptr); - ASSERT_STREQ(entry->d_name, "."); + ASSERT_STREQ(entry->d_name, dir1.c_str()); entry = swoole_coroutine_readdir(fp); ASSERT_NE(entry, nullptr); - ASSERT_STREQ(entry->d_name, ".."); + ASSERT_STREQ(entry->d_name, dir2.c_str()); swoole_coroutine_closedir(fp); };