SWDEV-391583: Set default outputdir when filename is specified

Change-Id: I9765582cc0dc870906d0ec16aa9ca38e990e0ef8
This commit is contained in:
Giovanni LB
2023-05-17 23:38:36 -03:00
committed by Giovanni Baraldi
parent d0326a0a28
commit 1b5fed173c
5 changed files with 119 additions and 4 deletions
+90 -1
View File
@@ -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);
}
*/