summaryrefslogtreecommitdiffstats
path: root/test/tverbounds18.c
blob: 0b501cb2bda7992cbc4be407b8858c386f1be998 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/***********************************************************
 *
 * Test program:  tverbounds18
 *
 * Test 1.8 compatibility with version bounds
 *
 * Description
 * ===========
 *       This file tests the compatibility in the files generated
 *       by gen_bounds.c in HDF5 1.10.2:
 *       - bounds_earliest_latest.h5
 *       - bounds_earliest_v18.h5
 *       - bounds_latest_latest.h5
 *       - bounds_v18_latest.h5
 *       - bounds_v18_v18.h5
 *
 * Oct 30, 2017
 *
 *************************************************************/

#include "h5test.h"
#include "H5srcdir.h"
#include "testhdf5.h"

/***********************************************************************
 * test_earliest_latest() reads file "bounds_earliest_latest.h5"
 *
 * Description:
 *   This test shows that the 1.8 library is able to open a chunked dataset
 *   with layout version 3 in a file with superblock version 0.
 *   However, it cannot open the chunked dataset with layout version 4
 *   in the same file.
 *
 ***********************************************************************/
#define FILENAME_E_L "bounds_earliest_latest.h5"
static void
test_earliest_latest(void)
{
    hid_t  fid  = FAIL; /* File ID */
    hid_t  dset = FAIL; /* Dataset ID */
    herr_t ret;         /* Return value */

    /* Test file name must have correct path when srcdir is used */
    const char *testfile = H5_get_srcdir_filename(FILENAME_E_L);

    /* Open file */
    fid = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT);
    CHECK(fid, FAIL, "H5Fopen");

    /*
     * Open the chunked dataset with layout version 3
     */

    /* Open the dataset */
    dset = H5Dopen2(fid, "DS_chunked_layout_3", H5P_DEFAULT);
    CHECK(dset, FAIL, "H5Dopen2");

    ret = H5Dclose(dset);
    CHECK(ret, FAIL, "H5Dclose");

    /*
     * Open the chunked dataset with layout version 4.  This should fail
     * with HDF5 1.8.
     */

    /* Open the dataset */
    H5E_BEGIN_TRY { dset = H5Dopen2(fid, "DS_chunked_layout_4", H5P_DEFAULT); }
    H5E_END_TRY;
    VERIFY(dset, FAIL, "H5Dopen2");

    /* Close the file */
    ret = H5Fclose(fid);
    CHECK(ret, FAIL, "H5Fclose");
}

/***********************************************************************
 * test_earliest_v18() reads file "bounds_earliest_v18.h5"
 *
 * Description:
 *   This test shows that the 1.8 library is able to open a chunked dataset
 *   with layout version 3 in a file with superblock version 0.
 *
 ***********************************************************************/
#define FILENAME_E_18 "bounds_earliest_v18.h5"

static void
test_earliest_v18(void)
{
    hid_t  fid  = FAIL; /* File ID */
    hid_t  dset = FAIL; /* Dataset ID */
    herr_t ret;         /* Return value */

    /* Test file name must have correct path when srcdir is used */
    const char *testfile = H5_get_srcdir_filename(FILENAME_E_18);

    /* Open file */
    fid = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT);
    CHECK(fid, FAIL, "H5Fopen");

    /*
     * Open the chunked dataset with layout version 3
     */

    /* Open the dataset */
    dset = H5Dopen2(fid, "DS_chunked_layout_3", H5P_DEFAULT);
    CHECK(dset, FAIL, "H5Dopen2");

    ret = H5Dclose(dset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close the file */
    ret = H5Fclose(fid);
    CHECK(ret, FAIL, "H5Fclose");
}

/***********************************************************************
 * test_latest_latest() reads file "bounds_latest_latest.h5"
 *
 * Description:
 *   This test shows that the 1.8 library is unable to open a file with
 *   superblock version 3.
 *
 ***********************************************************************/
#define FILENAME_L_L "bounds_latest_latest.h5"

