Skip to content

Commit 433ce37

Browse files
committed
try this for groupbased too
1 parent 7fd143a commit 433ce37

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

test/Files_SerialIO/close_and_reopen_test.cpp

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ auto run_test_groupbased(
184184
Access writeAccess,
185185
WriteIterations &&writeIterations,
186186
std::string const &ext,
187-
std::vector<Access> const &readModes)
187+
std::vector<Access> const &readModes,
188+
bool synchronous)
188189
{
189190
std::string filename =
190191
"../samples/close_iteration_reopen/groupbased." + ext;
@@ -214,6 +215,18 @@ auto run_test_groupbased(
214215
B_y.resetDataset({Datatype::INT, {5}});
215216
B_y.storeChunk(data, {0}, {5});
216217
it.close();
218+
// This also verifies that operator[] and at() can be used to access the
219+
// Iteration after closing
220+
REQUIRE(series.iterations.at(0).closed());
221+
REQUIRE(writeIterations(series)[0].closed() == !synchronous);
222+
REQUIRE(writeIterations(series).at(0).closed() == !synchronous);
223+
if (synchronous)
224+
{
225+
// we opened a new step, need to do something in it now,
226+
// otherwise we get a corrupted file
227+
B_y.storeChunk(data, {0}, {5});
228+
it.close();
229+
}
217230
}
218231

219232
{
@@ -229,6 +242,15 @@ auto run_test_groupbased(
229242
E_y.resetDataset({Datatype::INT, {5}});
230243
E_y.storeChunk(data, {0}, {5});
231244
it.close();
245+
246+
if (!synchronous || series.backend() != "ADIOS2")
247+
{
248+
writeIterations(series).at(0);
249+
}
250+
else
251+
{
252+
REQUIRE_THROWS(writeIterations(series).at(0));
253+
}
232254
}
233255
{
234256
auto it = writeIterations(series)[2];
@@ -332,37 +354,43 @@ auto close_and_reopen_test() -> void
332354
writeAccess,
333355
[](Series &s) { return s.iterations; },
334356
"bp4",
335-
{Access::READ_ONLY, Access::READ_LINEAR});
357+
{Access::READ_ONLY, Access::READ_LINEAR},
358+
false);
336359
// since these write data in a way that distributes one iteration's data
337360
// over multiple steps, only random access read mode makes sense
338361
run_test_groupbased(
339362
writeAccess,
340363
[](Series &s) { return s.writeIterations(); },
341364
"bp4",
342-
{Access::READ_RANDOM_ACCESS});
365+
{Access::READ_RANDOM_ACCESS},
366+
true);
343367
run_test_groupbased(
344368
writeAccess,
345369
[](Series &s) { return s.snapshots(); },
346370
"bp4",
347-
{Access::READ_RANDOM_ACCESS});
371+
{Access::READ_RANDOM_ACCESS},
372+
synchronous);
348373
// that doesnt matter for json tho
349374
run_test_groupbased(
350375
writeAccess,
351376
[](Series &s) { return s.snapshots(); },
352377
"json",
353-
{Access::READ_RANDOM_ACCESS, Access::READ_LINEAR});
378+
{Access::READ_RANDOM_ACCESS, Access::READ_LINEAR},
379+
synchronous);
354380
#if openPMD_HAVE_HDF5
355381
run_test_groupbased(
356382
writeAccess,
357383
[](Series &s) { return s.snapshots(); },
358384
"h5",
359-
{Access::READ_RANDOM_ACCESS, Access::READ_LINEAR});
385+
{Access::READ_RANDOM_ACCESS, Access::READ_LINEAR},
386+
synchronous);
360387
#endif
361388
run_test_groupbased(
362389
writeAccess,
363390
[](Series &s) { return s.snapshots(); },
364391
"json",
365-
{Access::READ_RANDOM_ACCESS, Access::READ_LINEAR});
392+
{Access::READ_RANDOM_ACCESS, Access::READ_LINEAR},
393+
synchronous);
366394
}
367395
}
368396
#else

0 commit comments

Comments
 (0)