From 7c752fa8a0291c38972f1ec5163c8a9c56b52916 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Tue, 25 Aug 2020 16:06:05 +0200 Subject: [PATCH] print elapsed time after successful run --- coverage.sh | 9 ++++++--- mmdebstrap | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/coverage.sh b/coverage.sh index 9783e44..0a43795 100755 --- a/coverage.sh +++ b/coverage.sh @@ -2356,9 +2356,11 @@ cat << END > shared/test.sh #!/bin/sh set -eu export LC_ALL=C.UTF-8 -$CMD --mode=root --variant=apt --logfile=log $DEFAULT_DIST /tmp/debian-chroot $mirror # we check the full log to also prevent debug printfs to accidentally make it into a commit -cat << LOG | diff -u - log +$CMD --mode=root --variant=apt --logfile=log $DEFAULT_DIST /tmp/debian-chroot $mirror +# omit the last line which should contain the runtime +head --lines=-1 log > trimmed +cat << LOG | diff -u - trimmed I: chroot architecture $HOSTARCH is equal to the host's architecture I: automatically chosen format: directory I: running apt-get update... @@ -2367,9 +2369,10 @@ I: extracting archives... I: installing packages... I: cleaning package lists and apt cache... LOG +tail --lines=1 log | grep '^I: success in .* seconds$' tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort | diff -u tar1.txt - rm -r /tmp/debian-chroot -rm log +rm log trimmed END if [ "$HAVE_QEMU" = "yes" ]; then ./run_qemu.sh diff --git a/mmdebstrap b/mmdebstrap index 42e0277..c75c8ff 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -41,6 +41,7 @@ use POSIX qw(SIGINT SIGHUP SIGPIPE SIGTERM SIG_BLOCK SIG_UNBLOCK strftime); use Carp; use Term::ANSIColor; use Socket; +use Time::HiRes; use version; ## no critic (InputOutput::RequireBriefOpen) @@ -3699,6 +3700,8 @@ sub approx_disk_usage { } sub main() { + my $before = Time::HiRes::time; + umask 022; if (scalar @ARGV >= 7 && $ARGV[0] eq "--hook-helper") { @@ -5249,6 +5252,11 @@ sub main() { $exitstatus = 1; } + if ($exitstatus == 0) { + my $duration = Time::HiRes::time - $before; + info "success in " . (sprintf "%.04f", $duration) . " seconds"; + } + exit $exitstatus; }