From: Peter Xu <peterx@redhat.com>
To: Andrew Jones <drjones@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [Qemu-devel] [kvm-unit-tests PATCH v3 1/2] run_tests: put logs into per-test file
Date: Mon, 9 Jan 2017 11:13:33 +0800 [thread overview]
Message-ID: <20170109031333.GF4135@pxdev.xzpeter.org> (raw)
In-Reply-To: <20170106135158.ml3t7nxgpoi4zedp@kamzik.brq.redhat.com>
On Fri, Jan 06, 2017 at 02:51:58PM +0100, Andrew Jones wrote:
> On Fri, Jan 06, 2017 at 11:33:00AM +0800, Peter Xu wrote:
> > We were using test.log before to keep all the test logs. This patch
> > creates one log file per test case under logs/ directory with name
> > "TESTNAME.log".
> >
> > A new file global.bash is added to store global informations.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > Makefile | 4 ++--
> > run_tests.sh | 14 ++++++++------
> > scripts/functions.bash | 11 +++++++++--
> > scripts/global.bash | 2 ++
> > 4 files changed, 21 insertions(+), 10 deletions(-)
> > create mode 100644 scripts/global.bash
> >
> > diff --git a/Makefile b/Makefile
> > index a32333b..f632c6c 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -94,9 +94,9 @@ libfdt_clean:
> > $(LIBFDT_objdir)/.*.d
> >
> > distclean: clean libfdt_clean
> > - $(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.* \
> > + $(RM) lib/asm config.mak $(TEST_DIR)-run msr.out cscope.* \
> > build-head
> > - $(RM) -r tests
> > + $(RM) -r tests logs
>
> We need .gitignore changes for this.
Yep.
>
> >
> > cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/asm-generic
> > cscope:
> > diff --git a/run_tests.sh b/run_tests.sh
> > index 254129d..e1bb3a6 100755
> > --- a/run_tests.sh
> > +++ b/run_tests.sh
> > @@ -7,6 +7,7 @@ if [ ! -f config.mak ]; then
> > exit 1
> > fi
> > source config.mak
> > +source scripts/global.bash
> > source scripts/functions.bash
>
> Rather than add a new file, can't we just rename functions.bash to
> something less function specific (common.bash?) and then add the
> globals to that?
Sure, common.bash is a good one, will use that.
>
> >
> > function usage()
> > @@ -46,17 +47,18 @@ while getopts "g:hv" opt; do
> > esac
> > done
> >
> > -RUNTIME_log_stderr () { cat >> test.log; }
> > +# RUNTIME_log_file will be configured later
> > +RUNTIME_log_stderr () { cat >> $RUNTIME_log_file; }
> > RUNTIME_log_stdout () {
> > if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
> > - ./scripts/pretty_print_stacks.py $1 >> test.log
> > + ./scripts/pretty_print_stacks.py $1 >> $RUNTIME_log_file
> > else
> > - cat >> test.log
> > + cat >> $RUNTIME_log_file
> > fi
> > }
> >
> > -
> > config=$TEST_DIR/unittests.cfg
> > -rm -f test.log
> > -printf "BUILD_HEAD=$(cat build-head)\n\n" > test.log
> > +rm -rf $ut_log_dir
>
> Instead of the 'rm', let's do
> 'mv $ut_log_dir $ut_log_dir.old || { echo [...]; exit 2; }'
> as I never liked that test.log was silently overwritten.
"Move" is indeed a much better way than "remove", especially "rm -rf"
(I think I should avoid using "rm -rf" in the future scripts as
well...). Will fix it.
>
> > +mkdir $ut_log_dir
> > +printf "BUILD_HEAD=$(cat build-head)\n\n" > $ut_log_summary
>
> I'm not sure we need the ut_ prefix on these variables. If we
> do think we need to start prefixing variables, then I'd prefer
> not to abbreviate, i.e. 'unittest_'
Since I would prefer a prefix, I'll use "unittest_" then.
[...]
> > diff --git a/scripts/global.bash b/scripts/global.bash
> > new file mode 100644
> > index 0000000..77b0b29
> > --- /dev/null
> > +++ b/scripts/global.bash
> > @@ -0,0 +1,2 @@
> > +: ${ut_log_dir:=logs}
> > +: ${ut_log_summary:=${ut_log_dir}/SUMMARY}
>
> Do we even need these variables? When/why would someone override these
> defaults?
I use variables when I write constant more than once. This suites the
case for log_dir. I can remove the latter log_summary, but I'll still
prefer keep the log_dir if you don't mind.
Thanks!
-- peterx
next prev parent reply other threads:[~2017-01-09 3:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-06 3:32 [kvm-unit-tests PATCH v3 0/2] run_tests: support concurrent test execution Peter Xu
2017-01-06 3:32 ` [Qemu-devel] " Peter Xu
2017-01-06 3:33 ` [kvm-unit-tests PATCH v3 1/2] run_tests: put logs into per-test file Peter Xu
2017-01-06 3:33 ` [Qemu-devel] " Peter Xu
2017-01-06 13:51 ` Andrew Jones
2017-01-09 3:13 ` Peter Xu [this message]
2017-01-06 3:33 ` [kvm-unit-tests PATCH v3 2/2] run_tests: allow run tests in parallel Peter Xu
2017-01-06 3:33 ` [Qemu-devel] " Peter Xu
2017-01-06 14:40 ` Andrew Jones
2017-01-06 14:40 ` [Qemu-devel] " Andrew Jones
2017-01-09 3:47 ` Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170109031333.GF4135@pxdev.xzpeter.org \
--to=peterx@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.