1998-07-31 00:38:21 +08:00
|
|
|
|
/*
|
|
|
|
|
* Copyright <EFBFBD> 1998 NCSA
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke <matzke@llnl.gov>
|
|
|
|
|
* Thursday, July 30, 1998
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Determines if the modification time message is working
|
|
|
|
|
* properly. Specifically, the code in H5O_mtime_decode() is
|
|
|
|
|
* very OS-dependent and this test tries to figure out if it's
|
|
|
|
|
* working properly.
|
|
|
|
|
*/
|
2001-04-04 02:09:16 +08:00
|
|
|
|
#include "h5test.h"
|
1998-11-03 01:58:28 +08:00
|
|
|
|
|
1998-11-24 04:40:35 +08:00
|
|
|
|
const char *FILENAME[] = {
|
|
|
|
|
"mtime",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
1998-07-31 00:38:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: main
|
|
|
|
|
*
|
|
|
|
|
* Purpose: H5O_mtime_decode() test.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success:
|
|
|
|
|
*
|
|
|
|
|
* Failure:
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Thursday, July 30, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
main(void)
|
|
|
|
|
{
|
1998-11-24 04:40:35 +08:00
|
|
|
|
hid_t fapl, file, space, dset;
|
1998-07-31 00:38:21 +08:00
|
|
|
|
hsize_t size[1] = {2};
|
|
|
|
|
time_t now;
|
|
|
|
|
struct tm *tm;
|
1998-08-31 21:46:47 +08:00
|
|
|
|
H5G_stat_t sb1, sb2;
|
1998-11-26 01:21:21 +08:00
|
|
|
|
signed char buf1[32], buf2[32];
|
|
|
|
|
char filename[1024];
|
1998-07-31 00:38:21 +08:00
|
|
|
|
|
1998-11-24 04:40:35 +08:00
|
|
|
|
h5_reset();
|
|
|
|
|
fapl = h5_fileaccess();
|
|
|
|
|
|
|
|
|
|
TESTING("modification time messages");
|
1998-07-31 00:38:21 +08:00
|
|
|
|
|
|
|
|
|
/* Create the file, create a dataset, then close the file */
|
1998-11-24 04:40:35 +08:00
|
|
|
|
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
|
|
|
|
|
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
|
|
|
|
|
return 1;
|
|
|
|
|
if ((space=H5Screate_simple(1, size, NULL))<0) return 1;
|
1998-11-26 01:21:21 +08:00
|
|
|
|
if ((dset=H5Dcreate(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT))<0)
|
1998-11-24 04:40:35 +08:00
|
|
|
|
return 1;
|
1998-07-31 00:38:21 +08:00
|
|
|
|
now = time(NULL);
|
|
|
|
|
if (H5Dclose(dset)<0) return 1;
|
|
|
|
|
if (H5Sclose(space)<0) return 1;
|
|
|
|
|
if (H5Fclose(file)<0) return 1;
|
|
|
|
|
|
1998-08-31 21:46:47 +08:00
|
|
|
|
/*
|
|
|
|
|
* Open the file and get the modification time. We'll test the new
|
1998-11-24 04:40:35 +08:00
|
|
|
|
* H5Gget_objinfo() arguments too: being able to stat something without
|
|
|
|
|
* knowing its name.
|
1998-08-31 21:46:47 +08:00
|
|
|
|
*/
|
1998-11-24 04:40:35 +08:00
|
|
|
|
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
|
|
|
|
|
if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) return 1;
|
1998-09-03 05:16:24 +08:00
|
|
|
|
if (H5Gget_objinfo(file, "dset", TRUE, &sb1)<0) return 1;
|
1998-08-31 21:46:47 +08:00
|
|
|
|
if ((dset=H5Dopen(file, "dset"))<0) return 1;
|
1998-09-03 05:16:24 +08:00
|
|
|
|
if (H5Gget_objinfo(dset, ".", TRUE, &sb2)<0) return 1;
|
1998-08-31 21:46:47 +08:00
|
|
|
|
if (H5Dclose(dset)<0) return 1;
|
1998-07-31 00:38:21 +08:00
|
|
|
|
if (H5Fclose(file)<0) return 1;
|
|
|
|
|
|
1998-09-03 05:16:24 +08:00
|
|
|
|
/* Compare times from the two ways of calling H5Gget_objinfo() */
|
1998-08-31 21:46:47 +08:00
|
|
|
|
if (sb1.objno[0]!=sb2.objno[0] || sb1.objno[1]!=sb2.objno[1] ||
|
|
|
|
|
sb1.mtime!=sb2.mtime) {
|
2001-01-26 01:03:29 +08:00
|
|
|
|
H5_FAILED();
|
1998-11-24 04:40:35 +08:00
|
|
|
|
puts(" Calling H5Gget_objinfo() with the dataset ID returned");
|
|
|
|
|
puts(" different values than calling it with a file and dataset");
|
|
|
|
|
puts(" name.");
|
1998-08-31 21:46:47 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
1998-07-31 00:38:21 +08:00
|
|
|
|
/* Compare times -- they must be within 60 seconds of one another */
|
1998-08-31 21:46:47 +08:00
|
|
|
|
if (0==sb1.mtime) {
|
1998-11-24 04:40:35 +08:00
|
|
|
|
SKIPPED();
|
|
|
|
|
puts(" The modification time could not be decoded on this OS.");
|
|
|
|
|
puts(" Modification times will be mantained in the file but");
|
|
|
|
|
puts(" cannot be queried on this system. See H5O_mtime_decode().");
|
1998-09-03 23:30:11 +08:00
|
|
|
|
return 0;
|
1998-08-31 21:46:47 +08:00
|
|
|
|
} else if (fabs(HDdifftime(now, sb1.mtime))>60.0) {
|
2001-01-26 01:03:29 +08:00
|
|
|
|
H5_FAILED();
|
1998-08-31 21:46:47 +08:00
|
|
|
|
tm = localtime(&(sb1.mtime));
|
1999-02-25 23:40:27 +08:00
|
|
|
|
strftime((char*)buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm);
|
1998-07-31 00:38:21 +08:00
|
|
|
|
tm = localtime(&now);
|
1999-02-25 23:40:27 +08:00
|
|
|
|
strftime((char*)buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S", tm);
|
1998-11-24 04:40:35 +08:00
|
|
|
|
printf(" got: %s\n ans: %s\n", buf1, buf2);
|
1998-07-31 00:38:21 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* All looks good */
|
1998-11-24 04:40:35 +08:00
|
|
|
|
PASSED();
|
|
|
|
|
puts("All modification time tests passed.");
|
2000-09-10 08:08:27 +08:00
|
|
|
|
h5_cleanup(FILENAME, fapl);
|
1998-07-31 00:38:21 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|