2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-14 21:32:11 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
2018-09-18 15:11:08 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#pragma once
|
2020-02-24 20:10:44 +08:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
|
|
|
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/fixtures/context_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/fixtures/device_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/fixtures/program_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
2020-02-22 16:28:27 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <string>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ProgramFromBinaryTest Test Fixture
|
|
|
|
// Used to test the Program class
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class ProgramFromBinaryTest : public DeviceFixture,
|
|
|
|
public ContextFixture,
|
|
|
|
public ProgramFixture,
|
|
|
|
public testing::TestWithParam<std::tuple<const char *, const char *>> {
|
|
|
|
|
|
|
|
using ContextFixture::SetUp;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SetUp() override {
|
|
|
|
std::tie(BinaryFileName, KernelName) = GetParam();
|
|
|
|
|
|
|
|
DeviceFixture::SetUp();
|
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
cl_device_id device = pClDevice;
|
2017-12-21 07:45:38 +08:00
|
|
|
ContextFixture::SetUp(1, &device);
|
|
|
|
ProgramFixture::SetUp();
|
|
|
|
|
|
|
|
if (options.size())
|
2019-08-29 21:10:51 +08:00
|
|
|
CreateProgramFromBinary(pContext, &device, BinaryFileName, options);
|
2017-12-21 07:45:38 +08:00
|
|
|
else
|
2019-08-29 21:10:51 +08:00
|
|
|
CreateProgramFromBinary(pContext, &device, BinaryFileName);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
2019-08-29 21:10:51 +08:00
|
|
|
knownSource.reset();
|
2017-12-21 07:45:38 +08:00
|
|
|
ProgramFixture::TearDown();
|
|
|
|
ContextFixture::TearDown();
|
|
|
|
DeviceFixture::TearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setOptions(std::string &optionsIn) {
|
|
|
|
options = optionsIn;
|
|
|
|
}
|
|
|
|
|
2020-03-13 21:59:00 +08:00
|
|
|
const char *BinaryFileName = nullptr;
|
|
|
|
const char *KernelName = nullptr;
|
|
|
|
cl_int retVal = CL_SUCCESS;
|
2017-12-21 07:45:38 +08:00
|
|
|
std::string options;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2018-03-16 01:13:52 +08:00
|
|
|
// ProgramSimpleFixture Test Fixture
|
2017-12-21 07:45:38 +08:00
|
|
|
// Used to test the Program class, but not using parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2018-03-16 01:13:52 +08:00
|
|
|
class ProgramSimpleFixture : public DeviceFixture,
|
|
|
|
public ContextFixture,
|
|
|
|
public ProgramFixture {
|
2017-12-21 07:45:38 +08:00
|
|
|
using ContextFixture::SetUp;
|
|
|
|
|
2018-03-16 01:13:52 +08:00
|
|
|
public:
|
2017-12-21 07:45:38 +08:00
|
|
|
void SetUp() override {
|
|
|
|
DeviceFixture::SetUp();
|
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
cl_device_id device = pClDevice;
|
2017-12-21 07:45:38 +08:00
|
|
|
ContextFixture::SetUp(1, &device);
|
|
|
|
ProgramFixture::SetUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
2019-08-29 21:10:51 +08:00
|
|
|
knownSource.reset();
|
2017-12-21 07:45:38 +08:00
|
|
|
ProgramFixture::TearDown();
|
|
|
|
ContextFixture::TearDown();
|
|
|
|
DeviceFixture::TearDown();
|
|
|
|
}
|
|
|
|
|
2018-03-16 01:13:52 +08:00
|
|
|
protected:
|
2020-03-13 21:59:00 +08:00
|
|
|
cl_int retVal = CL_SUCCESS;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|