SWDEV-391583: Set default outputdir when filename is specified
Change-Id: I9765582cc0dc870906d0ec16aa9ca38e990e0ef8
このコミットが含まれているのは:
1 親
d0326a0a28
コミット
1b5fed173c
5ファイル変更
+119
-4
検索条件に一致するファイルはありません
+1
-1
@@ -233,4 +233,4 @@ The resulting `a.out` will depend on
|
|||||||
- Samples are fixed to show the new usage of phases.
|
- Samples are fixed to show the new usage of phases.
|
||||||
- Plugin option validates the plugin names.
|
- Plugin option validates the plugin names.
|
||||||
- Fixing rocsys, for rocsys options, rocsys -h can be called
|
- Fixing rocsys, for rocsys options, rocsys -h can be called
|
||||||
|
- "--output-file" option ignored when no output folder was specified.
|
||||||
+3
-1
@@ -77,12 +77,14 @@ class file_plugin_t {
|
|||||||
const char* output_dir = getenv("OUTPUT_PATH");
|
const char* output_dir = getenv("OUTPUT_PATH");
|
||||||
output_file_name = getenv("OUT_FILE_NAME") ? std::string(getenv("OUT_FILE_NAME")) + "_" : "";
|
output_file_name = getenv("OUT_FILE_NAME") ? std::string(getenv("OUT_FILE_NAME")) + "_" : "";
|
||||||
|
|
||||||
if (output_dir == nullptr) {
|
if (output_dir == nullptr && getenv("OUT_FILE_NAME") == nullptr) {
|
||||||
stream_.copyfmt(std::cout);
|
stream_.copyfmt(std::cout);
|
||||||
stream_.clear(std::cout.rdstate());
|
stream_.clear(std::cout.rdstate());
|
||||||
stream_.basic_ios<char>::rdbuf(std::cout.rdbuf());
|
stream_.basic_ios<char>::rdbuf(std::cout.rdbuf());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (output_dir == nullptr)
|
||||||
|
output_dir = "./";
|
||||||
|
|
||||||
fs::path output_prefix(output_dir);
|
fs::path output_prefix(output_dir);
|
||||||
if (!fs::is_directory(fs::status(output_prefix))) {
|
if (!fs::is_directory(fs::status(output_prefix))) {
|
||||||
|
|||||||
@@ -97,12 +97,14 @@ class perfetto_plugin_t {
|
|||||||
const char* temp_file_name = getenv("OUT_FILE_NAME");
|
const char* temp_file_name = getenv("OUT_FILE_NAME");
|
||||||
output_file_name = temp_file_name ? std::string(temp_file_name) + "_" : "";
|
output_file_name = temp_file_name ? std::string(temp_file_name) + "_" : "";
|
||||||
|
|
||||||
if (output_dir == nullptr) {
|
if (output_dir == nullptr && temp_file_name == nullptr) {
|
||||||
stream_.copyfmt(std::cout);
|
stream_.copyfmt(std::cout);
|
||||||
stream_.clear(std::cout.rdstate());
|
stream_.clear(std::cout.rdstate());
|
||||||
stream_.basic_ios<char>::rdbuf(std::cout.rdbuf());
|
stream_.basic_ios<char>::rdbuf(std::cout.rdbuf());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (output_dir == nullptr)
|
||||||
|
output_dir = "./";
|
||||||
|
|
||||||
output_prefix_ = output_dir;
|
output_prefix_ = output_dir;
|
||||||
if (!fs::is_directory(fs::status(output_prefix_))) {
|
if (!fs::is_directory(fs::status(output_prefix_))) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ THE SOFTWARE.
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
//#include <experimental/filesystem>
|
||||||
|
|
||||||
#include "src/utils/helper.h"
|
#include "src/utils/helper.h"
|
||||||
#include "utils/test_utils.h"
|
#include "utils/test_utils.h"
|
||||||
@@ -61,6 +62,7 @@ static void init_test_path() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets application enviornment by seting HSA_TOOLS_LIB.
|
* Sets application enviornment by seting HSA_TOOLS_LIB.
|
||||||
*/
|
*/
|
||||||
@@ -1307,4 +1309,91 @@ TEST(ProfilerMPTest, WhenRunningMultiProcessTestItPasses) {
|
|||||||
} else { // failure
|
} else { // failure
|
||||||
ASSERT_TRUE(1);
|
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);
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -106,4 +106,26 @@ class ProfilerTest : public ApplicationParser {
|
|||||||
protected:
|
protected:
|
||||||
virtual void SetUp(const char* app_name) { ApplicationParser::SetUp(app_name); }
|
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_
|
#endif // TESTS_FEATURETESTS_PROFILER_GTESTS_APPS_PROFILER_GTEST_H_
|
||||||
新しいイシューから参照
ユーザーをブロックする