mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 06:23:01 +08:00
Print ocloc cmdline after compilation fail
Related-To: NEO-4784 Change-Id: I451d6e0a67fc185d610e5d2dd4ff6a3f6542ca4c Signed-off-by: Konstanty Misiak <konstanty.misiak@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
dcf708f2d2
commit
86b133207f
@@ -51,6 +51,7 @@ set(IGDRCL_SRCS_offline_compiler_tests
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/decoder/encoder_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/decoder/encoder_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/environment.h
|
${CMAKE_CURRENT_SOURCE_DIR}/environment.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_api_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.h
|
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_validator_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_validator_tests.cpp
|
||||||
|
|||||||
58
opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp
Normal file
58
opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/offline_compiler/source/ocloc_api.h"
|
||||||
|
#include "shared/offline_compiler/source/offline_compiler.h"
|
||||||
|
|
||||||
|
#include "environment.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
extern Environment *gEnvironment;
|
||||||
|
|
||||||
|
using namespace std::string_literals;
|
||||||
|
|
||||||
|
TEST(OclocApiTests, WhenGoodArgsAreGivenThenSuccessIsReturned) {
|
||||||
|
const char *argv[] = {
|
||||||
|
"ocloc",
|
||||||
|
"-file",
|
||||||
|
"test_files/copybuffer.cl",
|
||||||
|
"-device",
|
||||||
|
gEnvironment->devicePrefix.c_str()};
|
||||||
|
unsigned int argc = sizeof(argv) / sizeof(const char *);
|
||||||
|
|
||||||
|
testing::internal::CaptureStdout();
|
||||||
|
int retVal = oclocInvoke(argc, argv,
|
||||||
|
0, nullptr, nullptr, nullptr,
|
||||||
|
0, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr);
|
||||||
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
EXPECT_EQ(retVal, NEO::SUCCESS);
|
||||||
|
EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4]));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(OclocApiTests, WhenArgsWithMissingFileAreGivenThenErrorMessageIsProduced) {
|
||||||
|
const char *argv[] = {
|
||||||
|
"ocloc",
|
||||||
|
"-file",
|
||||||
|
"test_files/IDoNotExist.cl",
|
||||||
|
"-device",
|
||||||
|
gEnvironment->devicePrefix.c_str()};
|
||||||
|
unsigned int argc = sizeof(argv) / sizeof(const char *);
|
||||||
|
|
||||||
|
testing::internal::CaptureStdout();
|
||||||
|
int retVal = oclocInvoke(argc, argv,
|
||||||
|
0, nullptr, nullptr, nullptr,
|
||||||
|
0, nullptr, nullptr, nullptr,
|
||||||
|
nullptr, nullptr, nullptr, nullptr);
|
||||||
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
EXPECT_EQ(retVal, NEO::INVALID_FILE);
|
||||||
|
EXPECT_NE(std::string::npos, output.find("Command was: ocloc -file test_files/IDoNotExist.cl -device "s + argv[4]));
|
||||||
|
}
|
||||||
@@ -58,6 +58,13 @@ Examples:
|
|||||||
)===";
|
)===";
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
void printOclocCmdLine(unsigned int numArgs, const char *argv[], std::unique_ptr<OclocArgHelper> &helper) {
|
||||||
|
helper->printf("Command was:");
|
||||||
|
for (auto i = 0u; i < numArgs; ++i)
|
||||||
|
helper->printf(" %s", argv[i]);
|
||||||
|
helper->printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
int oclocInvoke(unsigned int numArgs, const char *argv[],
|
int oclocInvoke(unsigned int numArgs, const char *argv[],
|
||||||
const uint32_t numSources, const uint8_t **dataSources, const uint64_t *lenSources, const char **nameSources,
|
const uint32_t numSources, const uint8_t **dataSources, const uint64_t *lenSources, const char **nameSources,
|
||||||
const uint32_t numInputHeaders, const uint8_t **dataInputHeaders, const uint64_t *lenInputHeaders, const char **nameInputHeaders,
|
const uint32_t numInputHeaders, const uint8_t **dataInputHeaders, const uint64_t *lenInputHeaders, const char **nameInputHeaders,
|
||||||
@@ -118,14 +125,20 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
|
|||||||
helper->printf("Build failed with error code: %d\n", retVal);
|
helper->printf("Build failed with error code: %d\n", retVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (retVal != ErrorCode::SUCCESS)
|
||||||
|
printOclocCmdLine(numArgs, argv, helper);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
helper->printf("%s\n", e.what());
|
helper->printf("%s\n", e.what());
|
||||||
|
printOclocCmdLine(numArgs, argv, helper);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int oclocFreeOutput(uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs) {
|
int oclocFreeOutput(uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs) {
|
||||||
for (uint32_t i = 0; i < *numOutputs; i++) {
|
for (uint32_t i = 0; i < *numOutputs; i++) {
|
||||||
delete[](*dataOutputs)[i];
|
delete[](*dataOutputs)[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user