diff options
Diffstat (limited to 'test/enum.c')
-rw-r--r-- | test/enum.c | 199 |
1 files changed, 110 insertions, 89 deletions
diff --git a/test/enum.c b/test/enum.c index 02cad81..f852ecc 100644 --- a/test/enum.c +++ b/test/enum.c @@ -207,58 +207,68 @@ test_tr1(hid_t file) static c_e1 data1[10]={E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED}; c_e1 data2[10]; + const char *envval = NULL; TESTING("O(1) conversions"); - if ((cwg=H5Gcreate(file, "test_tr1", 0))<0) goto error; - - if ((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error; - if (H5Tenum_insert(m_type, "RED", CPTR(eval, E1_RED ))<0) goto error; - if (H5Tenum_insert(m_type, "GREEN", CPTR(eval, E1_GREEN))<0) goto error; - if (H5Tenum_insert(m_type, "BLUE", CPTR(eval, E1_BLUE ))<0) goto error; - if (H5Tenum_insert(m_type, "WHITE", CPTR(eval, E1_WHITE))<0) goto error; - if (H5Tenum_insert(m_type, "BLACK", CPTR(eval, E1_BLACK))<0) goto error; - - - if ((f_type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error; - if (H5Tenum_insert(f_type, "RED", CPTR(ival, 105))<0) goto error; - if (H5Tenum_insert(f_type, "GREEN", CPTR(ival, 104))<0) goto error; - if (H5Tenum_insert(f_type, "BLUE", CPTR(ival, 103))<0) goto error; - if (H5Tenum_insert(f_type, "WHITE", CPTR(ival, 102))<0) goto error; - if (H5Tenum_insert(f_type, "BLACK", CPTR(ival, 101))<0) goto error; - - if ((space=H5Screate_simple(1, ds_size, NULL))<0) goto error; - if ((dset=H5Dcreate(cwg, "color_table", f_type, space, H5P_DEFAULT))<0) - goto error; - if (H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1)<0) goto error; - if (H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2)<0) goto error; - - for (i=0; i<ds_size[0]; i++) { - if (data1[i]!=data2[i]) { - H5_FAILED(); - printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data2[i])); + envval = HDgetenv("HDF5_DRIVER"); + if (envval == NULL) + envval = "nomatch"; + if (HDstrcmp(envval, "split")) { + if ((cwg=H5Gcreate(file, "test_tr1", 0))<0) goto error; + + if ((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error; + if (H5Tenum_insert(m_type, "RED", CPTR(eval, E1_RED ))<0) goto error; + if (H5Tenum_insert(m_type, "GREEN", CPTR(eval, E1_GREEN))<0) goto error; + if (H5Tenum_insert(m_type, "BLUE", CPTR(eval, E1_BLUE ))<0) goto error; + if (H5Tenum_insert(m_type, "WHITE", CPTR(eval, E1_WHITE))<0) goto error; + if (H5Tenum_insert(m_type, "BLACK", CPTR(eval, E1_BLACK))<0) goto error; + + + if ((f_type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error; + if (H5Tenum_insert(f_type, "RED", CPTR(ival, 105))<0) goto error; + if (H5Tenum_insert(f_type, "GREEN", CPTR(ival, 104))<0) goto error; + if (H5Tenum_insert(f_type, "BLUE", CPTR(ival, 103))<0) goto error; + if (H5Tenum_insert(f_type, "WHITE", CPTR(ival, 102))<0) goto error; + if (H5Tenum_insert(f_type, "BLACK", CPTR(ival, 101))<0) goto error; + + if ((space=H5Screate_simple(1, ds_size, NULL))<0) goto error; + if ((dset=H5Dcreate(cwg, "color_table", f_type, space, H5P_DEFAULT))<0) goto error; + if (H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1)<0) goto error; + if (H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2)<0) goto error; + + for (i=0; i<ds_size[0]; i++) { + if (data1[i]!=data2[i]) { + H5_FAILED(); + printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n", + (unsigned long)i, (int)(data1[i]), + (unsigned long)i, (int)(data2[i])); + goto error; + } } - } - if (H5Dclose(dset)<0) goto error; - if (H5Sclose(space)<0) goto error; - if (H5Tclose(m_type)<0) goto error; - if (H5Tclose(f_type)<0) goto error; - if (H5Gclose(cwg)<0) goto error; - PASSED(); + if (H5Dclose(dset)<0) goto error; + if (H5Sclose(space)<0) goto error; + if (H5Tclose(m_type)<0) goto error; + if (H5Tclose(f_type)<0) goto error; + if (H5Gclose(cwg)<0) goto error; + PASSED(); + } + else + { + SKIPPED(); + } return 0; - error: - H5E_BEGIN_TRY { - H5Dclose(dset); - H5Sclose(space); - H5Tclose(m_type); - H5Tclose(f_type); - H5Gclose(cwg); - } H5E_END_TRY; - return 1; + error: + H5E_BEGIN_TRY { + H5Dclose(dset); + H5Sclose(space); + H5Tclose(m_type); + H5Tclose(f_type); + H5Gclose(cwg); + } H5E_END_TRY; + return 1; } @@ -288,57 +298,68 @@ test_tr2(hid_t file) static c_e1 data1[10]={E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED}; c_e1 data2[10]; + const char *envval = NULL; TESTING("O(log N) converions"); - if ((cwg=H5Gcreate(file, "test_tr2", 0))<0) goto error; - - if ((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error; - if (H5Tenum_insert(m_type, "RED", CPTR(val1, E1_RED ))<0) goto error; - if (H5Tenum_insert(m_type, "GREEN", CPTR(val1, E1_GREEN))<0) goto error; - if (H5Tenum_insert(m_type, "BLUE", CPTR(val1, E1_BLUE ))<0) goto error; - if (H5Tenum_insert(m_type, "WHITE", CPTR(val1, E1_WHITE))<0) goto error; - if (H5Tenum_insert(m_type, "BLACK", CPTR(val1, E1_BLACK))<0) goto error; - - if ((f_type = H5Tcreate(H5T_ENUM, sizeof(int)))<0) goto error; - if (H5Tenum_insert(f_type, "RED", CPTR(val2, 1050))<0) goto error; - if (H5Tenum_insert(f_type, "GREEN", CPTR(val2, 1040))<0) goto error; - if (H5Tenum_insert(f_type, "BLUE", CPTR(val2, 1030))<0) goto error; - if (H5Tenum_insert(f_type, "WHITE", CPTR(val2, 1020))<0) goto error; - if (H5Tenum_insert(f_type, "BLACK", CPTR(val2, 1010))<0) goto error; - - if ((space=H5Screate_simple(1, ds_size, NULL))<0) goto error; - if ((dset=H5Dcreate(cwg, "color_table", f_type, space, H5P_DEFAULT))<0) - goto error; - if (H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1)<0) goto error; - if (H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2)<0) goto error; - - for (i=0; i<ds_size[0]; i++) { - if (data1[i]!=data2[i]) { - H5_FAILED(); - printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data2[i])); + envval = HDgetenv("HDF5_DRIVER"); + if (envval == NULL) + envval = "nomatch"; + if (HDstrcmp(envval, "split")) { + if ((cwg=H5Gcreate(file, "test_tr2", 0))<0) goto error; + + if ((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error; + if (H5Tenum_insert(m_type, "RED", CPTR(val1, E1_RED ))<0) goto error; + if (H5Tenum_insert(m_type, "GREEN", CPTR(val1, E1_GREEN))<0) goto error; + if (H5Tenum_insert(m_type, "BLUE", CPTR(val1, E1_BLUE ))<0) goto error; + if (H5Tenum_insert(m_type, "WHITE", CPTR(val1, E1_WHITE))<0) goto error; + if (H5Tenum_insert(m_type, "BLACK", CPTR(val1, E1_BLACK))<0) goto error; + + if ((f_type = H5Tcreate(H5T_ENUM, sizeof(int)))<0) goto error; + if (H5Tenum_insert(f_type, "RED", CPTR(val2, 1050))<0) goto error; + if (H5Tenum_insert(f_type, "GREEN", CPTR(val2, 1040))<0) goto error; + if (H5Tenum_insert(f_type, "BLUE", CPTR(val2, 1030))<0) goto error; + if (H5Tenum_insert(f_type, "WHITE", CPTR(val2, 1020))<0) goto error; + if (H5Tenum_insert(f_type, "BLACK", CPTR(val2, 1010))<0) goto error; + + if ((space=H5Screate_simple(1, ds_size, NULL))<0) goto error; + if ((dset=H5Dcreate(cwg, "color_table", f_type, space, H5P_DEFAULT))<0) goto error; + if (H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1)<0) goto error; + if (H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2)<0) goto error; + + for (i=0; i<ds_size[0]; i++) { + if (data1[i]!=data2[i]) { + H5_FAILED(); + printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n", + (unsigned long)i, (int)(data1[i]), + (unsigned long)i, (int)(data2[i])); + goto error; + } } - } - if (H5Dclose(dset)<0) goto error; - if (H5Sclose(space)<0) goto error; - if (H5Tclose(m_type)<0) goto error; - if (H5Tclose(f_type)<0) goto error; - if (H5Gclose(cwg)<0) goto error; - PASSED(); + if (H5Dclose(dset)<0) goto error; + if (H5Sclose(space)<0) goto error; + if (H5Tclose(m_type)<0) goto error; + if (H5Tclose(f_type)<0) goto error; + if (H5Gclose(cwg)<0) goto error; + PASSED(); + } + else + { + SKIPPED(); + puts(" Test not compatible with current Virtual File Driver"); + } return 0; - error: - H5E_BEGIN_TRY { - H5Dclose(dset); - H5Sclose(space); - H5Tclose(m_type); - H5Tclose(f_type); - H5Gclose(cwg); - } H5E_END_TRY; - return 1; + error: + H5E_BEGIN_TRY { + H5Dclose(dset); + H5Sclose(space); + H5Tclose(m_type); + H5Tclose(f_type); + H5Gclose(cwg); + } H5E_END_TRY; + return 1; } |