summaryrefslogtreecommitdiffstats
path: root/test/unlink.c
Commit message (Expand)AuthorAgeFilesLines
* Develop clang 13 format (#1933)Allen Byrne2022-07-261-2/+2
* sprintf to snprintf (#1815)Sean McBride2022-06-221-39/+39
* h5test.h testing macros get enclosed in do..while loops (#1721)Dana Robinson2022-05-041-548/+548
* Fixed Spelling Errors (#1166)Scot Breitenfeld2021-12-071-3/+3
* Update clang config (#473)Quincey Koziol2021-03-171-10/+40
* Fixed all clang-tidy bugprone-suspicious-string-compare warnings (#451)Sean McBride2021-03-101-1/+1
* Update license url (#332)Larry Knox2021-02-171-1/+1
* HD prefix updates in src/ and test/Dana Robinson2020-10-241-1/+1
* Clang-format of source filesAllen Byrne2020-09-301-939/+1467
* Removes staff email addresses from the repositoryDana Robinson2020-08-071-1/+1
* Squashed commit of the token_refactoring branch:Dana Robinson2020-01-161-13/+16
* Small changes from the token_refactoring branch, to reduce the delta to developQuincey Koziol2020-01-041-2/+2
* Fixed some exit calls.Dana Robinson2019-09-071-10/+6
* Add HD prefix to testsAllen Byrne2019-08-151-185/+185
* Changes made based on feedback from pull request #1039.Vailin Choi2018-05-141-6/+6
* Fix for HDFFV-10180 Performance issues with H5Oget_info.Vailin Choi2018-04-241-6/+6
* Merge pull request #426 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:hdf5_1_10 to hdf5...Larry Knox2017-04-251-6/+4
* Cleanups and normalizations against incoming page_buffering changes.Quincey Koziol2017-02-201-2/+2
* Changes to be committed:Frank.Willmore2016-10-251-1/+1
* [svn-r30238] Follow-on to HDFFV-9928: remove unconditional call of time.h typ...Allen Byrne2016-08-011-1/+0
* [svn-r28138] Add first support for _Bool and make hbool_t a "real" _Bool if a...Jerome Soumagne2015-10-201-1/+1
* [svn-r27768] Description:Quincey Koziol2015-09-141-1/+1
* [svn-r27548] Revert r27545Jerome Soumagne2015-08-211-1/+1
* [svn-r27545] Add first support for _Bool and make hbool_t a "real" _Bool if a...Jerome Soumagne2015-08-211-1/+1
* [svn-r21923] Description:Quincey Koziol2012-02-101-6/+6
* [svn-r20529] Purpose: Add testing for bug 1864Neil Fortner2011-04-151-0/+3
* [svn-r17980] Description:Quincey Koziol2009-12-101-14/+62
* [svn-r15868] Description:Quincey Koziol2008-10-151-203/+175
* [svn-r15825] Description:Quincey Koziol2008-10-091-30/+28
* [svn-r14413] Description:Quincey Koziol2008-01-141-1/+1
* [svn-r14362] Description:Quincey Koziol2008-01-031-2/+2
* [svn-r14225] Description:Quincey Koziol2007-10-311-6/+6
* [svn-r14218] Description:Quincey Koziol2007-10-301-4/+4
* [svn-r14199] Description:Quincey Koziol2007-10-111-18/+18
* [svn-r14193] Description:Quincey Koziol2007-10-081-1/+1
* [svn-r14187] Description:Quincey Koziol2007-10-041-4/+4
* [svn-r14160] Description:Quincey Koziol2007-09-271-1/+1
* [svn-r14156] Description:Quincey Koziol2007-09-261-4/+4
* [svn-r14144] Description:Quincey Koziol2007-09-131-17/+21
* [svn-r14131] Description:Quincey Koziol2007-08-301-6/+6
* [svn-r14127] Description:Quincey Koziol2007-08-291-8/+8
* [svn-r14126] Description:Quincey Koziol2007-08-291-445/+466
* [svn-r14123] Description:Quincey Koziol2007-08-281-13/+13
* [svn-r14122] Description:Quincey Koziol2007-08-281-14/+15
* [svn-r14121] Description:Quincey Koziol2007-08-281-4/+4
* [svn-r14120] Description:Quincey Koziol2007-08-281-127/+125
* [svn-r14117] Description:Quincey Koziol2007-08-281-11/+11
* [svn-r14115] Description:Quincey Koziol2007-08-281-17/+14
* [svn-r14104] Description:Quincey Koziol2007-08-231-44/+45
* [svn-r13636] Description:Quincey Koziol2007-04-111-2/+1
HDstrcmp(s, "42 m 1 s") != 0) TEST_ERROR; HDfree(s); /* < 1 d hrs, mins, secs */ s = H5_timer_get_time_string(9756.0); if (NULL == s || HDstrcmp(s, "2 h 42 m 36 s") != 0) TEST_ERROR; HDfree(s); /* > 1 d days, hrs, mins, secs */ s = H5_timer_get_time_string(280802.0); if (NULL == s || HDstrcmp(s, "3 d 6 h 0 m 2 s") != 0) TEST_ERROR; HDfree(s); PASSED(); return 0; error: if (s) HDfree(s); return -1; } /*------------------------------------------------------------------------- * Function: test_timer_system_user * * Purpose: Tests the ability to get system and user times from the * timers. * Some platforms may require special code to get system and * user times. If we do not support that particular platform * dependent functionality, this test is skipped. * * Return: Success: 0 * Failure: -1 * * Programmer: Dana Robinson * May 2011 * *------------------------------------------------------------------------- */ static herr_t test_timer_system_user(void) { int i; char *buf = NULL; H5_timer_t timer; H5_timevals_t times; herr_t err; TESTING("system/user times"); err = H5_timer_init(&timer); if (err < 0) TEST_ERROR; err = H5_timer_start(&timer); if (err < 0) TEST_ERROR; /* The system and user times may not be present on some systems. They * will be -1.0 if they are not. */ if (timer.initial.system < 0.0 || timer.initial.user < 0.0) { SKIPPED(); HDprintf("NOTE: No suitable way to get system/user times on this platform.\n"); return 0; } /* Do some fake work */ for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } err = H5_timer_stop(&timer); if (err < 0) TEST_ERROR; err = H5_timer_get_times(timer, &times); if (err < 0) TEST_ERROR; /* System and user times should be non-negative. */ if (times.system < 0.0 || times.user < 0.0) TEST_ERROR; PASSED(); return 0; error: return -1; } /*------------------------------------------------------------------------- * Function: test_timer_elapsed * * Purpose: Tests the ability to get elapsed times from the timers. * We should always be able to get an elapsed time, * regardless of the time libraries or platform. * * Return: Success: 0 * Failure: -1 * * Programmer: Dana Robinson * May 2011 * *------------------------------------------------------------------------- */ static herr_t test_timer_elapsed(void) { int i; char *buf = NULL; H5_timer_t timer; H5_timevals_t times; herr_t err; TESTING("elapsed times"); err = H5_timer_init(&timer); if (err < 0) TEST_ERROR; err = H5_timer_start(&timer); if (err < 0) TEST_ERROR; /* Do some fake work */ for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } err = H5_timer_stop(&timer); if (err < 0) TEST_ERROR; err = H5_timer_get_times(timer, &times); if (err < 0) TEST_ERROR; /* Elapsed time should be non-negative. */ if (times.elapsed < 0.0) TEST_ERROR; PASSED(); return 0; error: return -1; } static herr_t test_timer_functionality(void) { int i; char *buf = NULL; H5_timer_t timer; H5_timevals_t times; double prev_etime; double prev_total_etime; herr_t err; TESTING("timer functionality"); /***************** * CHECK STARTUP * *****************/ /* Timer should be running after start */ err = H5_timer_init(&timer); if (err < 0 || timer.is_running) TEST_ERROR; /* Times should be initialized to zero */ err = H5_timer_get_times(timer, &times); if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, 0.0)) TEST_ERROR; err = H5_timer_get_total_times(timer, &times); if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, 0.0)) TEST_ERROR; /******************** * CHECK START/STOP * ********************/ /* Running state should change after start */ err = H5_timer_start(&timer); if (err < 0 || !timer.is_running) TEST_ERROR; /* Do some fake work */ for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } /* Running state should change after stop */ err = H5_timer_stop(&timer); if (err < 0 || timer.is_running) TEST_ERROR; /* Times should be positive and non-negative */ err = H5_timer_get_times(timer, &times); if (err < 0 || times.elapsed < 0.0) TEST_ERROR; err = H5_timer_get_total_times(timer, &times); if (err < 0 || times.elapsed < 0.0) TEST_ERROR; /********************** * CHECK INTERRUPTING * **********************/ /* Timer should change stat and refresh to 0s */ err = H5_timer_init(&timer); if (err < 0 || timer.is_running) TEST_ERROR; err = H5_timer_get_times(timer, &times); if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, 0.0)) TEST_ERROR; err = H5_timer_get_total_times(timer, &times); if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, 0.0)) TEST_ERROR; /* Timer state should flip */ err = H5_timer_start(&timer); if (err < 0 || !timer.is_running) TEST_ERROR; /* Do some fake work */ for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } /* Times should be non-negative */ err = H5_timer_get_times(timer, &times); if (err < 0 || times.elapsed < 0.0) TEST_ERROR; prev_etime = times.elapsed; err = H5_timer_get_total_times(timer, &times); if (err < 0 || times.elapsed < 0.0) TEST_ERROR; prev_total_etime = times.elapsed; /* Do some fake work */ for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } /* State should flip on stop */ err = H5_timer_stop(&timer); if (err < 0 || timer.is_running) TEST_ERROR; /* Times should be >= than the cached intermediate times */ err = H5_timer_get_times(timer, &times); if (err < 0 || times.elapsed < prev_etime) TEST_ERROR; err = H5_timer_get_total_times(timer, &times); if (err < 0 || times.elapsed < prev_total_etime) TEST_ERROR; PASSED(); return 0; error: return -1; } /*------------------------------------------------------------------------- * Function: main * * Purpose: Tests the basic functionality of the platform-independent * timers * * Return: Success: 0 * Failure: 1 * * Programmer: Dana Robinson * May, 2011 * *------------------------------------------------------------------------- */ int main(void) { int nerrors = 0; h5_reset(); HDprintf("Testing platform-independent timer functionality.\n"); nerrors += test_time_formatting() < 0 ? 1 : 0; nerrors += test_timer_system_user() < 0 ? 1 : 0; nerrors += test_timer_elapsed() < 0 ? 1 : 0; nerrors += test_timer_functionality() < 0 ? 1 : 0; if (nerrors) { HDprintf("***** %d platform-independent timer TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); return 1; } else { HDprintf("All platform-independent timer tests passed.\n"); return 0; } }