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

Function TEST

autotest/cpp/testmultithreadedwriting.cpp:46–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46TEST(testmultithreadedwriting, test)
47{
48 bool bEndlessLoop = CPLTestBool(CPLGetConfigOption("ENDLESS_LOOPS", "NO"));
49
50 CPLJoinableThread *hThread1;
51 CPLJoinableThread *hThread2;
52
53 GDALAllRegister();
54 GDALSetCacheMax(10000);
55
56 int one = 1;
57 int two = 2;
58 GDALDriver *poDriver = (GDALDriver *)GDALGetDriverByName("ENVI");
59 if (poDriver == nullptr)
60 {
61 GTEST_SKIP() << "ENVI driver missing";
62 }
63 else
64 {
65 GDALDataset *poDS = poDriver->Create("/vsimem/test_ref", 100, 2000, 1,
66 GDT_Byte, nullptr);
67 GDALClose(poDS);
68
69 int counter = 0;
70 const int nloops = bEndlessLoop ? 2 * 1000 * 1000 * 1000 : 1;
71 for (int i = 0; i < nloops; ++i)
72 {
73 ++i;
74 if ((i % 20) == 0)
75 printf("%d\n", counter);
76
77 hThread1 = CPLCreateJoinableThread(thread_func, &one);
78 hThread2 = CPLCreateJoinableThread(thread_func, &two);
79
80 CPLJoinThread(hThread1);
81 CPLJoinThread(hThread2);
82
83 GDALDataset *poDSRef =
84 (GDALDataset *)GDALOpen("/vsimem/test1", GA_ReadOnly);
85 const int cs =
86 GDALChecksumImage(poDSRef->GetRasterBand(1), 0, 0, 100, 2000);
87 EXPECT_EQ(cs, 29689);
88 GDALClose(poDSRef);
89
90 poDriver->Delete("/vsimem/test1");
91 poDriver->Delete("/vsimem/test2");
92 }
93
94 poDriver->Delete("/vsimem/test_ref");
95
96 GDALDestroyDriverManager();
97 }
98}
99
100} // namespace

Callers

nothing calls this directly

Calls 8

CPLTestBoolFunction · 0.85
GDALCloseClass · 0.85
CPLCreateJoinableThreadFunction · 0.85
CPLJoinThreadFunction · 0.85
GDALDestroyDriverManagerFunction · 0.85
CreateMethod · 0.45
GetRasterBandMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected