mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
fix: do not append .bin extension when -output filename has .out/exe
- effective only when -output_no_suffix is also passed
- this change allows to keep backwards compatibility before:
0c5264dfeb
Related-To: NEO-7474
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d9be9b32f7
commit
1498ae30bd
@@ -2641,6 +2641,47 @@ TEST(OfflineCompilerTest, givenOutputNoSuffixFlagAndNonEmptyOutputFileNameAndNon
|
||||
EXPECT_EQ("12345678", outputFileIt->second);
|
||||
}
|
||||
|
||||
TEST(OfflineCompilerTest, givenOutputNoSuffixFlagAndOutputFileNameWithExtensionOutWhenWritingOutAllFilesThenBinaryFileDoesNotHaveExtensionBinAdded) {
|
||||
MockOfflineCompiler mockOfflineCompiler{};
|
||||
mockOfflineCompiler.uniqueHelper->interceptOutput = true;
|
||||
|
||||
mockOfflineCompiler.outputNoSuffix = true;
|
||||
mockOfflineCompiler.outputFile = "some_output_filename.out";
|
||||
mockOfflineCompiler.elfBinary = {49, 50, 51, 52, 53, 54, 55, 56}; // ASCII codes of "12345678"
|
||||
|
||||
mockOfflineCompiler.writeOutAllFiles();
|
||||
|
||||
const auto outputFileIt = mockOfflineCompiler.uniqueHelper->interceptedFiles.find("some_output_filename.out");
|
||||
ASSERT_NE(mockOfflineCompiler.uniqueHelper->interceptedFiles.end(), outputFileIt);
|
||||
|
||||
mockOfflineCompiler.uniqueHelper->interceptedFiles.clear();
|
||||
mockOfflineCompiler.outputFile = "some_output_filename.out1";
|
||||
mockOfflineCompiler.writeOutAllFiles();
|
||||
|
||||
const auto outputFileIt2 = mockOfflineCompiler.uniqueHelper->interceptedFiles.find("some_output_filename.out1.bin");
|
||||
ASSERT_NE(mockOfflineCompiler.uniqueHelper->interceptedFiles.end(), outputFileIt2);
|
||||
}
|
||||
TEST(OfflineCompilerTest, givenOutputNoSuffixFlagAndOutputFileNameWithExtensionExeWhenWritingOutAllFilesThenBinaryFileDoesNotHaveExtensionBinAdded) {
|
||||
MockOfflineCompiler mockOfflineCompiler{};
|
||||
mockOfflineCompiler.uniqueHelper->interceptOutput = true;
|
||||
|
||||
mockOfflineCompiler.outputNoSuffix = true;
|
||||
mockOfflineCompiler.outputFile = "some_output_filename.exe";
|
||||
mockOfflineCompiler.elfBinary = {49, 50, 51, 52, 53, 54, 55, 56}; // ASCII codes of "12345678"
|
||||
|
||||
mockOfflineCompiler.writeOutAllFiles();
|
||||
|
||||
const auto outputFileIt = mockOfflineCompiler.uniqueHelper->interceptedFiles.find("some_output_filename.exe");
|
||||
ASSERT_NE(mockOfflineCompiler.uniqueHelper->interceptedFiles.end(), outputFileIt);
|
||||
|
||||
mockOfflineCompiler.uniqueHelper->interceptedFiles.clear();
|
||||
mockOfflineCompiler.outputFile = "some_output_filename.exe1";
|
||||
mockOfflineCompiler.writeOutAllFiles();
|
||||
|
||||
const auto outputFileIt2 = mockOfflineCompiler.uniqueHelper->interceptedFiles.find("some_output_filename.exe1.bin");
|
||||
ASSERT_NE(mockOfflineCompiler.uniqueHelper->interceptedFiles.end(), outputFileIt2);
|
||||
}
|
||||
|
||||
TEST(OfflineCompilerTest, givenInputFileNameAndOutputNoSuffixFlagAndEmptyOutputFileNameAndNonEmptyElfContentWhenWritingOutAllFilesThenFileWithTruncatedInputNameIsWritten) {
|
||||
MockOfflineCompiler mockOfflineCompiler{};
|
||||
mockOfflineCompiler.uniqueHelper->interceptOutput = true;
|
||||
|
||||
@@ -1158,7 +1158,22 @@ void OfflineCompiler::writeOutAllFiles() {
|
||||
if (!elfBinary.empty()) {
|
||||
std::string elfOutputFile;
|
||||
if (outputNoSuffix) {
|
||||
elfOutputFile = generateFilePath(outputDirectory, fileBase, ".bin");
|
||||
// temporary fix for backwards compatibility with oneAPI 2023.1 and older
|
||||
// after adding ".bin" extension to name of binary output file
|
||||
// if "-output filename" is passed with ".out" or ".exe" extension - do not append ".bin"
|
||||
if (outputFile.empty()) {
|
||||
elfOutputFile = generateFilePath(outputDirectory, fileBase, ".bin");
|
||||
} else {
|
||||
size_t extPos = fileBase.find_last_of(".", fileBase.size());
|
||||
std::string fileExt = ".bin";
|
||||
if (extPos != std::string::npos) {
|
||||
auto existingExt = fileBase.substr(extPos, fileBase.size());
|
||||
if (existingExt == ".out" || existingExt == ".exe") {
|
||||
fileExt = "";
|
||||
}
|
||||
}
|
||||
elfOutputFile = generateFilePath(outputDirectory, fileBase, fileExt.c_str());
|
||||
}
|
||||
} else {
|
||||
elfOutputFile = generateFilePath(outputDirectory, fileBase, ".bin") + generateOptsSuffix();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user