Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions test_conformance/compiler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@

#include "harness/testHarness.h"
#include "harness/stringHelpers.h"
#include "harness/os_helpers.h"

std::string spvBinariesPath = "spirv_bin";
std::string spvIncludeTestDirectory = "includeTestDirectory";
std::string spvSecondIncludeTestDirectory = "secondIncludeTestDirectory";

const std::string spvBinariesPathArg = "--spirv-binaries-path";
const std::string spvIncludeTestDirectoryArg = "--include-test-directory";
const std::string spvSecondIncludeTestDirectoryArg =
"--second-include-test-directory";

void printUsage()
{
Expand All @@ -32,6 +39,18 @@ void printUsage()

int main(int argc, const char *argv[])
{
char const *sep = get_dir_sep();
char const *exe_dir = get_exe_dir();

// Set default include directories
spvIncludeTestDirectory =
std::string(exe_dir) + sep + "includeTestDirectory";
spvSecondIncludeTestDirectory =
std::string(exe_dir) + sep + "secondIncludeTestDirectory";

free((void *)sep);
free((void *)exe_dir);

bool modifiedSpvBinariesPath = false;
bool listTests = false;
for (int i = 0; i < argc; ++i)
Expand All @@ -52,6 +71,34 @@ int main(int argc, const char *argv[])
modifiedSpvBinariesPath = true;
}
}
if (argv[i] == spvIncludeTestDirectoryArg)
{
if (i + 1 == argc)
{
log_error("Missing value for '%s' argument.\n",
spvIncludeTestDirectoryArg.c_str());
return TEST_FAIL;
}
else
{
spvIncludeTestDirectory = std::string(argv[i + 1]);
argsRemoveNum += 2;
}
}
if (argv[i] == spvSecondIncludeTestDirectoryArg)
{
if (i + 1 == argc)
{
log_error("Missing value for '%s' argument.\n",
spvSecondIncludeTestDirectoryArg.c_str());
return TEST_FAIL;
}
else
{
spvSecondIncludeTestDirectory = std::string(argv[i + 1]);
argsRemoveNum += 2;
}
}

if (argsRemoveNum > 0)
{
Expand Down
10 changes: 5 additions & 5 deletions test_conformance/compiler/test_build_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "harness/os_helpers.h"
#include "harness/testHarness.h"

extern std::string spvIncludeTestDirectory;
extern std::string spvSecondIncludeTestDirectory;

#include <array>

const char *preprocessor_test_kernel[] = {
Expand Down Expand Up @@ -249,8 +252,6 @@ REGISTER_TEST(options_include_directory)
{
int error;

std::string sep = dir_sep();
std::string path = exe_dir(); // Directory where test executable is located.
std::string include_dir;

clProgramWrapper program;
Expand All @@ -265,9 +266,8 @@ REGISTER_TEST(options_include_directory)
}

/* Build with the include directory defined */
include_dir = "-I " + path + sep + "includeTestDirectory";
include_dir = "-I " + spvIncludeTestDirectory;

// log_info("%s\n", include_dir);
error =
clBuildProgram(program, 1, &device, include_dir.c_str(), NULL, NULL);
test_error( error, "Test program did not properly build" );
Expand Down Expand Up @@ -295,7 +295,7 @@ REGISTER_TEST(options_include_directory)
}

// Rebuild with a different include directory
include_dir = "-I " + path + sep + "secondIncludeTestDirectory";
include_dir = "-I " + spvSecondIncludeTestDirectory;
error =
clBuildProgram(program, 1, &device, include_dir.c_str(), NULL, NULL);
test_error( error, "Test program did not properly rebuild" );
Expand Down
11 changes: 5 additions & 6 deletions test_conformance/compiler/test_preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "testBase.h"
#include "harness/os_helpers.h"

extern std::string spvIncludeTestDirectory;

const char *define_kernel_code[] = {
" #define VALUE\n"
"__kernel void define_test(__global int *src, __global int *dstA, __global int *dstB)\n"
Expand Down Expand Up @@ -157,18 +159,15 @@ REGISTER_TEST(preprocessor_include)
cl_int *resultData;
int i;

char include_dir[4096] = { 0 };
char include_kernel[4096] = { 0 };

char const *sep = get_dir_sep();
char const *path = get_exe_dir();

/* Build with the include directory defined */
sprintf(include_dir, "%s%sincludeTestDirectory%stestIncludeFile.h", path,
sep, sep);
sprintf(include_kernel, include_kernel_code, include_dir);
std::string include_dir =
spvIncludeTestDirectory + sep + "testIncludeFile.h";
sprintf(include_kernel, include_kernel_code, include_dir.c_str());
free((void *)sep);
free((void *)path);

const char *test_kernel[] = { include_kernel, 0 };
error = create_single_kernel_helper(context, &program, &kernel, 1,
Expand Down
Loading