Testsuite cleanups and improvements.

Add ctest support.
Add FileSystem::changeDirectory method.
pull/216/head
castano 15 years ago
parent 4a34c673a4
commit ab73c790e1

@ -1,5 +1,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
PROJECT(NV)
ENABLE_TESTING()
SET(NV_CMAKE_DIR "${NV_SOURCE_DIR}/cmake")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${NV_CMAKE_DIR}")

4
configure vendored

@ -65,6 +65,10 @@ all:
@make --no-print-directory -C build-$build/
install:
@make install --no-print-directory -C build-$build/
package:
@make package --no-print-directory -C build-$build/
test:
@make test --no-print-directory -C build-$build/
clean:
@make clean --no-print-directory -C build-$build/
distclean:

@ -45,3 +45,11 @@ bool FileSystem::createDirectory(const char * path)
#endif
}
bool FileSystem::changeDirectory(const char * path)
{
#if NV_OS_WIN32
return _chdir(path) != -1;
#else
return chdir(path) != -1;
#endif
}

@ -13,6 +13,7 @@ namespace nv
NVCORE_API bool exists(const char * path);
NVCORE_API bool createDirectory(const char * path);
NVCORE_API bool changeDirectory(const char * path);
} // FileSystem namespace

@ -2,8 +2,14 @@
ADD_EXECUTABLE(filtertest filtertest.cpp ../tools/cmdline.h)
TARGET_LINK_LIBRARIES(filtertest nvcore nvmath nvimage)
ADD_EXECUTABLE(nvtestsuite stress.cpp)
ADD_EXECUTABLE(nvtestsuite testsuite.cpp)
TARGET_LINK_LIBRARIES(nvtestsuite nvcore nvmath nvimage nvtt)
ADD_TEST(NVTT.TestSuite.Kodak.cuda nvtestsuite -path ${NV_SOURCE_DIR}/data/testsuite -set 0 -out output-cuda-kodak)
ADD_TEST(NVTT.TestSuite.Waterloo.cuda nvtestsuite -path ${NV_SOURCE_DIR}/data/testsuite -set 1 -out output-cuda-waterloo)
ADD_TEST(NVTT.TestSuite.Epic.cuda nvtestsuite -path ${NV_SOURCE_DIR}/data/testsuite -set 2 -out output-cuda-epic)
ADD_TEST(NVTT.TestSuite.Kodak.nocuda nvtestsuite -path ${NV_SOURCE_DIR}/data/testsuite -set 0 -nocuda -out output-nocuda-kodak)
ADD_TEST(NVTT.TestSuite.Waterloo.nocuda nvtestsuite -path ${NV_SOURCE_DIR}/data/testsuite -set 1 -nocuda -out output-nocuda-waterloo)
ADD_TEST(NVTT.TestSuite.Epic.nocuda nvtestsuite -path ${NV_SOURCE_DIR}/data/testsuite -set 2 -nocuda -out output-nocuda-epic)
IF (CUDA_FOUND)
ADD_EXECUTABLE(driverapitest driverapi.cpp)

