summaryrefslogtreecommitdiff
path: root/t/helper/test-date.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2019-02-06 22:05:26 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-02-06 22:05:26 -0800
commit57cbc53d3e0567d630b3e08be41e555efb06f616 (patch)
tree97fbb06114350cebe37f5f68e41206e53e43c7f8 /t/helper/test-date.c
parentMerge branch 'br/commit-tree-fully-spelled-gpg-sign-option' (diff)
parenttest-date: drop unused parameter to getnanos() (diff)
downloadtgif-57cbc53d3e0567d630b3e08be41e555efb06f616.tar.xz
Merge branch 'js/vsts-ci'
Prepare to run test suite on Azure Pipeline. * js/vsts-ci: (22 commits) test-date: drop unused parameter to getnanos() ci: parallelize testing on Windows ci: speed up Windows phase tests: optionally skip bin-wrappers/ t0061: workaround issues with --with-dashes and RUNTIME_PREFIX tests: add t/helper/ to the PATH with --with-dashes mingw: try to work around issues with the test cleanup tests: include detailed trace logs with --write-junit-xml upon failure tests: avoid calling Perl just to determine file sizes README: add a build badge (status of the Azure Pipelines build) mingw: be more generous when wrapping up the setitimer() emulation ci: use git-sdk-64-minimal build artifact ci: add a Windows job to the Azure Pipelines definition Add a build definition for Azure DevOps ci/lib.sh: add support for Azure Pipelines tests: optionally write results as JUnit-style .xml test-date: add a subcommand to measure times in shell scripts ci: use a junction on Windows instead of a symlink ci: inherit --jobs via MAKEFLAGS in run-build-and-tests ci/lib.sh: encapsulate Travis-specific things ...
Diffstat (limited to 't/helper/test-date.c')
-rw-r--r--t/helper/test-date.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index a47bfa3003..b3253803ac 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -8,6 +8,7 @@ static const char *usage_msg = "\n"
" test-tool date parse [date]...\n"
" test-tool date approxidate [date]...\n"
" test-tool date timestamp [date]...\n"
+" test-tool date getnanos [start-nanos]\n"
" test-tool date is64bit\n"
" test-tool date time_t-is64bit\n";
@@ -91,6 +92,15 @@ static void parse_approx_timestamp(const char **argv, struct timeval *now)
}
}
+static void getnanos(const char **argv)
+{
+ double seconds = getnanotime() / 1.0e9;
+
+ if (*argv)
+ seconds -= strtod(*argv, NULL);
+ printf("%lf\n", seconds);
+}
+
int cmd__date(int argc, const char **argv)
{
struct timeval now;
@@ -119,6 +129,8 @@ int cmd__date(int argc, const char **argv)
parse_approxidate(argv+1, &now);
else if (!strcmp(*argv, "timestamp"))
parse_approx_timestamp(argv+1, &now);
+ else if (!strcmp(*argv, "getnanos"))
+ getnanos(argv+1);
else if (!strcmp(*argv, "is64bit"))
return sizeof(timestamp_t) == 8 ? 0 : 1;
else if (!strcmp(*argv, "time_t-is64bit"))