Source
1310
1310
ret = H5Sclose(decoded_sid3);
1311
1311
CHECK(ret, FAIL, "H5Sclose");
1312
1312
1313
1313
HDfree(sbuf);
1314
1314
HDfree(null_sbuf);
1315
1315
HDfree(scalar_buf);
1316
1316
} /* test_h5s_encode() */
1317
1317
1318
1318
/****************************************************************
1319
1319
**
1320
+
** test_h5s_encode_exceed32():
1321
+
** Verify that encoding selection that exceeds (2^32 - 1)
1322
+
** (32 bit integer limit) will return error.
1323
+
** See HDFFV-9947 and the RFC for "H5Sencode/H5Sdecode Format Change"
1324
+
**
1325
+
****************************************************************/
1326
+
static void
1327
+
test_h5s_encode_exceed32(void)
1328
+
{
1329
+
hid_t sid; /* Dataspace ID */
1330
+
size_t hyper_buf_size=0, pt_buf_size=0; /* Buffer size for H5Sencode */
1331
+
unsigned char *hyper_buf=NULL, *pt_buf=NULL; /* Buffers for H5Sencode */
1332
+
hsize_t numparticles = 8388608;
1333
+
unsigned num_dsets = 513;
1334
+
hsize_t total_particles = numparticles * num_dsets;
1335
+
hsize_t vdsdims[1] = {total_particles};
1336
+
hsize_t start, count, block; /* Hyperslab selection specification */
1337
+
hsize_t coord[4]; /* Coordinates for point selection */
1338
+
herr_t ret; /* Generic return value */
1339
+
1340
+
/* Output message about test being performed */
1341
+
MESSAGE(5, ("Testing Dataspace Encoding Exceeding 32 bits integer limit\n"));
1342
+
1343
+
/*-------------------------------------------------------------------------
1344
+
* Test encoding and decoding of simple dataspace and hyperslab selection.
1345
+
*-------------------------------------------------------------------------
1346
+
*/
1347
+
1348
+
/* Create dataspace */
1349
+
sid = H5Screate_simple(1, vdsdims, NULL);
1350
+
CHECK(sid, FAIL, "H5Screate_simple");
1351
+
1352
+
start = 0;
1353
+
block = total_particles; /* 4303355904 (exceeds 2^32) */
1354
+
count = 1;
1355
+
1356
+
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, NULL, &count, &block);
1357
+
CHECK(ret, FAIL, "H5Sselect_hyperslab");
1358
+
1359
+
/* Encode data space in a buffer */
1360
+
ret = H5Sencode(sid, NULL, &hyper_buf_size);
1361
+
CHECK(ret, FAIL, "H5Sencode");
1362
+
1363
+
/* Allocate buffer */
1364
+
if(hyper_buf_size > 0) {
1365
+
hyper_buf = (unsigned char*)HDcalloc((size_t)1, hyper_buf_size);
1366
+
CHECK(hyper_buf, NULL, "HDcalloc");
1367
+
}
1368
+
1369
+
/* H5Sencode should fail because block exceeds (2^32 - 1) */
1370
+
H5E_BEGIN_TRY {
1371
+
ret = H5Sencode(sid, hyper_buf, &hyper_buf_size);
1372
+
} H5E_END_TRY
1373
+
VERIFY(ret, FAIL, "H5Sencode");
1374
+
1375
+
/*-------------------------------------------------------------------------
1376
+
* Test encoding and decoding of simple dataspace and points selection.
1377
+
*-------------------------------------------------------------------------
1378
+
*/
1379
+
1380
+
/* Select points in dataspace */
1381
+
coord[0] = 5;
1382
+
coord[1] = 15;
1383
+
coord[2] = 4294967296; /* 2^32 */
1384
+
coord[3] = 19;
1385
+
ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord);
1386
+
CHECK(ret, FAIL, "H5Sselect_elements");
1387
+
1388
+
/* Encode data space in a buffer */
1389
+
ret = H5Sencode(sid, NULL, &pt_buf_size);
1390
+
CHECK(ret, FAIL, "H5Sencode");
1391
+
1392
+
/* Allocate buffer */
1393
+
if(pt_buf_size > 0)
1394
+
pt_buf = (unsigned char*)HDcalloc((size_t)1, pt_buf_size);
1395
+
1396
+
/* H5Sencode should fail because coord[2] exceeds (2^32 - 1) */
1397
+
H5E_BEGIN_TRY {
1398
+
ret = H5Sencode(sid, pt_buf, &pt_buf_size);
1399
+
} H5E_END_TRY
1400
+
VERIFY(ret, FAIL, "H5Sencode");
1401
+
1402
+
/* Close the dataspace */
1403
+
ret = H5Sclose(sid);
1404
+
CHECK(ret, FAIL, "H5Sclose");
1405
+
1406
+
/* Free the buffers */
1407
+
if(hyper_buf)
1408
+
HDfree(hyper_buf);
1409
+
if(pt_buf)
1410
+
HDfree(pt_buf);
1411
+
1412
+
} /* test_h5s_encode_exceed32() */
1413
+
1414
+
/****************************************************************
1415
+
**
1320
1416
** test_h5s_scalar_write(): Test scalar H5S (dataspace) writing code.
1321
1417
**
1322
1418
****************************************************************/
1323
1419
static void
1324
1420
test_h5s_scalar_write(void)
1325
1421
{
1326
1422
hid_t fid1; /* HDF5 File IDs */
1327
1423
hid_t dataset; /* Dataset ID */
1328
1424
hid_t sid1; /* Dataspace ID */
1329
1425
int rank; /* Logical rank of dataspace */
2377
2473
void
2378
2474
test_h5s(void)
2379
2475
{
2380
2476
/* Output message about test being performed */
2381
2477
MESSAGE(5, ("Testing Dataspaces\n"));
2382
2478
2383
2479
test_h5s_basic(); /* Test basic H5S code */
2384
2480
test_h5s_null(); /* Test Null dataspace H5S code */
2385
2481
test_h5s_zero_dim(); /* Test dataspace with zero dimension size */
2386
2482
test_h5s_encode(); /* Test encoding and decoding */
2483
+
test_h5s_encode_exceed32(); /* Testing encoding when selection exceeds 32 bits limit */
2387
2484
test_h5s_scalar_write(); /* Test scalar H5S writing code */
2388
2485
test_h5s_scalar_read(); /* Test scalar H5S reading code */
2389
2486
2390
2487
test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */
2391
2488
test_h5s_compound_scalar_read(); /* Test compound datatype scalar H5S reading code */
2392
2489
2393
2490
/* This test was added later to exercise a bug in chunked I/O */
2394
2491
test_h5s_chunk(); /* Exercise bug fix for chunked I/O */
2395
2492
2396
2493
test_h5s_extent_equal(); /* Test extent comparison code */