diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2008-05-08 13:30:30 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2008-05-08 13:30:30 (GMT) |
commit | cb79e86d4b8b0f4f68c48856e28a5e2c9ed7d229 (patch) | |
tree | f0a06d7af2a5fcd92902859d8615f1d1e262756d /test/links.c | |
parent | a67435cf3b0c91001aefb2c226f66bd573fb07fc (diff) | |
download | hdf5-cb79e86d4b8b0f4f68c48856e28a5e2c9ed7d229.zip hdf5-cb79e86d4b8b0f4f68c48856e28a5e2c9ed7d229.tar.gz hdf5-cb79e86d4b8b0f4f68c48856e28a5e2c9ed7d229.tar.bz2 |
[svn-r14952] 1. test/links.c: put in external link tests for windows
2. src/H5private.h: remove #define for HDputenv()
Diffstat (limited to 'test/links.c')
-rw-r--r-- | test/links.c | 713 |
1 files changed, 651 insertions, 62 deletions
diff --git a/test/links.c b/test/links.c index fec25a1..9dcd810 100644 --- a/test/links.c +++ b/test/links.c @@ -20,10 +20,6 @@ * Purpose: Tests hard, soft (symbolic) & external links. */ -#include "h5test.h" - -#include "H5Lprivate.h" - /* * This file needs to access private information from the H5G package. * This file also needs to access the group testing code. @@ -32,6 +28,9 @@ #define H5G_TESTING #include "H5Gpkg.h" /* Groups */ +#include "h5test.h" +#include "H5Lprivate.h" + /* File for external link test. Created with gen_udlinks.c */ #define LINKED_FILE "be_extlink2.h5" @@ -48,10 +47,10 @@ const char *FILENAME[] = { "links6", /* 9 */ "links7", /* 10 */ "links8", /* 11 */ - "extlinks0", /* 12: main files */ - "tmp/extlinks0", /* 13: */ - "extlinks1", /* 14: target files */ - "tmp/extlinks1", /* 15: */ + "extlinks0", /* 12: main files */ + "tmp/extlinks0", /* 13: */ + "extlinks1", /* 14: target files */ + "tmp/extlinks1", /* 15: */ "extlinks2", /* 16: */ "tmp/extlinks2", /* 17: */ "extlinks3", /* 18: */ @@ -65,6 +64,14 @@ const char *FILENAME[] = { "tmp/extlinks8", /* 26: */ "extlinks9", /* 27: */ "tmp/extlinks9", /* 28: */ + "extlinks10", /* 29: */ /* TESTS for windows */ + "tmp/extlinks10", /* 30: */ + "tmp/extlinks11", /* 31: */ + "tmp/extlinks12", /* 32: */ + "extlinks13", /* 33: */ + "tmp/extlinks13", /* 34: */ + "tmp/extlinks14", /* 35: */ + "tmp/extlinks15", /* 36: */ NULL }; @@ -2580,12 +2587,14 @@ external_link_dangling(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_env: test 1 * - * Purpose: 1. Create target file in tmp directory ("tmp/extlinks1") - * 2. Create main file in current directory ("extlinks0") -* 3. Create external link to target file ("extlinks1") - * 4. Set up environment variable "HDF5_EXT_PREFIX" to be ".:tmp" + * Purpose: + * 1. target link: "extlinks1" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks1" + * 4. The environment variable "HDF5_EXT_PREFIX" should be set to ".:tmp" * Should be able to access the target file in tmp directory through searching - * the pathnames set in HDF5_EXT_PREFIX + * the pathnames set in HDF5_EXT_PREFIX. + * This test will be skipped if HDF5_EXT_PREFIX is not set as expected. * * * Return: Success: 0 @@ -2603,10 +2612,7 @@ external_link_env(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group IDs */ - - char *envval=NULL; - static char *new_env = "HDF5_EXT_PREFIX=.:tmp"; - static char *old_env = "HDF5_EXT_PREFIX="; + const char *envval = NULL; char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], @@ -2617,6 +2623,12 @@ external_link_env(hid_t fapl, hbool_t new_format) else TESTING("external links via environment variable") + if ((envval = HDgetenv("HDF5_EXT_PREFIX")) == NULL) + envval = "nomatch"; + if (HDstrcmp(envval, ".:tmp")) { + SKIPPED(); + return(0); + } /* set up name for main file:"extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); @@ -2644,18 +2656,11 @@ external_link_env(hid_t fapl, hbool_t new_format) /* Create external link to target file */ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if (HDputenv(new_env) < 0) - TEST_ERROR - - /* Open object through external link */ H5E_BEGIN_TRY { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); } H5E_END_TRY; - if (HDputenv(old_env) < 0) - TEST_ERROR - /* should be able to find the target file from pathnames set via environment variable */ if (gid < 0) { H5_FAILED(); @@ -2682,9 +2687,9 @@ external_link_env(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_prefix: test 2 * - * Purpose: 1. Create the target file in tmp directory ("tmp/extlinks2") - * 2. Create the main file in current directory ("extlinks0") -* 3. Create external link to target file ("extlinks2") + * Purpose: 1. target link: "extlinks2" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks2" * 4. Set up external link prefix via H5Pset_elink_prefix() to be "tmp" * Should be able to access the target file in tmp directory via the prefix set * by H5Pset_elink_prefix() @@ -2777,12 +2782,10 @@ external_link_prefix(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_abs_mainpath: test 3 * - * Purpose: 1. Create target file in tmp directory ("tmp/extlinks3") - * 2. Create main file (with absolute pathname) in tmp directory ("/CWD/tmp/extlinks0") - * 3. Create external link to target file without absolute path ("extlinks3") - * Should be able to access the target file via the main file's - * absolute pathname ("/CWD/tmp") - * + * Purpose: 1. target link: "extlinks3" + * 2. main file: Linux:"/CWD/tmp/extlinks0"; Windows: "<cur drive>:/CWD/tmp/extlinks0" + * 3. target file: "tmp/extlinks3" + * Should be able to access the target file via the main file's absolute path * * Return: Success: 0 * Failure: -1 @@ -2819,7 +2822,11 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) TEST_ERROR - /* set up name for main file: "/CWD/tmp/extlinks0" */ + /* + * set up name for main file: + * Linux: "/CWD/tmp/extlinks0" + * Window: "<cur drive>:/CWD/tmp/extlinks0" + */ HDstrcpy(tmpname, cwdpath); HDstrcat(tmpname, "/"); HDstrcat(tmpname, FILENAME[13]); @@ -2871,12 +2878,10 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_rel_mainpath: test 4 * - * Purpose: 1. Create target file in tmp directory ("tmp/extlinks4") - * Purpose: 2. Create main file (with relative pathname) in tmp directory ("tmp/extlinks0") - * 3. Create external link to target file without the absolute pathname ("extlinks4") - * Should be able to access the target file via the main file's - * CWD+relative path ("/CWD/tmp") - * + * Purpose: 1. target link: "extlinks4" + * 2. main file: "tmp/extlinks0" + * 3. target file: "tmp/extlinks4" + * Should be able to access the target file via the main file's CWD+relative path * * Return: Success: 0 * Failure: -1 @@ -2958,9 +2963,9 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_cwd: test 5 * - * Purpose: 1. Create main file (with absolute path) in tmp directory ("/CWD/tmp/extlinks0") - * 2. Create target file in current working directory ("extlinks5") - * 3. Create external link to target file (without the absolute path) ("extlinks5") + * Purpose: 1. target link: "extlinks5" + * 2. main file: Linux:"/CWD/tmp/extlinks0"; Window: "<cur drive>:/CWD/tmp/extlinks0" + * 2. target file: "extlinks5" * Should be able to access the target file in the current working directory * * @@ -2997,7 +3002,11 @@ external_link_cwd(hid_t fapl, hbool_t new_format) if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) TEST_ERROR - /* set up name for main file: "/CWD/tmp/extlinks0" */ + /* + * set up name for main file: + * Linux: "/CWD/tmp/extlinks0" + * Windows: "<cur drive>:/CWD/tmp/extlinks0" + */ HDstrcpy(tmpname, cwdpath); HDstrcat(tmpname, "/"); HDstrcat(tmpname, FILENAME[13]); @@ -3049,10 +3058,10 @@ external_link_cwd(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_abstar: test 6 * - * Purpose: 1. Create target file in tmp directory (with absolute path) ("tmp/extlinks6") - * 2. Create main file in current directory ("extlinks0") - * 3. Create external link to target file (with absolute path) ("/CWD/tmp/extlinks6") - * Should be able to access the target file (with absolute path) directly + * Purpose: 1. target link: Linux:"/CWD/tmp/extlinks6"; Windows:"<cur drive>:/CWD/tmp/extlinks6" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks6" + * Should be able to access the target file's absolute path * * Return: Success: 0 * Failure: -1 @@ -3087,7 +3096,11 @@ external_link_abstar(hid_t fapl, hbool_t new_format) if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) TEST_ERROR - /* set up name for external linked target file: "/CWD/tmp/extlinks6" */ + /* + * set up name for external linked target file: + * Linux: "/CWD/tmp/extlinks6" + * Windows: "<cur drive>:/CWD/tmp/extlinks6" + */ HDstrcpy(tmpname, cwdpath); HDstrcat(tmpname, "/"); HDstrcat(tmpname, FILENAME[23]); @@ -3141,10 +3154,9 @@ external_link_abstar(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_abstar_cur: test 7 * - * Purpose: 1. Create target file in current working directory "extlinks7" - * 2. Create main file in current working directory "extlinks0" - * 3. Create external link to target file (with absolute path - * that does not exist in that directory) ("/CWD/tmp/extlinks7") + * Purpose: 1. target link: Linux: "/CWD/tmp/extlinks7"; Windows: "<cur drive>:/CWD/tmp/extlinks7" + * 2. main file: "extlinks0" + * 3. target file: "extlinks7" * Should be able to access the target file via the main file's CWD. * * Return: Success: 0 @@ -3183,7 +3195,11 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) TEST_ERROR - /* set up name for external linked target file: "/CWD/tmp/extlinks7" */ + /* + * set up name for external linked target file: + * Linux: "/CWD/tmp/extlinks7" + * Windows: "<cur drive>:/CWD/tmp/extlinks7" + */ HDstrcpy(tmpname, cwdpath); HDstrcat(tmpname, "/"); HDstrcat(tmpname, FILENAME[25]); @@ -3235,11 +3251,10 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_reltar: test 8 * - * Purpose: 1. Create target file in tmp directory ("tmp/extlinks8") - * 2. Create main file in current working directory ("extlinks0") - * 3. Create external link to target file with relative path ("tmp/extlinks8") - * Should be able to access the target file via the main file's - * relative pathname (CWD + relative path of targetfile: "/CWD/tmp/extlinks8") + * Purpose: 1. target link: Linux:"tmp/extlinks8" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks8" + * Should be able to access the target file via the main file's CWD+ target's relative path * * Return: Success: 0 * Failure: -1 @@ -3323,10 +3338,11 @@ external_link_reltar(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- * Function: external_link_chdir: test 9 * - * Purpose: 1. Create target file in tmp directory ("tmp/extlinks9") - * 2. Create main file in current working directory ("extlinks0") + * Purpose: + * 1. target link: "extlinks9" + * 2. main file: "extlinks0" + * 3. target file" "tmp/extlinks9" * 3. chdir "tmp" - * 3. Create external link to target file ("extlinks9") * Should be able to access the target file in current working directory * * Return: Success: 0 @@ -3414,6 +3430,570 @@ external_link_chdir(hid_t fapl, hbool_t new_format) } H5E_END_TRY; return -1; } /* end external_link_chdir() */ + + + +#ifdef H5_HAVE_WINDOW_PATH + +/*------------------------------------------------------------------------- + * Function: external_link_win1 + * + * Purpose: + * 1. target link: "/CWD/tmp/extlinks10" + * 2. main file: "extlinks0" + * 3. target file: "extlinks10" + * Should be able to find the target file via main file's current drive/rel path + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * April 15, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_win1(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via main file's current drive/rel path(windows)(w/new group format)") + else + TESTING("external links via main file's current drive/rel path(windows)") + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + + if (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL) + TEST_ERROR + + /* set up name for target link: "/CWD/tmp/extlinks10" */ + HDstrcpy(tmpname, &cwdpath[2]); /* stripped the drive letter to make it rel drive but absolute path */ + HDstrcat(tmpname, "/"); + HDstrcat(tmpname, FILENAME[30]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "extlinks10" */ + h5_fixname(FILENAME[29], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file via main file's CWD*/ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in CWD."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_win2() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_win2 + * + * Purpose: + * 1. target link: "/CWD/tmp/extlinks11" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks11" + * Should be able to access the target file directly (rel drive/abs path) + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * April 15, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_win2(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via target's rel drive/abs path directly(windows)(w/new group format)") + else + TESTING("external links via target's rel drive/abs path directly(windows)") + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + + /* create tmp directory and get current working directory path */ + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL)) + TEST_ERROR + + /* set up name for target link: "/CWD/tmp/extlinks11" */ + HDstrcpy(tmpname, &cwdpath[2]); /* stripped the drive letter to make it relative drive but absolute path */ + HDstrcat(tmpname, "/"); + HDstrcat(tmpname, FILENAME[31]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "tmp/extlinks11" */ + h5_fixname(FILENAME[31], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file directly */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_win2() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_win3 + * + * Purpose: + * 1. target link: "<cur drive>:tmp/extlinks12" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks12" + * Should be able to access the target file directly (abs drive/rel path) + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * April i15 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_win3(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via target's abs drive/rel path directly (windows)(w/new group format)") + else + TESTING("external links via target's abs drive/rel path directly (windows)") + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + + /* create tmp directory */ + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* set up name for target link: "<drive-letter>:tmp/extlinks12" */ + drive = HDgetdrive(); + sprintf(tmpname, "%c:%s", (drive+'A'-1), FILENAME[32]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "tmp/extlinks12" */ + h5_fixname(FILENAME[32], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file directly */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_win3() */ + +/*------------------------------------------------------------------------- + * Function: external_link_win4 + * + * Purpose: + * 1. target link: "<cur drive>:extlinks13" + * 2. main file: "<cur-drive>:tmp/extlinks0" + * 3. target file: tmp/extlinks13 + * Should be able to access the target file via main file's abs drive/rel path + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * April 15, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_win4(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via main file's abs drive/rel path (windows)(w/new group format)") + else + TESTING("external links via main file's abs drive/rel path (windows)") + + /* set up name for main file: "<drive-letter>:tmp/extlinks0" */ + drive = HDgetdrive(); + sprintf(tmpname, "%c:%s", (drive+'A'-1), FILENAME[13]); + h5_fixname(tmpname, fapl, filename1, sizeof filename1); + + /* set up name for target link: "<drive-letter>:extlinks13" */ + sprintf(tmpname, "%c:%s", (drive+'A'-1), FILENAME[33]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "tmp/extlinks13" */ + h5_fixname(FILENAME[34], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file via main file's absolute drive/relative path */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in CWD."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_win4() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_win5 + * + * Purpose: + * 1. target link: "<cur drive+1>:tmp/extlinks14" + * 2. main file: "/CWD/extlinks0" + * 3. target file: "tmp/extlinks14" + * Should be able to access the target file via main file's relative drive/absolute path + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * April 15, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_win5(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via main file's rel drive/abs path (windows)(w/new group format)") + else + TESTING("external links via main file's rel drive/abs path (windows)") + + if (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL) + TEST_ERROR + drive = HDgetdrive(); + + /* set up name for main file: "/CWD/extlinks0" */ + HDstrcpy(tmpname, &cwdpath[2]); /* stripped the drive letter to make it rel drive but absolute path */ + HDstrcat(tmpname, "/"); + HDstrcat(tmpname, FILENAME[12]); + h5_fixname(tmpname, fapl, filename1, sizeof filename1); + + /* set up name for target link: "<drive-letter+1>:tmp/extlinks14" */ + sprintf(tmpname, "%c:%s", ((drive+1)+'A'-1), FILENAME[35]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "tmp/extlinks14" */ + h5_fixname(FILENAME[35], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file via main file's rel drive/abs path */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in CWD."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_win5() */ + + +/*------------------------------------------------------------------------- + * Function: external_link_win6 + * + * Purpose: + * 1. target link: "<cur drive+1>:tmp/extlinks15" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks15" + * Should be able to access the target file via target's current drive/rel path + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi + * April 15, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_link_win6(hid_t fapl, hbool_t new_format) +{ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; + + if(new_format) + TESTING("external links via target's current drive/rel path (windows)(w/new group format)") + else + TESTING("external links via target's current drive/rel path (windows)") + + /* create tmp directory */ + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + drive = HDgetdrive(); + + /* set up name for main file: "extlinks0" */ + h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); + + /* set up name for target link: "<drive-letter+1>:tmp/extlinks15" */ + sprintf(tmpname, "%c:%s", ((drive+1)+'A'-1), FILENAME[36]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "tmp/extlinks15" */ + h5_fixname(FILENAME[36], fapl, filename3, sizeof filename3); + + /* Create the target file */ + if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* closing for target file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + + /* Create the main file */ + if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to target file */ + if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Open object through external link */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); + } H5E_END_TRY; + + /* should be able to find the target file via target file's rel path in current drive */ + if (gid < 0) { + H5_FAILED(); + puts(" Should have found the file in tmp."); + goto error; + } + + /* closing for main file */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose (gid); + H5Fclose (fid); + } H5E_END_TRY; + return -1; +} /* end external_link_win6() */ + +#endif /* H5_HAVE_WINDOW_PATH */ + /*------------------------------------------------------------------------- * Function: external_link_recursive @@ -11138,6 +11718,15 @@ main(void) nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0; +#ifdef H5_HAVE_WINDOW_PATH + nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0; +#endif + /* These tests assume that external links are a form of UD links, * so assume that everything that passed for external links * above has already been tested for UD links. |