1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #24343 from mshabunin:fix-test-writes

Fix tests writing to current work dir #24343

Several tests were writing files in the current work directory and did not clean up after test. Moved all temporary files to the `/tmp` dir and added a cleanup code.
This commit is contained in:
Maksim Shabunin
2023-10-03 16:34:25 +03:00
committed by GitHub
parent 9f74982a54
commit 1bccc14e05
3 changed files with 46 additions and 40 deletions
+4 -2
View File
@@ -474,12 +474,13 @@ TEST(Core_PCA, accuracy)
ASSERT_LE(err, diffBackPrjEps) << "bad accuracy of cvBackProjectPCA() (CV_PCA_DATA_AS_COL)";
#endif
// Test read and write
FileStorage fs( "PCA_store.yml", FileStorage::WRITE );
const std::string filename = cv::tempfile("PCA_store.yml");
FileStorage fs( filename, FileStorage::WRITE );
rPCA.write( fs );
fs.release();
PCA lPCA;
fs.open( "PCA_store.yml", FileStorage::READ );
fs.open( filename, FileStorage::READ );
lPCA.read( fs.root() );
err = cvtest::norm(rPCA.eigenvectors, lPCA.eigenvectors, NORM_L2 | NORM_RELATIVE);
EXPECT_LE(err, 0) << "bad accuracy of write/load functions (YML)";
@@ -487,6 +488,7 @@ TEST(Core_PCA, accuracy)
EXPECT_LE(err, 0) << "bad accuracy of write/load functions (YML)";
err = cvtest::norm(rPCA.mean, lPCA.mean, NORM_L2 | NORM_RELATIVE);
EXPECT_LE(err, 0) << "bad accuracy of write/load functions (YML)";
EXPECT_EQ(0, remove(filename.c_str()));
}
class Core_ArrayOpTest : public cvtest::BaseTest