diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2008-04-16 17:13:20 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2008-04-16 17:13:20 (GMT) |
commit | a642c440f711855767e373f9bd50fcd1cdbe1daa (patch) | |
tree | 5641a7dc3116729d30b783418a8746e0edfd6b64 /test | |
parent | 58b37f0a880740a94f52f4fc6afcfd14e8b5714e (diff) | |
download | hdf5-a642c440f711855767e373f9bd50fcd1cdbe1daa.zip hdf5-a642c440f711855767e373f9bd50fcd1cdbe1daa.tar.gz hdf5-a642c440f711855767e373f9bd50fcd1cdbe1daa.tar.bz2 |
[svn-r14847] 1. test/links.c: add tests specific for windows
remove HDputenv() from external_link_env() test
(will add script later to set HDF5_EXT_PREFIX for running the test)
modify and add more comments
2. src/H5private.h: remove #define for HDputenv()
Tested on kagiso, linew and smirom.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/links.c | 705 |
2 files changed, 649 insertions, 58 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 191e999..b0f80cb 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -105,7 +105,7 @@ flush2.chkexe_: flush1.chkexe_ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5\ tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab.h5 \ extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2]\ - links.h5 links[0-6]*.h5 extlinks[0-9].h5 tmp \ + links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ big.data big[0-9][0-9][0-9][0-9][0-9].h5 \ stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \ tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \ diff --git a/test/links.c b/test/links.c index 7671c60..26da4c3 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" @@ -65,6 +64,15 @@ 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: */ + "extlinks14", /* 35: */ + "tmp/extlinks14", /* 36: */ + "tmp/extlinks15", /* 37: */ NULL }; @@ -2580,12 +2588,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 +2613,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 +2624,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,17 +2657,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(); @@ -2681,9 +2688,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() @@ -2776,12 +2783,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 @@ -2818,7 +2823,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]); @@ -2870,12 +2879,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 @@ -2957,9 +2964,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 * * @@ -2996,7 +3003,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]); @@ -3048,10 +3059,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 @@ -3086,7 +3097,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]); @@ -3140,10 +3155,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 @@ -3182,7 +3196,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]); @@ -3234,11 +3252,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 @@ -3322,10 +3339,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 @@ -3413,6 +3431,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 CWD + * + * 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 CWD (windows)(w/new group format)") + else + TESTING("external links via main file's CWD (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 + * + * 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 (windows)(w/new group format)") + else + TESTING("external links via target's rel drive/abs path (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 + * + * 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 (windows)(w/new group format)") + else + TESTING("external links via target's abs drive/rel path (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>:tmp/extlinks13" + * 2. main file: "<cur-drive>:extlinks0" + * 3. target file: extlinks13 + * Should be able to access the target file via main file's CWD + * + * 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>:extlinks0" */ + drive = HDgetdrive(); + sprintf(tmpname, "%c:%s", (drive+'A'-1), FILENAME[12]); + h5_fixname(tmpname, fapl, filename1, sizeof filename1); + + /* set up name for target link: "<drive-letter>:tmp/extlinks13" */ + sprintf(tmpname, "%c:%s", (drive+'A'-1), FILENAME[34]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "extlinks13" */ + h5_fixname(FILENAME[33], 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>:tmp/extlinks14" + * 2. main file: "/CWD/extlinks0" + * 3. target file: "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, filename2, sizeof filename2); + + /* set up name for target link: "<drive-letter>:tmp/extlinks14" */ + sprintf(tmpname, "%c:%s", (drive+'A'-1), FILENAME[36]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "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 rel path in the current drive + * + * 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 rel path in current drive(windows)(w/new group format)") + else + TESTING("external links via target's rel path in current drive(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[37]); + h5_fixname(tmpname, fapl, filename2, sizeof filename2); + + /* set up name for target file: "tmp/extlinks15" */ + h5_fixname(FILENAME[37], 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 @@ -11137,6 +11719,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. |