@ -40,8 +40,8 @@
using namespace nv;
static const char * s_fileNames[] = {
// Kodak image set
// Kodak image set
static const char * s_kodakImageSet[] = {
"kodim01.png",
"kodim02.png",
"kodim03.png",
@ -66,7 +66,10 @@ static const char * s_fileNames[] = {
"kodim22.png",
"kodim23.png",
"kodim24.png",
// Waterloo image set
};
// Waterloo image set
static const char * s_waterlooImageSet[] = {
"clegg.png",
"frymire.png",
"lena.png",
@ -75,7 +78,10 @@ static const char * s_fileNames[] = {
"sail.png",
"serrano.png",
"tulips.png",
// Epic image set
};
// Epic image set
static const char * s_epicImageSet[] = {
"Bradley1.png",
"Gradient.png",
"MoreRocks.png",
@ -83,7 +89,19 @@ static const char * s_fileNames[] = {
"Rainbow.png",
"Text.png",
};
const int s_fileCount = sizeof(s_fileNames)/sizeof(s_fileNames[0]);
struct ImageSet
{
const char ** fileNames;
int fileCount;
};
static ImageSet s_imageSets[] = {
{s_kodakImageSet, sizeof(s_kodakImageSet)/sizeof(s_kodakImageSet[0])},
{s_waterlooImageSet, sizeof(s_waterlooImageSet)/sizeof(s_waterlooImageSet[0])},
{s_epicImageSet, sizeof(s_epicImageSet)/sizeof(s_epicImageSet[0])},
};
const int s_imageSetCount = sizeof(s_imageSets)/sizeof(s_imageSets[0]);
struct MyOutputHandler : public nvtt::OutputHandler
@ -197,16 +215,25 @@ int main(int argc, char *argv[])
printf("NVIDIA Texture Tools %u.%u - Copyright NVIDIA Corporation 2007 - 2008\n\n", major, minor);
int set = 0;
bool fast = false;
bool nocuda = false;
bool showHelp = false;
const char * basePath = "";
const char * outPath = "output";
const char * regressPath = NULL;
// Parse arguments.
for (int i = 1; i < argc; i++)
{
if (strcmp("-fast", argv[i]) == 0)
if (strcmp("-set", argv[i]) == 0)
{
if (i+1 < argc && argv[i+1][0] != '-') {
set = atoi(argv[i+1]);
i++;
}
}
else if (strcmp("-fast", argv[i]) == 0)
{
fast = true;
}
@ -218,13 +245,26 @@ int main(int argc, char *argv[])
{
showHelp = true;
}
else if (strcmp("-path", argv[i]) == 0)
{
if (i+1 < argc && argv[i+1][0] != '-') {
basePath = argv[i+1];
i++;
}
}
else if (strcmp("-out", argv[i]) == 0)
{
if (i+1 < argc && argv[i+1][0] != '-') outPath = argv[i+1];
if (i+1 < argc && argv[i+1][0] != '-') {
outPath = argv[i+1];
i++;
}
}
else if (strcmp("-regress", argv[i]) == 0)
{
if (i+1 < argc && argv[i+1][0] != '-') regressPath = argv[i+1];
if (i+1 < argc && argv[i+1][0] != '-') {
regressPath = argv[i+1];
i++;
}
}
}
@ -233,6 +273,8 @@ int main(int argc, char *argv[])
printf("usage: nvtestsuite [options]\n\n");
printf("Input options:\n");
printf(" -path <path>\tInput image path.\n");
printf(" -set [0:2]\tImage set.\n");
printf(" -regress <path>\tRegression directory.\n");
printf("Compression options:\n");
@ -268,6 +310,7 @@ int main(int argc, char *argv[])
nvtt::Context context;
context.enableCudaAcceleration(!nocuda);
FileSystem::changeDirectory(basePath);
FileSystem::createDirectory(outPath);
Path csvFileName;
@ -280,20 +323,23 @@ int main(int argc, char *argv[])
int failedTests = 0;
float totalDiff = 0;
for (int i = 0; i < s_fileCount; i++)
const char ** fileNames = s_imageSets[set].fileNames;
int fileCount = s_imageSets[set].fileCount;
for (int i = 0; i < fileCount; i++)
{
AutoPtr<Image> img( new Image() );
if (!img->load(s_fileNames[i]))
if (!img->load(fileNames[i]))
{
printf("Input image '%s' not found.\n", s_fileNames[i]);
printf("Input image '%s' not found.\n", fileNames[i]);
return EXIT_FAILURE;
}
inputOptions.setTextureLayout(nvtt::TextureType_2D, img->width(), img->height());
inputOptions.setMipmapData(img->pixels(), img->width(), img->height());
printf("Compressing: \t'%s'\n", s_fileNames[i]);
printf("Compressing: \t'%s'\n", fileNames[i]);
clock_t start = clock();
@ -306,9 +352,9 @@ int main(int argc, char *argv[])
AutoPtr<Image> img_out( outputHandler.decompress(nvtt::Format_BC1) );
Path outputFileName;
outputFileName.format("%s/%s", outPath, s_fileNames[i]);
outputFileName.format("%s/%s", outPath, fileNames[i]);
outputFileName.stripExtension();
outputFileName.append(".tga");
outputFileName.append(".png");
if (!ImageIO::save(outputFileName, img_out.ptr()))
{
printf("Error saving file '%s'.\n", outputFileName.str());
@ -320,14 +366,14 @@ int main(int argc, char *argv[])
printf(" RMSE: \t%.4f\n", rmse);
// Output csv file
csvWriter << "\"" << s_fileNames[i] << "\"," << rmse << "\n";
csvWriter << "\"" << fileNames[i] << "\"," << rmse << "\n";
if (regressPath != NULL)
{
Path regressFileName;
regressFileName.format("%s/%s", regressPath, s_fileNames[i]);
regressFileName.format("%s/%s", regressPath, fileNames[i]);
regressFileName.stripExtension();
regressFileName.append(".tga");
regressFileName.append(".png");
AutoPtr<Image> img_reg( new Image() );
if (!img_reg->load(regressFileName.str()))
@ -354,8 +400,8 @@ int main(int argc, char *argv[])
fflush(stdout);
}
totalRMSE /= s_fileCount;
totalDiff /= s_fileCount;
totalRMSE /= fileCount;
totalDiff /= fileCount;
printf("Total Results:\n");
printf(" Total Time: \t%.3f sec\n", totalTime / CLOCKS_PER_SEC);
@ -365,7 +411,7 @@ int main(int argc, char *argv[])
{
printf("Regression Results:\n");
printf(" Diff: %.4f\n", totalDiff);
printf(" %d/%d tests failed.\n", failedTests, s_fileCount);
printf(" %d/%d tests failed.\n", failedTests, fileCount);
}
return EXIT_SUCCESS;
Loading…
Cancel
Save