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

Function TEST

autotest/cpp/testblockcachelimits.cpp:76–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74// ---------------------------------------------------------------------------
75
76TEST(testblockcachelimits, test)
77{
78 CPLJoinableThread *hThread;
79
80 // CPLSetConfigOption("CPL_DEBUG", "ON");
81
82 printf("main thread %p\n", (void *)CPLGetPID());
83
84 CPLSetConfigOption("GDAL_CACHEMAX", "0");
85 CPLSetConfigOption("GDAL_DEBUG_BLOCK_CACHE", "ON");
86 GDALAllRegister();
87
88 GDALDatasetH hDS = GDALOpen(GCORE_DATA_DIR "byte.tif", GA_ReadOnly);
89
90 char buf[20 * 20];
91 printf("cache fill\n");
92 CPL_IGNORE_RET_VAL(GDALRasterIO(GDALGetRasterBand(hDS, 1), GF_Read, 0, 0,
93 20, 20, buf, 20, 20, GDT_Byte, 0, 0));
94 printf("end of cache fill\n");
95 printf("buf[0]=%d\n\n", (int)buf[0]);
96
97 hThread = CPLCreateJoinableThread(thread_func, nullptr);
98 CPLSleep(0.3);
99
100 printf("re read block\n");
101 CPL_IGNORE_RET_VAL(GDALRasterIO(GDALGetRasterBand(hDS, 1), GF_Read, 0, 0,
102 20, 20, buf, 20, 20, GDT_Byte, 0, 0));
103 printf("end of re read block\n");
104 printf("buf[0]=%d\n", (int)buf[0]);
105 CPLJoinThread(hThread);
106
107 hThread = CPLCreateJoinableThread(thread_func2, nullptr);
108 CPLSleep(0.3);
109
110 printf("re read block\n");
111 CPL_IGNORE_RET_VAL(GDALRasterIO(GDALGetRasterBand(hDS, 1), GF_Read, 0, 0,
112 20, 20, buf, 20, 20, GDT_Byte, 0, 0));
113 printf("end of re read block\n");
114 printf("buf[0]=%d\n", (int)buf[0]);
115 CPLJoinThread(hThread);
116
117 hThread = CPLCreateJoinableThread(thread_func3, nullptr);
118
119 printf("re read block\n");
120 CPLSetThreadLocalConfigOption("GDAL_RB_TRYGET_SLEEP_AFTER_TAKE_LOCK",
121 "0.6");
122 CPL_IGNORE_RET_VAL(GDALRasterIO(GDALGetRasterBand(hDS, 1), GF_Read, 0, 0,
123 20, 20, buf, 20, 20, GDT_Byte, 0, 0));
124 CPLSetThreadLocalConfigOption("GDAL_RB_TRYGET_SLEEP_AFTER_TAKE_LOCK", "0");
125 printf("end of re read block\n");
126 printf("buf[0]=%d\n", (int)buf[0]);
127 CPLJoinThread(hThread);
128
129 hThread = CPLCreateJoinableThread(thread_func2, nullptr);
130 CPLSleep(0.3);
131 printf("before GDALFlushRasterCache\n");
132 GDALFlushRasterCache(GDALGetRasterBand(hDS, 1));
133 printf("after GDALFlushRasterCache\n");

Callers

nothing calls this directly

Calls 8

CPLGetPIDFunction · 0.85
CPLCreateJoinableThreadFunction · 0.85
CPLSleepFunction · 0.85
CPLJoinThreadFunction · 0.85
ASSERT_EQFunction · 0.85
GDALCloseClass · 0.85
GDALDestroyDriverManagerFunction · 0.85
CPL_IGNORE_RET_VALFunction · 0.50

Tested by

no test coverage detected