| 116 | } |
| 117 | |
| 118 | static 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 |
no test coverage detected