opencv/modules/nonfree/test/test_main.cpp

74 lines
1.6 KiB
C++
Raw Normal View History

#include "test_precomp.hpp"
2013-03-18 20:14:37 +08:00
#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA)
using namespace cv;
using namespace cv::gpu;
using namespace cvtest;
using namespace testing;
int main(int argc, char **argv)
2013-03-18 20:14:37 +08:00
{
try
{
const char* keys =
"{ h | help ? | false | Print help}"
"{ i | info | false | Print information about system and exit }"
"{ d | device | -1 | Device on which tests will be executed (-1 means all devices) }"
;
CommandLineParser cmd(argc, (const char**)argv, keys);
if (cmd.get<bool>("help"))
{
cmd.printParams();
return 0;
}
2013-03-18 20:14:37 +08:00
printCudaInfo();
if (cmd.get<bool>("info"))
{
2013-03-18 20:14:37 +08:00
return 0;
}
2013-03-18 20:14:37 +08:00
int device = cmd.get<int>("device");
if (device < 0)
{
2013-03-18 20:14:37 +08:00
DeviceManager::instance().loadAll();
std::cout << "Run tests on all supported devices \n" << std::endl;
}
2013-03-18 20:14:37 +08:00
else
{
2013-03-18 20:14:37 +08:00
DeviceManager::instance().load(device);
DeviceInfo info(device);
std::cout << "Run tests on device " << device << " [" << info.name() << "] \n" << std::endl;
}
2013-03-18 20:14:37 +08:00
TS::ptr()->init("cv");
InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
2013-03-18 20:14:37 +08:00
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
return -1;
}
catch (...)
{
2013-03-18 20:14:37 +08:00
std::cerr << "Unknown error" << std::endl;
return -1;
}
return 0;
}
#else // HAVE_CUDA
CV_TEST_MAIN("cv")
2013-03-18 18:42:27 +08:00
#endif // HAVE_CUDA