X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=tests%2Futils%2Ftap%2Ftap.c;h=687ea22f28a9adf7f787dc473b5313d1da129cf3;hb=83dc3923fa4b0fc2e0ad091392aea64cac046498;hp=1ef417fed34a70b4897918815c2c783db4840fd5;hpb=2a69bf1437eb7e81979a1410b1a66a960b52caeb;p=lttng-tools.git diff --git a/tests/utils/tap/tap.c b/tests/utils/tap/tap.c index 1ef417fed..687ea22f2 100644 --- a/tests/utils/tap/tap.c +++ b/tests/utils/tap/tap.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -183,11 +184,22 @@ void _tap_init(void) with Test::Harness */ setbuf(stdout, 0); - char *autotime_env = getenv("TAP_AUTOTIME"); - if (autotime_env != NULL) { - time_tests = atoi(autotime_env); - if (time_tests != 0) { - time_tests = 1; + /* + * Check if the LTTNG_TESTS_TAP_AUTOTIME environment variable + * is set and contains at least one byte. + */ + const char *autotime_env = getenv("LTTNG_TESTS_TAP_AUTOTIME"); + if (autotime_env != NULL && strnlen(autotime_env, 1)) { + int tap_autotime; + + /* + * Check if LTTNG_TESTS_TAP_AUTOTIME is '0', also check + * errno because strtol() can return '0' on error. + */ + errno = 0; + tap_autotime = strtol(autotime_env, NULL, 10); + if (tap_autotime == 0 && errno == 0) { + time_tests = 0; } }