MCPcopy Create free account
hub / github.com/OSGeo/gdal / test

Function test

autotest/cpp/test_driver_metadata_multithread.cpp:21–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19{
20
21static bool test(int mainIter)
22{
23 bool ret = true;
24 GDALAllRegister();
25
26 const char *pszItem = (mainIter % 2) == 0
27 ? GDAL_DMD_CREATIONOPTIONLIST
28 : GDAL_DS_LAYER_CREATIONOPTIONLIST;
29
30 auto poDM = GetGDALDriverManager();
31 const int nDriverCount = poDM->GetDriverCount();
32 for (int iDrv = 0; iDrv < nDriverCount; ++iDrv)
33 {
34 auto poDriver = poDM->GetDriver(iDrv);
35 if (poDriver->pfnCreate || poDriver->pfnCreateCopy)
36 {
37 std::vector<std::thread> threads;
38 std::vector<std::string> tabretval(4);
39 for (size_t i = 0; i < tabretval.size(); ++i)
40 {
41 std::string &retval = tabretval[i];
42 threads.emplace_back(
43 [pszItem, i, poDriver, &retval]()
44 {
45 const char *pszStr;
46 if ((i % 2) == 0)
47 {
48 pszStr = poDriver->GetMetadataItem(pszItem);
49 }
50 else
51 {
52 pszStr = CSLFetchNameValue(poDriver->GetMetadata(),
53 pszItem);
54 }
55 if (pszStr)
56 retval = pszStr;
57 });
58 }
59 for (size_t i = 0; i < tabretval.size(); ++i)
60 {
61 threads[i].join();
62 if (i > 0 && tabretval[i] != tabretval[0])
63 {
64 fprintf(stderr, "%s\n", poDriver->GetDescription());
65 ret = false;
66 }
67 }
68 }
69 }
70
71 GDALDestroyDriverManager();
72 return ret;
73}
74
75TEST(Test, test)
76{

Callers 2

TESTFunction · 0.70
TEST_FFunction · 0.70

Calls 9

GetGDALDriverManagerFunction · 0.85
CSLFetchNameValueFunction · 0.85
GDALDestroyDriverManagerFunction · 0.85
GetDriverCountMethod · 0.45
GetDriverMethod · 0.45
sizeMethod · 0.45
GetMetadataItemMethod · 0.45
GetMetadataMethod · 0.45
GetDescriptionMethod · 0.45

Tested by

no test coverage detected