• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2022 Huawei Device Co., Ltd.
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  *     http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 
15 #include <iostream>
16 #include <vector>
17 #include <cstring>
18 #include <dirent.h>
19 
20 #include "runtest.h"
21 
GetTestNames(std::string path,std::vector<std::string> & tempName)22 static void GetTestNames(std::string path, std::vector<std::string>& tempName)
23 {
24     DIR *pDir;
25     struct dirent* ptr;
26     std::string  p;
27     if (!(pDir = opendir(path.c_str()))) {
28         std::cout << "Folder doesn't Exist!" << std::endl;
29         return;
30     }
31     while ((ptr = readdir(pDir)) != nullptr) {
32         if (ptr->d_type == DT_DIR) {
33             if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
34                 GetTestNames(path + "/" + ptr->d_name, tempName);
35             }
36         } else {
37             if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
38                 tempName.push_back(path + "/" + ptr->d_name);
39             }
40         }
41     }
42     closedir(pDir);
43 }