From 56745b5400d10814928d887b08f14effc82eb124 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Mon, 29 Nov 2010 14:23:30 +0000 Subject: [PATCH] refactored gpu tests a little --- tests/gpu/src/arithm.cpp | 80 ++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/tests/gpu/src/arithm.cpp b/tests/gpu/src/arithm.cpp index 02ff33b520..31722bacb8 100644 --- a/tests/gpu/src/arithm.cpp +++ b/tests/gpu/src/arithm.cpp @@ -680,18 +680,29 @@ struct CV_GpuMinMaxTest: public CvTest void run(int) { - int depth_end; - if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) depth_end = CV_64F; else depth_end = CV_32F; - for (int depth = CV_8U; depth <= depth_end; ++depth) + try { - for (int i = 0; i < 3; ++i) + int depth_end; + if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) + depth_end = CV_64F; + else + depth_end = CV_32F; + for (int depth = CV_8U; depth <= depth_end; ++depth) { - int rows = 1 + rand() % 1000; - int cols = 1 + rand() % 1000; - test(rows, cols, 1, depth); - test_masked(rows, cols, 1, depth); + for (int i = 0; i < 3; ++i) + { + int rows = 1 + rand() % 1000; + int cols = 1 + rand() % 1000; + test(rows, cols, 1, depth); + test_masked(rows, cols, 1, depth); + } } } + catch (const Exception& e) + { + if (!check_and_treat_gpu_exception(e, ts)) throw; + return; + } } void test(int rows, int cols, int cn, int depth) @@ -804,19 +815,30 @@ struct CV_GpuMinMaxLocTest: public CvTest void run(int) { - int depth_end; - if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) depth_end = CV_64F; else depth_end = CV_32F; - for (int depth = CV_8U; depth <= depth_end; ++depth) + try { - int rows = 1, cols = 3; - test(rows, cols, depth); - for (int i = 0; i < 4; ++i) + int depth_end; + if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) + depth_end = CV_64F; + else + depth_end = CV_32F; + for (int depth = CV_8U; depth <= depth_end; ++depth) { - int rows = 1 + rand() % 1000; - int cols = 1 + rand() % 1000; + int rows = 1, cols = 3; test(rows, cols, depth); + for (int i = 0; i < 4; ++i) + { + int rows = 1 + rand() % 1000; + int cols = 1 + rand() % 1000; + test(rows, cols, depth); + } } } + catch (const Exception& e) + { + if (!check_and_treat_gpu_exception(e, ts)) throw; + return; + } } void test(int rows, int cols, int depth) @@ -875,18 +897,28 @@ struct CV_GpuCountNonZeroTest: CvTest void run(int) { - srand(0); - int depth_end; - if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) depth_end = CV_64F; else depth_end = CV_32F; - for (int depth = CV_8U; depth <= CV_32F; ++depth) + try { - for (int i = 0; i < 4; ++i) + int depth_end; + if (cv::gpu::hasNativeDoubleSupport(cv::gpu::getDevice())) + depth_end = CV_64F; + else + depth_end = CV_32F; + for (int depth = CV_8U; depth <= CV_32F; ++depth) { - int rows = 1 + rand() % 1000; - int cols = 1 + rand() % 1000; - test(rows, cols, depth); + for (int i = 0; i < 4; ++i) + { + int rows = 1 + rand() % 1000; + int cols = 1 + rand() % 1000; + test(rows, cols, depth); + } } } + catch (const Exception& e) + { + if (!check_and_treat_gpu_exception(e, ts)) throw; + return; + } } void test(int rows, int cols, int depth)