SWDEV-391583: Set default outputdir when filename is specified

Change-Id: I9765582cc0dc870906d0ec16aa9ca38e990e0ef8
이 커밋은 다음에 포함됨:
Giovanni LB
2023-05-17 23:38:36 -03:00
커밋한 사람 Giovanni Baraldi
부모 d0326a0a28
커밋 1b5fed173c
5개의 변경된 파일119개의 추가작업 그리고 4개의 파일을 삭제
+90 -1
파일 보기
@@ -30,6 +30,7 @@ THE SOFTWARE.
#include <string>
#include <thread>
#include <array>
//#include <experimental/filesystem>
#include "src/utils/helper.h"
#include "utils/test_utils.h"
@@ -61,6 +62,7 @@ static void init_test_path() {
}
}
/**
* Sets application enviornment by seting HSA_TOOLS_LIB.
*/
@@ -1307,4 +1309,91 @@ TEST(ProfilerMPTest, WhenRunningMultiProcessTestItPasses) {
} else { // failure
ASSERT_TRUE(1);
}
}
}
/*
* ###################################################
* ############ File plugin tests ################
* ###################################################
*/
/**
* Sets application output dir.
*/
/*
void FilePluginTest::RunApplication(const char* app_name, const char* appParams) {
if (is_installed_path()) return; // Only run these tests from build
init_test_path();
unsetenv("OUTPUT_FOLDER");
std::stringstream os;
os << binary_path << " --hsa-activity " << appParams << " ";
os << test_app_path << app_name;
ProcessApplication(os);
}
bool FilePluginTest::hasFileInDir(const std::string& filename, const char* directory) {
if (is_installed_path()) return true; // Only run these tests from build
for (const auto& entry : std::experimental::filesystem::directory_iterator(directory)) {
if (filename.size() == 0)
return true;
if (std::string(entry.path().filename()).substr(0, filename.size()) == filename)
return true;
}
return false;
}
void FilePluginTest::ProcessApplication(std::stringstream& ss) {
FILE* handle = popen(ss.str().c_str(), "r");
ASSERT_NE(handle, nullptr);
pclose(handle);
}
class VectorAddFileOnlyTest : public FilePluginTest {
protected:
virtual void SetUp() {
RunApplication("hip_vectoradd", "-o file_test_name");
}
virtual void TearDown() {
std::string filename = "file_test_name";
for (const auto& entry : std::experimental::filesystem::directory_iterator("./"))
if (std::string(entry.path().filename()).substr(0, filename.size()) == filename)
std::experimental::filesystem::remove(entry);
}
bool hasFile(){ return hasFileInDir("file_test_name", "."); }
};
TEST_F(VectorAddFileOnlyTest, WhenRunningProfilerWithOnlyOutputFilenameSetTest) {
EXPECT_EQ(hasFile(), true);
}
class VectorAddFolderOnlyTest : public FilePluginTest {
protected:
virtual void SetUp() {
RunApplication("hip_vectoradd", "-d ./plugin_test_folder_path");
}
virtual void TearDown() { std::experimental::filesystem::remove_all("./plugin_test_folder_path"); }
bool hasFile(){ return hasFileInDir("", "./plugin_test_folder_path"); }
};
TEST_F(VectorAddFolderOnlyTest, WhenRunningProfilerWithOnlyOutputFilenameSetTest) {
EXPECT_EQ(hasFile(), true);
}
class VectorAddFileAndFolderTest : public FilePluginTest {
protected:
virtual void SetUp() {
RunApplication("hip_vectoradd", "-d ./plugin_test_folder_path -o file_test_name");
}
virtual void TearDown() { std::experimental::filesystem::remove_all("./plugin_test_folder_path"); }
bool hasFile(){ return hasFileInDir("file_test_name", "./plugin_test_folder_path"); }
};
TEST_F(VectorAddFileAndFolderTest, WhenRunningProfilerWithOnlyOutputFilenameSetTest) {
EXPECT_EQ(hasFile(), true);
}
*/
+22
파일 보기
@@ -106,4 +106,26 @@ class ProfilerTest : public ApplicationParser {
protected:
virtual void SetUp(const char* app_name) { ApplicationParser::SetUp(app_name); }
};
/* --------------------------------------------------------------------------*/
/**
* @Synopsis Base class for file plugin tests.
* The file test will check wether certain filenames are created.
* Currently, file plugin tests only from build as they need to create files.
*/
/* --------------------------------------------------------------------------*/
/*
class FilePluginTest : public ::testing::Test {
public:
//!< Sets application environment by seting rocprofv2.
void RunApplication(const char* app_name, const char* appParams);
//!< Checks wether a file beginning with "filename" exists in "directory"
static bool hasFileInDir(const std::string& filename, const char* directory);
private:
//!< Runs a given appllication with the hsa activity.
void ProcessApplication(std::stringstream& ss);
}; */
#endif // TESTS_FEATURETESTS_PROFILER_GTESTS_APPS_PROFILER_GTEST_H_