]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add more unit tests for isc_test API
authorOndřej Surý <ondrej@isc.org>
Wed, 26 Jan 2022 10:50:12 +0000 (11:50 +0100)
committerMartin Basti <mbasti@isc.org>
Wed, 22 Jul 2026 09:17:36 +0000 (11:17 +0200)
While working on internal 64-bit time for BIND 9, the unit test suite
for isc_time API has been extended.

Backport the unit tests from 64-bit time branch to the main branch.
This should make the unit tests for isc_time API (mostly) complete.

tests/isc/time_test.c

index 5dc1834e77edb6fe4d37ef6d85d2e84fbf6b0a11..35d63a53d478008243742576077b1ebe3d936d4a 100644 (file)
 
 #include <tests/isc.h>
 
+#define MAX_S  UINT_MAX
 #define MAX_NS (NS_PER_SEC - 1)
 
+ISC_RUN_TEST_IMPL(isc_interval_basic_test) {
+       isc_interval_t i = { 0, 0 };
+
+       assert_true(isc_interval_iszero(&i));
+
+       isc_interval_set(&i, MAX_S, MAX_NS);
+       assert_int_equal(i.seconds, MAX_S);
+       assert_int_equal(i.nanoseconds, MAX_NS);
+
+       isc_interval_set(&i, 1, NS_PER_MS * 2);
+       assert_int_equal(isc_interval_ms(&i), MS_PER_SEC + 2);
+
+       expect_assert_failure(isc_interval_set(NULL, 0, 0));
+       expect_assert_failure(isc_interval_set(&i, 0, MAX_NS + 1));
+
+       expect_assert_failure(isc_interval_iszero(NULL));
+}
+
+ISC_RUN_TEST_IMPL(isc_time_basic_test) {
+       isc_time_t t = { 0, 0 };
+
+       assert_true(isc_time_isepoch(&t));
+
+       isc_time_set(&t, MAX_S, MAX_NS);
+       assert_int_equal(t.seconds, MAX_S);
+       assert_int_equal(t.nanoseconds, MAX_NS);
+
+       assert_int_equal(isc_time_seconds(&t), t.seconds);
+       assert_int_equal(isc_time_nanoseconds(&t), t.nanoseconds);
+
+       isc_time_settoepoch(&t);
+       assert_int_equal(t.seconds, 0);
+       assert_int_equal(t.nanoseconds, 0);
+       assert_true(isc_time_isepoch(&t));
+
+       expect_assert_failure(isc_time_set(NULL, 0, 0));
+       expect_assert_failure(isc_time_set(&t, 0, MAX_NS + 1));
+
+       expect_assert_failure(isc_time_settoepoch(NULL));
+       expect_assert_failure(isc_time_isepoch(NULL));
+       expect_assert_failure(isc_time_isepoch(&(isc_time_t){ 0, MAX_NS + 1 }));
+
+       expect_assert_failure(isc_time_seconds(NULL));
+       expect_assert_failure(isc_time_seconds(&(isc_time_t){ 0, MAX_NS + 1 }));
+
+       expect_assert_failure(isc_time_nanoseconds(NULL));
+       expect_assert_failure(
+               isc_time_nanoseconds(&(isc_time_t){ 0, MAX_NS + 1 }));
+}
+
+ISC_RUN_TEST_IMPL(isc_time_now_test) {
+       isc_time_t t1 = { 0, 0 };
+       isc_time_t t2 = { 0, 0 };
+       time_t tm;
+
+       tm = time(NULL);
+       t1 = isc_time_now();
+       nanosleep(&(struct timespec){ 1, 0 }, NULL);
+       t2 = isc_time_now();
+
+       assert_true(t1.seconds >= tm);
+       assert_true(t2.seconds >= tm);
+
+       assert_int_not_equal(t1.seconds, 0);
+       assert_int_not_equal(t2.seconds, 0);
+       assert_int_equal(isc_time_compare(&t2, &t1), 1);
+       assert_int_equal(t2.seconds - t1.seconds, 1);
+
+       tm = time(NULL);
+       t1 = isc_time_now_hires();
+       nanosleep(&(struct timespec){ 0, NS_PER_US }, NULL);
+       t2 = isc_time_now_hires();
+
+       assert_true(t1.seconds >= tm);
+       assert_true(t2.seconds >= tm);
+       assert_true(isc_time_microdiff(&t2, &t1) >= 1);
+       assert_true(isc_time_microdiff(&t2, &t1) < US_PER_SEC);
+}
+
 struct time_vectors {
        isc_time_t a;
        isc_interval_t b;
@@ -66,16 +146,14 @@ const struct time_vectors vectors_sub[7] = {
          { 0, MAX_NS },
          { 0, NS_PER_SEC / 2 + 1 },
          ISC_R_SUCCESS },
-       { { UINT_MAX, MAX_NS }, { UINT_MAX, 0 }, { 0, MAX_NS }, ISC_R_SUCCESS },
+       { { MAX_S, MAX_NS }, { MAX_S, 0 }, { 0, MAX_NS }, ISC_R_SUCCESS },
        { { 0, 0 }, { 1, 0 }, { 0, 0 }, ISC_R_RANGE },
        { { 0, 0 }, { 0, MAX_NS }, { 0, 0 }, ISC_R_RANGE },
 };
 
 ISC_RUN_TEST_IMPL(isc_time_add_test) {
-       UNUSED(state);
-
        for (size_t i = 0; i < ARRAY_SIZE(vectors_add); i++) {
-               isc_time_t r = { UINT_MAX, UINT_MAX };
+               isc_time_t r = { MAX_S, MAX_S };
                isc_result_t result = isc_time_add(&(vectors_add[i].a),
                                                   &(vectors_add[i].b), &r);
                assert_int_equal(result, vectors_add[i].result);
@@ -105,8 +183,6 @@ ISC_RUN_TEST_IMPL(isc_time_add_test) {
 }
 
 ISC_RUN_TEST_IMPL(isc_time_sub_test) {
-       UNUSED(state);
-
        for (size_t i = 0; i < ARRAY_SIZE(vectors_sub); i++) {
                isc_time_t r = { UINT_MAX, UINT_MAX };
                isc_result_t result = isc_time_subtract(
@@ -136,41 +212,187 @@ ISC_RUN_TEST_IMPL(isc_time_sub_test) {
                &(isc_time_t){ 0, 0 }, &(isc_interval_t){ 0, 0 }, NULL));
 }
 
-/* parse http time stamp */
+struct compare_vectors {
+       isc_time_t a;
+       isc_time_t b;
+       int64_t r;
+};
+
+const struct compare_vectors vectors_compare[] = {
+       { { 0, 0 }, { 0, 0 }, 0 },
+       { { 1, 0 }, { 0, 0 }, 1 },
+       { { 0, 0 }, { 1, 0 }, -1 },
+
+       { { 0, 1 }, { 0, 1 }, 0 },
+       { { 0, 1 }, { 0, 0 }, 1 },
+       { { 0, 0 }, { 0, 1 }, -1 },
+
+       { { 0, 0 }, { MAX_S, MAX_NS }, -1 },
+       { { MAX_S, MAX_NS }, { 0, 0 }, 1 },
+       { { MAX_S, MAX_NS }, { MAX_S, MAX_NS }, 0 },
+
+       { { 1, 0 }, { 0, MAX_NS }, 1 },
+       { { 0, MAX_NS }, { 1, 0 }, -1 }
+};
+
+ISC_RUN_TEST_IMPL(isc_time_compare_test) {
+       for (size_t i = 0; i < ARRAY_SIZE(vectors_compare); i++) {
+               int r = isc_time_compare(&(vectors_compare[i].a),
+                                        &(vectors_compare[i].b));
+               assert_int_equal(vectors_compare[i].r, r);
+       }
+
+       /* Invalid first argument */
+       expect_assert_failure((void)isc_time_compare((isc_time_t *)NULL,
+                                                    &(isc_time_t){ 0, 0 }));
+
+       expect_assert_failure((void)isc_time_compare(
+               &(isc_time_t){ 0, MAX_NS + 1 }, &(isc_time_t){ 0, 0 }));
+
+       /* Invalid second argument */
+       expect_assert_failure((void)isc_time_compare(&(isc_time_t){ 0, 0 },
+                                                    (isc_time_t *)NULL));
+
+       expect_assert_failure((void)isc_time_compare(
+               &(isc_time_t){ 0, 0 }, &(isc_time_t){ 0, MAX_NS + 1 }));
+}
+
+#define MAX_NS_PER_US   (MAX_NS / NS_PER_US)
+#define MAX_MICRODIFF_N         (MAX_S + 0LL)
+#define MAX_MICRODIFF_US (MAX_S + 0LL) * US_PER_SEC
+
+const struct compare_vectors vectors_microdiff[] = {
+       { { 0, 0 }, { 0, 0 }, 0 },
+       { { 1, 0 }, { 0, 0 }, 1 * US_PER_SEC },
+       { { 0, 0 }, { 1, 0 }, 0 },
+
+       { { 0, 1 }, { 0, 1 }, 0 },
+       { { 0, 1 }, { 0, 0 }, 0 },
+       { { 0, 0 }, { 0, 1 }, 0 },
+
+       { { 0, NS_PER_US }, { 0, NS_PER_US }, 0 },
+       { { 0, NS_PER_US }, { 0, 0 }, 1 },
+       { { 0, 0 }, { 0, NS_PER_US }, 0 },
+
+       { { 0, 0 }, { MAX_MICRODIFF_N, MAX_NS }, 0 },
+       { { MAX_MICRODIFF_N, MAX_NS },
+         { 0, 0 },
+         MAX_MICRODIFF_US + MAX_NS_PER_US },
+       { { MAX_MICRODIFF_N, MAX_NS }, { MAX_MICRODIFF_N, MAX_NS }, 0 },
+
+       { { 1, 0 }, { 0, MAX_NS }, 0 },
+       { { 0, MAX_NS }, { 1, 0 }, 0 }
+};
+
+ISC_RUN_TEST_IMPL(isc_time_microdiff_test) {
+       for (size_t i = 0; i < ARRAY_SIZE(vectors_microdiff); i++) {
+               int64_t r = isc_time_microdiff(&(vectors_microdiff[i].a),
+                                              &(vectors_microdiff[i].b));
+               assert_int_equal(vectors_microdiff[i].r, r);
+       }
+
+       /* Invalid first argument */
+       expect_assert_failure((void)isc_time_microdiff((isc_time_t *)NULL,
+                                                      &(isc_time_t){ 0, 0 }));
+
+       expect_assert_failure((void)isc_time_microdiff(
+               &(isc_time_t){ 0, MAX_NS + 1 }, &(isc_time_t){ 0, 0 }));
+
+       /* Invalid second argument */
+       expect_assert_failure((void)isc_time_microdiff(&(isc_time_t){ 0, 0 },
+                                                      (isc_time_t *)NULL));
 
+       expect_assert_failure((void)isc_time_microdiff(
+               &(isc_time_t){ 0, 0 }, &(isc_time_t){ 0, MAX_NS + 1 }));
+}
+
+ISC_RUN_TEST_IMPL(isc_time_formattimestamp_test) {
+       isc_time_t t = { 0, 0 };
+       char buf[ISC_FORMATTIMESTAMP_SIZE];
+
+       /*
+        * The second least population is at UTC+08:45 that covers village of
+        * Eucla and other villages in Australia with a population of around
+        * 200. The area is surrounded by signs to remind you to turn your
+        * clocks, but it is unofficial so it might not comply either.
+        */
+       setenv("TZ", "Australia/Eucla", 1);
+       t = isc_time_now();
+
+       memset(buf, 'X', sizeof(buf));
+       isc_time_formattimestamp(&t, buf, sizeof(buf));
+       assert_int_equal(strlen(buf), sizeof(buf) - 1);
+
+       memset(buf, 'X', sizeof(buf));
+       isc_time_settoepoch(&t);
+       isc_time_formattimestamp(&t, buf, sizeof(buf));
+       assert_string_equal(buf, "01-Jan-1970 08:45:00.000");
+
+       memset(buf, 'X', sizeof(buf));
+       isc_time_set(&t, 1450000000, 123000000);
+       isc_time_formattimestamp(&t, buf, sizeof(buf));
+       assert_string_equal(buf, "13-Dec-2015 18:31:40.123");
+
+       expect_assert_failure(isc_time_formattimestamp(NULL, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formattimestamp(
+               &(isc_time_t){ 0, MAX_NS + 1 }, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formattimestamp(&t, NULL, 0));
+       expect_assert_failure(
+               isc_time_formattimestamp(&t, buf, sizeof(buf) - 1));
+}
+
+/* parse http time stamp */
 ISC_RUN_TEST_IMPL(isc_time_parsehttptimestamp_test) {
-       isc_result_t result;
        isc_time_t t, x;
        char buf[ISC_FORMATHTTPTIMESTAMP_SIZE];
 
-       UNUSED(state);
-
-       setenv("TZ", "America/Los_Angeles", 1);
+       setenv("TZ", "Australia/Eucla", 1);
        tzset();
        t = isc_time_now();
 
        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_parsehttptimestamp(buf, &x), ISC_R_SUCCESS);
+       assert_int_equal(isc_time_seconds(&t), isc_time_seconds(&x));
+
+       memset(buf, 'X', sizeof(buf));
+       isc_time_settoepoch(&t);
+       isc_time_formathttptimestamp(&t, buf, sizeof(buf));
+       assert_string_equal(buf, "Thu, 01 Jan 1970 00:00:00 GMT");
+       assert_int_equal(isc_time_parsehttptimestamp(buf, &x), ISC_R_SUCCESS);
+       assert_int_equal(isc_time_seconds(&t), isc_time_seconds(&x));
+
+       memset(buf, 'X', sizeof(buf));
+       isc_time_set(&t, 1450000000, 123000000);
+       isc_time_formathttptimestamp(&t, buf, sizeof(buf));
+       assert_string_equal(buf, "Sun, 13 Dec 2015 09:46:40 GMT");
+       assert_int_equal(isc_time_parsehttptimestamp(buf, &x), ISC_R_SUCCESS);
        assert_int_equal(isc_time_seconds(&t), isc_time_seconds(&x));
+
+       expect_assert_failure(
+               isc_time_formathttptimestamp(NULL, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formathttptimestamp(
+               &(isc_time_t){ 0, MAX_NS + 1 }, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formathttptimestamp(&t, NULL, 0));
+       expect_assert_failure(
+               isc_time_formathttptimestamp(&t, buf, sizeof(buf) - 1));
+
+       expect_assert_failure(isc_time_parsehttptimestamp(buf, NULL));
+       expect_assert_failure(isc_time_parsehttptimestamp(NULL, &t));
 }
 
 /* print UTC in ISO8601 */
-
 ISC_RUN_TEST_IMPL(isc_time_formatISO8601_test) {
-       isc_time_t t;
-       char buf[64];
-
-       UNUSED(state);
+       isc_time_t t = { 0, 0 };
+       char buf[ISC_FORMATISO8601_SIZE];
 
-       setenv("TZ", "America/Los_Angeles", 1);
+       setenv("TZ", "Australia/Eucla", 1);
        tzset();
        t = isc_time_now();
 
        /* check formatting: yyyy-mm-ddThh:mm:ssZ */
        memset(buf, 'X', sizeof(buf));
        isc_time_formatISO8601(&t, buf, sizeof(buf));
-       assert_int_equal(strlen(buf), 20);
+       assert_int_equal(strlen(buf), sizeof(buf) - 1);
        assert_int_equal(buf[4], '-');
        assert_int_equal(buf[7], '-');
        assert_int_equal(buf[10], 'T');
@@ -188,24 +410,27 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601_test) {
        isc_time_set(&t, 1450000000, 123000000);
        isc_time_formatISO8601(&t, buf, sizeof(buf));
        assert_string_equal(buf, "2015-12-13T09:46:40Z");
+
+       expect_assert_failure(isc_time_formatISO8601(NULL, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601(
+               &(isc_time_t){ 0, MAX_NS + 1 }, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601(&t, NULL, 0));
+       expect_assert_failure(isc_time_formatISO8601(&t, buf, sizeof(buf) - 1));
 }
 
 /* print UTC in ISO8601 with milliseconds */
-
 ISC_RUN_TEST_IMPL(isc_time_formatISO8601ms_test) {
-       isc_time_t t;
-       char buf[64];
-
-       UNUSED(state);
+       isc_time_t t = { 0, 0 };
+       char buf[ISC_FORMATISO8601MS_SIZE];
 
-       setenv("TZ", "America/Los_Angeles", 1);
+       setenv("TZ", "Australia/Eucla", 1);
        tzset();
        t = isc_time_now();
 
        /* check formatting: yyyy-mm-ddThh:mm:ss.sssZ */
        memset(buf, 'X', sizeof(buf));
        isc_time_formatISO8601ms(&t, buf, sizeof(buf));
-       assert_int_equal(strlen(buf), 24);
+       assert_int_equal(strlen(buf), sizeof(buf) - 1);
        assert_int_equal(buf[4], '-');
        assert_int_equal(buf[7], '-');
        assert_int_equal(buf[10], 'T');
@@ -224,24 +449,28 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601ms_test) {
        isc_time_set(&t, 1450000000, 123000000);
        isc_time_formatISO8601ms(&t, buf, sizeof(buf));
        assert_string_equal(buf, "2015-12-13T09:46:40.123Z");
+
+       expect_assert_failure(isc_time_formatISO8601ms(NULL, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601ms(
+               &(isc_time_t){ 0, MAX_NS + 1 }, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601ms(&t, NULL, 0));
+       expect_assert_failure(
+               isc_time_formatISO8601ms(&t, buf, sizeof(buf) - 1));
 }
 
 /* print UTC in ISO8601 with microseconds */
-
 ISC_RUN_TEST_IMPL(isc_time_formatISO8601us_test) {
-       isc_time_t t;
-       char buf[64];
-
-       UNUSED(state);
+       isc_time_t t = { 0, 0 };
+       char buf[ISC_FORMATISO8601US_SIZE];
 
-       setenv("TZ", "America/Los_Angeles", 1);
+       setenv("TZ", "Australia/Eucla", 1);
        tzset();
        t = isc_time_now_hires();
 
        /* check formatting: yyyy-mm-ddThh:mm:ss.ssssssZ */
        memset(buf, 'X', sizeof(buf));
        isc_time_formatISO8601us(&t, buf, sizeof(buf));
-       assert_int_equal(strlen(buf), 27);
+       assert_int_equal(strlen(buf), sizeof(buf) - 1);
        assert_int_equal(buf[4], '-');
        assert_int_equal(buf[7], '-');
        assert_int_equal(buf[10], 'T');
@@ -260,25 +489,28 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601us_test) {
        isc_time_set(&t, 1450000000, 123456000);
        isc_time_formatISO8601us(&t, buf, sizeof(buf));
        assert_string_equal(buf, "2015-12-13T09:46:40.123456Z");
+
+       expect_assert_failure(isc_time_formatISO8601us(NULL, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601us(
+               &(isc_time_t){ 0, MAX_NS + 1 }, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601us(&t, NULL, 0));
+       expect_assert_failure(
+               isc_time_formatISO8601us(&t, buf, sizeof(buf) - 1));
 }
 
 /* print local time in ISO8601 with milliseconds and timezone */
-
 ISC_RUN_TEST_IMPL(isc_time_formatISO8601TZms_test) {
-       isc_time_t t;
-       char buf[64];
-
-       UNUSED(state);
+       isc_time_t t = { 0, 0 };
+       char buf[ISC_FORMATISO8601TZMS_SIZE];
 
-       setenv("TZ", "America/Los_Angeles", 1);
+       setenv("TZ", "Australia/Eucla", 1);
        tzset();
        t = isc_time_now();
 
-       /* check formatting: yyyy-mm-ddThh:mm:ss.sss */
+       /* check formatting: yyyy-mm-ddThh:mm:ss.sss+hh:mm */
        memset(buf, 'X', sizeof(buf));
-       buf[63] = '\0';
        isc_time_formatISO8601TZms(&t, buf, sizeof(buf));
-       assert_int_equal(strlen(buf), strlen("yyyy-mm-ddThh:mm:ss.sss+hh:mm"));
+       assert_int_equal(strlen(buf), sizeof(buf) - 1);
 
        assert_int_equal(buf[4], '-');
        assert_int_equal(buf[7], '-');
@@ -290,33 +522,38 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601TZms_test) {
        assert_true((buf[23] == '+') || (buf[23] == '-'));
        assert_int_equal(buf[26], ':');
 
-       /* check time conversion correctness */
        memset(buf, 'X', sizeof(buf));
        isc_time_settoepoch(&t);
-       isc_time_formatISO8601Lms(&t, buf, sizeof(buf));
-       assert_string_equal(buf, "1969-12-31T16:00:00.000");
+       isc_time_formatISO8601TZms(&t, buf, sizeof(buf));
+       assert_string_equal(buf, "1970-01-01T08:45:00.000+08:45");
 
        memset(buf, 'X', sizeof(buf));
        isc_time_set(&t, 1450000000, 123000000);
-       isc_time_formatISO8601Lms(&t, buf, sizeof(buf));
-       assert_string_equal(buf, "2015-12-13T01:46:40.123");
+       isc_time_formatISO8601TZms(&t, buf, sizeof(buf));
+       assert_string_equal(buf, "2015-12-13T18:31:40.123+08:45");
+
+       expect_assert_failure(
+               isc_time_formatISO8601TZms(NULL, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601TZms(
+               &(isc_time_t){ 0, MAX_NS + 1 }, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601TZms(&t, NULL, 0));
+       expect_assert_failure(
+               isc_time_formatISO8601TZms(&t, buf, sizeof(buf) - 1));
 }
-/* print local time in ISO8601 with milliseconds */
 
+/* print local time in ISO8601 with milliseconds */
 ISC_RUN_TEST_IMPL(isc_time_formatISO8601Lms_test) {
-       isc_time_t t;
-       char buf[64];
-
-       UNUSED(state);
+       isc_time_t t = { 0, 0 };
+       char buf[ISC_FORMATISO8601LMS_SIZE];
 
-       setenv("TZ", "America/Los_Angeles", 1);
+       setenv("TZ", "Australia/Eucla", 1);
        tzset();
        t = isc_time_now();
 
        /* check formatting: yyyy-mm-ddThh:mm:ss.sss */
        memset(buf, 'X', sizeof(buf));
        isc_time_formatISO8601Lms(&t, buf, sizeof(buf));
-       assert_int_equal(strlen(buf), 23);
+       assert_int_equal(strlen(buf), sizeof(buf) - 1);
        assert_int_equal(buf[4], '-');
        assert_int_equal(buf[7], '-');
        assert_int_equal(buf[10], 'T');
@@ -328,30 +565,35 @@ ISC_RUN_TEST_IMPL(isc_time_formatISO8601Lms_test) {
        memset(buf, 'X', sizeof(buf));
        isc_time_settoepoch(&t);
        isc_time_formatISO8601Lms(&t, buf, sizeof(buf));
-       assert_string_equal(buf, "1969-12-31T16:00:00.000");
+       assert_string_equal(buf, "1970-01-01T08:45:00.000");
 
        memset(buf, 'X', sizeof(buf));
        isc_time_set(&t, 1450000000, 123000000);
        isc_time_formatISO8601Lms(&t, buf, sizeof(buf));
-       assert_string_equal(buf, "2015-12-13T01:46:40.123");
+       assert_string_equal(buf, "2015-12-13T18:31:40.123");
+
+       expect_assert_failure(
+               isc_time_formatISO8601Lms(NULL, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601Lms(
+               &(isc_time_t){ 0, MAX_NS + 1 }, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatISO8601Lms(&t, NULL, 0));
+       expect_assert_failure(
+               isc_time_formatISO8601Lms(&t, buf, sizeof(buf) - 1));
 }
 
 /* print UTC time as yyyymmddhhmmsssss */
-
 ISC_RUN_TEST_IMPL(isc_time_formatshorttimestamp_test) {
-       isc_time_t t;
-       char buf[64];
-
-       UNUSED(state);
+       isc_time_t t = { 0, 0 };
+       char buf[ISC_FORMATSHORTTIMESTAMP_SIZE];
 
-       setenv("TZ", "America/Los_Angeles", 1);
+       setenv("TZ", "Australia/Eucla", 1);
        tzset();
        t = isc_time_now();
 
        /* check formatting: yyyymmddhhmmsssss */
        memset(buf, 'X', sizeof(buf));
        isc_time_formatshorttimestamp(&t, buf, sizeof(buf));
-       assert_int_equal(strlen(buf), 17);
+       assert_int_equal(strlen(buf), sizeof(buf) - 1);
 
        /* check time conversion correctness */
        memset(buf, 'X', sizeof(buf));
@@ -363,10 +605,21 @@ ISC_RUN_TEST_IMPL(isc_time_formatshorttimestamp_test) {
        isc_time_set(&t, 1450000000, 123000000);
        isc_time_formatshorttimestamp(&t, buf, sizeof(buf));
        assert_string_equal(buf, "20151213094640123");
+
+       expect_assert_failure(
+               isc_time_formatshorttimestamp(NULL, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatshorttimestamp(
+               &(isc_time_t){ 0, MAX_NS + 1 }, buf, sizeof(buf)));
+       expect_assert_failure(isc_time_formatshorttimestamp(&t, NULL, 0));
+       expect_assert_failure(
+               isc_time_formatshorttimestamp(&t, buf, sizeof(buf) - 1));
 }
 
 ISC_TEST_LIST_START
 
+ISC_TEST_ENTRY(isc_interval_basic_test)
+ISC_TEST_ENTRY(isc_time_basic_test)
+ISC_TEST_ENTRY(isc_time_now_test)
 ISC_TEST_ENTRY(isc_time_add_test)
 ISC_TEST_ENTRY(isc_time_sub_test)
 ISC_TEST_ENTRY(isc_time_parsehttptimestamp_test)
@@ -376,6 +629,9 @@ ISC_TEST_ENTRY(isc_time_formatISO8601us_test)
 ISC_TEST_ENTRY(isc_time_formatISO8601Lms_test)
 ISC_TEST_ENTRY(isc_time_formatISO8601TZms_test)
 ISC_TEST_ENTRY(isc_time_formatshorttimestamp_test)
+ISC_TEST_ENTRY(isc_time_formattimestamp_test)
+ISC_TEST_ENTRY(isc_time_microdiff_test)
+ISC_TEST_ENTRY(isc_time_compare_test)
 
 ISC_TEST_LIST_END