1 /* $NetBSD: time_test.c,v 1.1.1.4 2015/07/08 15:38:05 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC") 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #include <config.h> 20 #include <stdlib.h> 21 22 #include <atf-c.h> 23 24 #include <isc/time.h> 25 #include <isc/result.h> 26 27 ATF_TC(isc_time_parsehttptimestamp); 28 ATF_TC_HEAD(isc_time_parsehttptimestamp, tc) { 29 atf_tc_set_md_var(tc, "descr", "parse http time stamp"); 30 } 31 ATF_TC_BODY(isc_time_parsehttptimestamp, tc) { 32 isc_result_t result; 33 isc_time_t t, x; 34 char buf[ISC_FORMATHTTPTIMESTAMP_SIZE]; 35 36 setenv("TZ", "PST8PDT", 1); 37 result = isc_time_now(&t); 38 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); 39 40 isc_time_formathttptimestamp(&t, buf, sizeof(buf)); 41 result = isc_time_parsehttptimestamp(buf, &x); 42 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); 43 ATF_REQUIRE_EQ(isc_time_seconds(&t), isc_time_seconds(&x)); 44 } 45 46 /* 47 * Main 48 */ 49 ATF_TP_ADD_TCS(tp) { 50 ATF_TP_ADD_TC(tp, isc_time_parsehttptimestamp); 51 return (atf_no_error()); 52 } 53 54