2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-02-23 05:21:06 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2019-02-27 18:39:32 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-27 23:17:08 +08:00
|
|
|
#include "shared/offline_compiler/source/multi_command.h"
|
|
|
|
#include "shared/offline_compiler/source/offline_compiler.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <CL/cl.h>
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <cstdint>
|
2020-03-10 21:02:09 +08:00
|
|
|
#include <memory>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class OfflineCompilerTests : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
OfflineCompilerTests() : pOfflineCompiler(nullptr),
|
|
|
|
retVal(CL_SUCCESS) {
|
2020-03-10 21:02:09 +08:00
|
|
|
uniqueHelper = std::make_unique<OclocArgHelper>();
|
2017-12-21 07:45:38 +08:00
|
|
|
// ctor
|
|
|
|
}
|
|
|
|
|
|
|
|
OfflineCompiler *pOfflineCompiler;
|
|
|
|
int retVal;
|
2020-03-10 21:02:09 +08:00
|
|
|
std::unique_ptr<OclocArgHelper> uniqueHelper;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2019-05-14 22:47:35 +08:00
|
|
|
class MultiCommandTests : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
MultiCommandTests() : pMultiCommand(nullptr),
|
|
|
|
retVal(CL_SUCCESS) {
|
2020-03-10 21:02:09 +08:00
|
|
|
uniqueHelper = std::make_unique<OclocArgHelper>();
|
2019-05-14 22:47:35 +08:00
|
|
|
}
|
|
|
|
void createFileWithArgs(const std::vector<std::string> &, int numOfBuild);
|
|
|
|
void deleteFileWithArgs();
|
2019-11-21 20:52:43 +08:00
|
|
|
void deleteOutFileList();
|
2019-05-14 22:47:35 +08:00
|
|
|
MultiCommand *pMultiCommand;
|
|
|
|
std::string nameOfFileWithArgs;
|
2019-11-21 20:52:43 +08:00
|
|
|
std::string outFileList;
|
2019-05-14 22:47:35 +08:00
|
|
|
int retVal;
|
2020-03-10 21:02:09 +08:00
|
|
|
std::unique_ptr<OclocArgHelper> uniqueHelper;
|
2019-05-14 22:47:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void MultiCommandTests::createFileWithArgs(const std::vector<std::string> &singleArgs, int numOfBuild) {
|
|
|
|
std::ofstream myfile(nameOfFileWithArgs);
|
|
|
|
if (myfile.is_open()) {
|
|
|
|
for (int i = 0; i < numOfBuild; i++) {
|
|
|
|
for (auto singleArg : singleArgs)
|
|
|
|
myfile << singleArg + " ";
|
|
|
|
myfile << std::endl;
|
|
|
|
}
|
|
|
|
myfile.close();
|
|
|
|
} else
|
|
|
|
printf("Unable to open file\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiCommandTests::deleteFileWithArgs() {
|
|
|
|
if (remove(nameOfFileWithArgs.c_str()) != 0)
|
|
|
|
perror("Error deleting file");
|
|
|
|
}
|
|
|
|
|
2019-11-21 20:52:43 +08:00
|
|
|
void MultiCommandTests::deleteOutFileList() {
|
|
|
|
if (remove(outFileList.c_str()) != 0)
|
|
|
|
perror("Error deleting file");
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|