Merge pull request #2286 from alalek:umat_unmap_issue

pull/2535/merge
Andrey Pavlenko 11 years ago committed by OpenCV Buildbot
commit 6f5800e7df
  1. 134
      modules/core/test/test_umat.cpp

@ -834,3 +834,137 @@ TEST(UMat, DISABLED_synchronization_map_unmap)
}
} } // namespace cvtest::ocl
TEST(UMat, DISABLED_bug_with_unmap)
{
for (int i = 0; i < 20; i++)
{
try
{
Mat m = Mat(1000, 1000, CV_8UC1);
UMat u = m.getUMat(ACCESS_READ);
UMat dst;
add(u, Scalar::all(0), dst); // start async operation
u.release();
m.release();
}
catch (const cv::Exception& e)
{
printf("i = %d... %s\n", i, e.what());
ADD_FAILURE();
}
catch (...)
{
printf("i = %d...\n", i);
ADD_FAILURE();
}
}
}
TEST(UMat, DISABLED_bug_with_unmap_in_class)
{
class Logic
{
public:
Logic() {}
void processData(InputArray input)
{
Mat m = input.getMat();
{
Mat dst;
m.convertTo(dst, CV_32FC1);
// some additional CPU-based per-pixel processing into dst
intermediateResult = dst.getUMat(ACCESS_READ);
std::cout << "data processed..." << std::endl;
} // problem is here: dst::~Mat()
std::cout << "leave ProcessData()" << std::endl;
}
UMat getResult() const { return intermediateResult; }
protected:
UMat intermediateResult;
};
try
{
Mat m = Mat(1000, 1000, CV_8UC1);
Logic l;
l.processData(m);
UMat result = l.getResult();
}
catch (const cv::Exception& e)
{
printf("exception... %s\n", e.what());
ADD_FAILURE();
}
catch (...)
{
printf("exception... \n");
ADD_FAILURE();
}
}
TEST(UMat, Test_same_behaviour_read_and_read)
{
bool exceptionDetected = false;
try
{
UMat u(Size(10, 10), CV_8UC1);
Mat m = u.getMat(ACCESS_READ);
UMat dst;
add(u, Scalar::all(1), dst);
}
catch (...)
{
exceptionDetected = true;
}
ASSERT_FALSE(exceptionDetected); // no data race, 2+ reads are valid
}
// VP: this test (and probably others from same_behaviour series) is not valid in my opinion.
TEST(UMat, DISABLED_Test_same_behaviour_read_and_write)
{
bool exceptionDetected = false;
try
{
UMat u(Size(10, 10), CV_8UC1);
Mat m = u.getMat(ACCESS_READ);
add(u, Scalar::all(1), u);
}
catch (...)
{
exceptionDetected = true;
}
ASSERT_TRUE(exceptionDetected); // data race
}
TEST(UMat, DISABLED_Test_same_behaviour_write_and_read)
{
bool exceptionDetected = false;
try
{
UMat u(Size(10, 10), CV_8UC1);
Mat m = u.getMat(ACCESS_WRITE);
UMat dst;
add(u, Scalar::all(1), dst);
}
catch (...)
{
exceptionDetected = true;
}
ASSERT_TRUE(exceptionDetected); // data race
}
TEST(UMat, DISABLED_Test_same_behaviour_write_and_write)
{
bool exceptionDetected = false;
try
{
UMat u(Size(10, 10), CV_8UC1);
Mat m = u.getMat(ACCESS_WRITE);
add(u, Scalar::all(1), u);
}
catch (...)
{
exceptionDetected = true;
}
ASSERT_TRUE(exceptionDetected); // data race
}

Loading…
Cancel
Save