Skip to content

Commit 07c2dca

Browse files
Skip unicode tests for specific VFDs (#5823)
During testing, specific VFDs create files with names that are different than the "base" filename passed to H5Fcreate(). The unicode tests are setup to expect specific filenames, so these tests are skipped when the test utility function h5_fixname() would modify the "base" filename.
1 parent 8bcb794 commit 07c2dca

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

test/tunicode.c

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#define COMP_FLOAT_VAL (-42.0F)
3636
#define COMP_DOUBLE_VAL 42.0
3737

38+
/* Size of buffer used for temporary filenames */
39+
#define TEMP_FILENAME_BUF_SIZE 128
40+
3841
/* Test function prototypes */
3942
static void test_utf8_filenames(void);
4043
static void test_utf8_conv_failure(void);
@@ -72,13 +75,29 @@ test_utf8_filenames(void)
7275
const char *quot_filename = u8"‚.h5"; /* U+201A "Single Low-9 Quotation Mark" */
7376
const char *chin_filename = u8"漢字.h5";
7477
hid_t fid = H5I_INVALID_HID;
78+
hid_t fapl = H5I_INVALID_HID;
7579
char *env = NULL;
80+
char fixed_filename[TEMP_FILENAME_BUF_SIZE];
7681
herr_t ret;
7782
int acc_ret;
7883
#ifdef H5_HAVE_WIN32_API
7984
wchar_t *wfilename = NULL;
8085
#endif
8186

87+
/*
88+
* If the filenames would be perturbed by h5_fixname() due to
89+
* a specific VFD being used, skip this test as the filename
90+
* could be unpredictable and cause unexpected failures.
91+
*/
92+
fapl = h5_fileaccess();
93+
CHECK(fapl, H5I_INVALID_HID, "H5Pcreate");
94+
h5_fixname(u8"€", fapl, fixed_filename, TEMP_FILENAME_BUF_SIZE);
95+
H5Pclose(fapl);
96+
if (0 != strcmp(euro_filename, fixed_filename)) {
97+
MESSAGE(5, ("Testing UTF-8 filenames -- SKIPPED due to unpredictable test filenames\n"));
98+
return;
99+
}
100+
82101
/*
83102
* If the HDF5_PREFER_WINDOWS_CODE_PAGE environment variable
84103
* is set to a true value, skip this test as the filenames
@@ -245,10 +264,28 @@ test_utf8_conv_failure(void)
245264
const char *filename = "\x83\x6E\x83\x8D\x81\x5B\x83\x8F\x81\x5B\x83\x8B\x83\x68"
246265
".h5";
247266
wchar_t wfilename[64];
248-
hid_t fid = H5I_INVALID_HID;
267+
hid_t fid = H5I_INVALID_HID;
268+
hid_t fapl = H5I_INVALID_HID;
269+
char fixed_filename[TEMP_FILENAME_BUF_SIZE];
249270
herr_t ret;
250271
int int_ret;
251272

273+
/*
274+
* If the filename would be perturbed by h5_fixname() due to
275+
* a specific VFD being used, skip this test as the filename
276+
* could be unpredictable and cause unexpected failures.
277+
*/
278+
fapl = h5_fileaccess();
279+
CHECK(fapl, H5I_INVALID_HID, "H5Pcreate");
280+
h5_fixname("\x83\x6E\x83\x8D\x81\x5B\x83\x8F\x81\x5B\x83\x8B\x83\x68", fapl, fixed_filename,
281+
TEMP_FILENAME_BUF_SIZE);
282+
H5Pclose(fapl);
283+
if (0 != strcmp(filename, fixed_filename)) {
284+
MESSAGE(5, ("Testing UTF-8 filename conversion failure fallback -- SKIPPED due to unpredictable test "
285+
"filenames\n"));
286+
return;
287+
}
288+
252289
/*
253290
* If the current code page would cause a failure in the fallback
254291
* pathway (for example, if the current code page is UTF-8), skip
@@ -319,12 +356,30 @@ test_utf8_conv_failure(void)
319356
static void
320357
test_code_page_override(void)
321358
{
322-
const char *filename = "\xc3\x9f"; /* UTF-8 'ß' / Windows code page 1252 'ß' */
359+
const char *filename = "\xc3\x9f"
360+
".h5"; /* UTF-8 'ß' / Windows code page 1252 'ß' */
323361
hid_t fid = H5I_INVALID_HID;
362+
hid_t fapl = H5I_INVALID_HID;
324363
char *env = NULL;
364+
char fixed_filename[TEMP_FILENAME_BUF_SIZE];
325365
herr_t ret;
326366
int int_ret;
327367

368+
/*
369+
* If the filename would be perturbed by h5_fixname() due to
370+
* a specific VFD being used, skip this test as the filename
371+
* could be unpredictable and cause unexpected failures.
372+
*/
373+
fapl = h5_fileaccess();
374+
CHECK(fapl, H5I_INVALID_HID, "H5Pcreate");
375+
h5_fixname("\xc3\x9f", fapl, fixed_filename, TEMP_FILENAME_BUF_SIZE);
376+
H5Pclose(fapl);
377+
if (0 != strcmp(filename, fixed_filename)) {
378+
MESSAGE(5, ("Testing code pages environment variable override -- SKIPPED due to unpredictable test "
379+
"filenames"));
380+
return;
381+
}
382+
328383
#ifdef H5_HAVE_WIN32_API
329384
/* Perform some initial Windows-specific tests to see if this test
330385
* needs to be skipped

0 commit comments

Comments
 (0)