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

Function test2

autotest/cpp/testblockcachewrite.cpp:118–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118static void test2()
119{
120 printf("Start test2\n");
121 printf("main thread %p\n", (void *)CPLGetPID());
122
123 CPLJoinableThread *hThread;
124
125 CPLSetConfigOption("GDAL_RB_INTERNALIZE_SLEEP_AFTER_DETACH_BEFORE_WRITE",
126 "0.5");
127 GDALSetCacheMax(1000 * 1000);
128
129 auto poDS = GetGDALDriverManager()->GetDriverByName("GTiff")->Create(
130 "/vsimem/foo.tif", 1, 1, 2, GDT_Byte, nullptr);
131 poDS->GetRasterBand(1)->Fill(0);
132 poDS->GetRasterBand(2)->Fill(0);
133 poDS->FlushCache(false);
134 GDALSetCacheMax(0);
135
136 poDS->GetRasterBand(1)->Fill(1);
137 hThread = CPLCreateJoinableThread(thread_func2, nullptr);
138 CPLSleep(0.2);
139
140 GByte c = 0;
141 CPL_IGNORE_RET_VAL(poDS->GetRasterBand(1)->RasterIO(
142 GF_Read, 0, 0, 1, 1, &c, 1, 1, GDT_Byte, 0, 0, nullptr));
143 printf("%d\n", c);
144 ASSERT_EQ(c, 1);
145 CPLJoinThread(hThread);
146
147 CPLSetConfigOption("GDAL_RB_INTERNALIZE_SLEEP_AFTER_DETACH_BEFORE_WRITE",
148 nullptr);
149 delete poDS;
150 VSIUnlink("/vsimem/foo.tif");
151 printf("End test2\n");
152}
153
154// ---------------------------------------------------------------------------
155

Callers 1

TESTFunction · 0.70

Calls 14

CPLGetPIDFunction · 0.85
GetGDALDriverManagerFunction · 0.85
CPLCreateJoinableThreadFunction · 0.85
CPLSleepFunction · 0.85
ASSERT_EQFunction · 0.85
CPLJoinThreadFunction · 0.85
VSIUnlinkFunction · 0.85
CPL_IGNORE_RET_VALFunction · 0.50
CreateMethod · 0.45
GetDriverByNameMethod · 0.45
FillMethod · 0.45
GetRasterBandMethod · 0.45

Tested by

no test coverage detected