/* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * See the COPYRIGHT file distributed with this work for additional * information regarding copyright ownership. */ #include #if HAVE_CMOCKA #include #include #include #include #include #include #define UNIT_TESTING #include #include #include #include #include /* parse http time stamp */ static void isc_time_parsehttptimestamp_test(void **state) { isc_result_t result; isc_time_t t, x; char buf[ISC_FORMATHTTPTIMESTAMP_SIZE]; UNUSED(state); setenv("TZ", "PST8PDT", 1); result = isc_time_now(&t); assert_int_equal(result, ISC_R_SUCCESS); isc_time_formathttptimestamp(&t, buf, sizeof(buf)); result = isc_time_parsehttptimestamp(buf, &x); assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(isc_time_seconds(&t), isc_time_seconds(&x)); } int main(void) { const struct CMUnitTest tests[] = { cmocka_unit_test(isc_time_parsehttptimestamp_test), }; return (cmocka_run_group_tests(tests, NULL, NULL)); } #else /* HAVE_CMOCKA */ #include int main(void) { printf("1..0 # Skipped: cmocka not available\n"); return (0); } #endif