diff --git a/test_packages.gni b/test_packages.gni index 8a6e5d4d7e4d2e201018238593b341b6f2188996..176910d606f2bba72edc649194bce23c27819f8c 100644 --- a/test_packages.gni +++ b/test_packages.gni @@ -47,6 +47,7 @@ _all_test_packages = [ "${ACTS_ROOT}/barrierfree:barrierfree", "${ACTS_ROOT}/customization:customization", "${ACTS_ROOT}/distributedschedule:distributedschedule", + "${ACTS_ROOT}/toolchain:toolchain", ] _all_test_packages_ivi = [ diff --git a/toolchain/BUILD.gn b/toolchain/BUILD.gn index 411eb94985bbd2d1ca2dd3ee3bd7ed553253b950..10fb0f442f5d5f75af6832896737a66502332242 100644 --- a/toolchain/BUILD.gn +++ b/toolchain/BUILD.gn @@ -15,6 +15,9 @@ import("//test/xts/tools/build/suite.gni") group("toolchain") { testonly = true + deps = [ + "//third_party/musl:libctest", + ] if (is_standard_system) { deps = [ #":tar_testcases", diff --git a/toolchain/libc-test/include/getfiles.cpp b/toolchain/libc-test/include/getfiles.cpp index 2c7554c7284eff209519b4191b842efe89aa0bb9..053e3b1a76fe3a606991edc1ab87522d81e5c5a1 100644 --- a/toolchain/libc-test/include/getfiles.cpp +++ b/toolchain/libc-test/include/getfiles.cpp @@ -17,28 +17,24 @@ #include #include #include +#include "gettestfiles.cpp" #include "runtest.h" -void GetFileNames(std::string path, std::vector& filenames) +using namespace std; +vector filenames; + +vector GetFileNames(std::string path) { - DIR *pDir; - struct dirent* ptr; - std::string p; - if (!(pDir = opendir(path.c_str()))) { - std::cout << "Folder doesn't Exist!" << std::endl; - return; - } - while ((ptr = readdir(pDir)) != nullptr) { - if (ptr->d_type == DT_DIR) { - if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) { - GetFileNames(path + "/" + ptr->d_name, filenames); - } - } else { - if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) { - filenames.push_back(path + "/" + ptr->d_name); - } + vector tempName; + GetTestNames(path, tempName); + for (size_t i = 0; i < tempName.size(); i++) { + if ((tempName[i].find("stat", path.length()-1) != -1) || + (tempName[i].find("sem_close-unmap", path.length()-1) != -1) || + (tempName[i].find("runtest", path.length()-1) != -1)) { + continue; } + filenames.push_back(tempName[i]); } - closedir(pDir); + return filenames; } \ No newline at end of file diff --git a/toolchain/libc-test/include/runtest.h b/toolchain/libc-test/include/runtest.h index 5ba4aef43e6b10d98e6a64735607e4979ab4f941..ddf282da053b686f8213d769523f23d4559c565e 100644 --- a/toolchain/libc-test/include/runtest.h +++ b/toolchain/libc-test/include/runtest.h @@ -20,6 +20,6 @@ #include int t_setrlim(int r, long lim); -void GetFileNames(std::string path, std::vector& filenames); +std::vector GetFileNames(std::string path); #endif // TOOLCHAIN_LIBC_TEST_INCLUDE_RUNTEST_H_ diff --git a/toolchain/libc-test/src/toolchaintest.cpp b/toolchain/libc-test/src/toolchaintest.cpp index 706bca17e2e37ec8c25d32f17259f7859e90ab34..98bc35a13355c2b4de8cf4fb3abbef2039343e1e 100644 --- a/toolchain/libc-test/src/toolchaintest.cpp +++ b/toolchain/libc-test/src/toolchaintest.cpp @@ -32,8 +32,10 @@ using namespace std; using namespace testing::ext; -class toolchaintest : public testing::Test {}; +class ToolChainTest : public ::testing::TestWithParam {}; +static string filepath = "/data/local/tmp/libc-test/src"; +static vector temp = GetFileNames(filepath); volatile int t_status = 0; static void handler(int s) @@ -54,7 +56,7 @@ static int start(char *wrap, const char *argvs) return pid; } -static int runtests(const char *argvs) +static int runTests(const char *argvs) { char wrap[] = ""; int timeoutsec = 5, timeout = 0; @@ -109,23 +111,20 @@ static int runtests(const char *argvs) } /** - * @tc.name : toolchaintest.LibcTest + * @tc.name : ToolChainTest.LibcTest * @tc.desc : start test * @tc.level : Level 2 */ -static HWTEST_F(toolchaintest, LibcTest, Function | MediumTest | Level3) +static HWTEST_F(ToolChainTest, LibcTest, Function | MediumTest | Level3) { int ret; - vector temp; - string filepath = "/data/local/tmp/libc-test/src"; - GetFileNames(filepath, temp); - for (size_t i = 0; i < temp.size(); i++) { - if ((temp[i].find("stat", filepath.length()-1) != -1) || - (temp[i].find("sem_close-unmap", filepath.length()-1) != -1) || - (temp[i].find("runtest", filepath.length()-1) != -1)) { - continue; - } - ret = runtests(temp[i].c_str()); - EXPECT_EQ(0, ret) << "test " << temp[i] << " failed" << endl; + string testName = GetParam(); + ret = runTests(testName.c_str()); + if (ret == 0) { + EXPECT_EQ(0, ret) << "test " << testName << " succeed" << endl; + } else { + EXPECT_EQ(1, ret) << "test " << testName << " failed" << endl; + EXPECT_EQ(-1, ret) << "test " << testName << " failed" << endl; } } +INSTANTIATE_TEST_CASE_P(libcTest, ToolChainTest, testing:: ValuesIn(temp.begin(), temp.end()));