Skip to content

Commit

Permalink
Added option to change output directory in Testbed command line argum…
Browse files Browse the repository at this point in the history
…ents.
  • Loading branch information
LukasBanana committed Aug 3, 2023
1 parent 4dc117a commit 32c46d3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
31 changes: 28 additions & 3 deletions tests/Testbed/TestbedContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#define ENABLE_GPU_DEBUGGER 1
#define ENABLE_CPU_DEBUGGER 0

static constexpr const char* g_defaultOutputDir = "Output/";

static bool HasArgument(int argc, char* argv[], const char* search)
{
for (int i = 0; i < argc; ++i)
Expand All @@ -27,8 +29,31 @@ static bool HasArgument(int argc, char* argv[], const char* search)
return false;
}

static std::string FindOutputDir(int argc, char* argv[])
{
for (int i = 0; i < argc; ++i)
{
if (::strncmp(argv[i], "-o=", 3) == 0)
return argv[i] + 3;
}
return g_defaultOutputDir;
}

static std::string SanitizePath(std::string path)
{
for (char& chr : path)
{
if (chr == '\\')
chr = '/';
}
if (!path.empty() && path.back() != '/')
path.push_back('/');
return path;
}

TestbedContext::TestbedContext(const char* moduleName, int argc, char* argv[]) :
moduleName { moduleName },
outputDir { SanitizePath(FindOutputDir(argc, argv)) },
verbose { HasArgument(argc, argv, "-v") || HasArgument(argc, argv, "--verbose") },
showTiming { HasArgument(argc, argv, "-t") || HasArgument(argc, argv, "--timing") },
fastTest { HasArgument(argc, argv, "-f") || HasArgument(argc, argv, "--fast") }
Expand Down Expand Up @@ -882,7 +907,7 @@ void TestbedContext::SaveDepthImageTGA(const std::vector<float>& image, const LL
colors[i] = ColorRGBub{ color };
}

const std::string path = "Output/" + moduleName + "/";
const std::string path = outputDir + moduleName + "/";
SaveImageTGA(colors, extent, path + name + ".Result.tga", verbose);
}

Expand All @@ -907,9 +932,9 @@ int TestbedContext::DiffImagesTGA(const std::string& name, int threshold, int sc
std::vector<ColorRGBub> pixelsA, pixelsB, pixelsDiff;
Extent2D extentA, extentB;

const std::string resultPath = "Output/" + moduleName + "/";
const std::string resultPath = outputDir + moduleName + "/";
const std::string refPath = "Reference/";
const std::string diffPath = "Output/" + moduleName + "/";
const std::string diffPath = outputDir + moduleName + "/";

if (!LoadImageTGA(pixelsA, extentA, refPath + name + ".Ref.tga"))
return -1;
Expand Down
1 change: 1 addition & 0 deletions tests/Testbed/TestbedContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class TestbedContext
protected:

const std::string moduleName;
const std::string outputDir;
const bool verbose;
const bool showTiming;
const bool fastTest; // Skip slow buffer/texture creations to speed up test run
Expand Down

0 comments on commit 32c46d3

Please sign in to comment.