static void
test_latest_latest(void)
{
    hid_t fid = FAIL; /* File ID */

    /* Test file name must have correct path when srcdir is used */
    const char *testfile = H5_get_srcdir_filename(FILENAME_L_L);

    /* Opening the file of latest version bounds should fail with HDF5 1.8. */
    H5E_BEGIN_TRY { fid = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT); }
    H5E_END_TRY;
    VERIFY(fid, FAIL, "H5Fopen file with latest version bounds");
}

/***********************************************************************
 * test_v18_latest() reads file "bounds_v18_latest.h5"
 *
 * Description:
 *   This test shows that the 1.8 library is able to open a chunked dataset
 *   with layout version 3 in a file with superblock version 2.
 *
 ***********************************************************************/
#define FILENAME_18_L "bounds_v18_latest.h5"

static void
test_v18_latest(void)
{
    hid_t  fid  = FAIL; /* File ID */
    hid_t  dset = FAIL; /* Dataset ID */
    herr_t ret;         /* Return value */

    /* Test file name must have correct path when srcdir is used */
    const char *testfile = H5_get_srcdir_filename(FILENAME_18_L);

    /* Open file */
    fid = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT);
    CHECK(fid, FAIL, "H5Fopen");

    /*
     * Open the chunked dataset with layout version 3
     */

    /* Open the dataset */
    dset = H5Dopen2(fid, "DS_chunked_layout_3", H5P_DEFAULT);
    CHECK(dset, FAIL, "H5Dopen2");

    ret = H5Dclose(dset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close the file */
    ret = H5Fclose(fid);
    CHECK(ret, FAIL, "H5Fclose");
}

/***********************************************************************
 * test_v18_v18() reads file "bounds_v18_v18.h5"
 *
 * Description:
 *   This test shows that the 1.8 library is able to open a chunked dataset
 *   with layout version 3 in a file with superblock version 2 and
 *   version 1.8 bounds.  However, it cannot open the chunked
 *   dataset with layout version 4 in the same file.
 *
 ***********************************************************************/
#define FILENAME_18_18 "bounds_v18_v18.h5"

static void
test_v18_v18(void)
{
    hid_t  fid  = FAIL; /* File ID */
    hid_t  dset = FAIL; /* Dataset ID */
    herr_t ret;         /* Return value */

    /* Test file name must have correct path when srcdir is used */
    const char *testfile = H5_get_srcdir_filename(FILENAME_18_18);

    /* Open file */
    fid = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT);
    CHECK(fid, FAIL, "H5Fopen");

    /*
     * Open the chunked dataset with layout version 3
     */

    /* Open the dataset */
    dset = H5Dopen2(fid, "DS_chunked_layout_3", H5P_DEFAULT);
    CHECK(dset, FAIL, "H5Dopen2");

    ret = H5Dclose(dset);
    CHECK(ret, FAIL, "H5Dclose");

    /*
     * Open the chunked dataset with layout version 4.  This should fail
     * with HDF5 1.8.
     */

    /* Open the dataset */
    H5E_BEGIN_TRY { dset = H5Dopen2(fid, "DS_chunked_layout_4", H5P_DEFAULT); }
    H5E_END_TRY;
    VERIFY(dset, FAIL, "H5Dopen2");

    /* Close the file */
    ret = H5Fclose(fid);
    CHECK(ret, FAIL, "H5Fclose");
}

/*************************************************************************
**  test_verbounds_18()
**      Main routine to test library version bounds with HDF5 1.8 library.
**
*************************************************************************/
void
test_verbounds_18(void)
{
    /* Output message about test being performed */
    MESSAGE(5, ("Testing Compatibility of Version Bounds with 1.8\n"));

    /* Test with file bounds_earliest_latest.h5 */
    test_earliest_latest();

    /* Test with file bounds_earliest_v18.h5 */
    test_earliest_v18();

    /* Test with file bounds_latest_latest.h5 */
    test_latest_latest();

    /* Test with file bounds_v18_latest.h5 */
    test_v18_latest();

    /* Test with file bounds_v18_v18.h5 */
    test_v18_v18();
}

/*-------------------------------------------------------------------------
 * Function:    cleanup_verbounds_18
 *
 * Purpose:     Cleanup temporary test files
 *
 * Return:      none
 *
 *-------------------------------------------------------------------------
 */
void
cleanup_verbounds_18(void)
{
}