Re: [libvirt] [PATCH 5/5] tests: uniformly report test failures

2013-02-25 Thread Michal Privoznik
On 23.02.2013 00:09, Eric Blake wrote:
 testutils.c likes to print summaries after a test completes,
 including if it failed.  But if the test outright exit()s,
 this summary is skipped.  Enforce that we return instead of exit.
 
 * cfg.mk (sc_prohibit_exit_tests): New syntax check.
 * tests/commandhelper.c (main): Fix offenders.
 * tests/qemumonitorjsontest.c (mymain): Likewise.
 * tests/seclabeltest.c (main): Likewise.
 * tests/securityselinuxlabeltest.c (mymain): Likewise.
 * tests/securityselinuxtest.c (mymain): Likewise.
 * tests/testutils.h (VIRT_TEST_MAIN_PRELOAD): Likewise.
 * tests/testutils.c (virtTestMain): Likewise.
 (virtTestCaptureProgramOutput): Use symbolic name.
 ---
  cfg.mk   | 7 +++
  tests/commandhelper.c| 7 +++
  tests/qemumonitorjsontest.c  | 8 +++-
  tests/seclabeltest.c | 8 
  tests/securityselinuxlabeltest.c | 6 +++---
  tests/securityselinuxtest.c  | 6 +++---
  tests/testutils.c| 8 
  tests/testutils.h| 4 ++--
  8 files changed, 29 insertions(+), 25 deletions(-)

ACK

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 5/5] tests: uniformly report test failures

2013-02-25 Thread Eric Blake
On 02/25/2013 03:38 AM, Michal Privoznik wrote:
 On 23.02.2013 00:09, Eric Blake wrote:
 testutils.c likes to print summaries after a test completes,
 including if it failed.  But if the test outright exit()s,
 this summary is skipped.  Enforce that we return instead of exit.

 
 ACK

Thanks for the reviews.  Series pushed now, as this improves the
testsuite for 1.0.3.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 5/5] tests: uniformly report test failures

2013-02-22 Thread Eric Blake
testutils.c likes to print summaries after a test completes,
including if it failed.  But if the test outright exit()s,
this summary is skipped.  Enforce that we return instead of exit.

* cfg.mk (sc_prohibit_exit_tests): New syntax check.
* tests/commandhelper.c (main): Fix offenders.
* tests/qemumonitorjsontest.c (mymain): Likewise.
* tests/seclabeltest.c (main): Likewise.
* tests/securityselinuxlabeltest.c (mymain): Likewise.
* tests/securityselinuxtest.c (mymain): Likewise.
* tests/testutils.h (VIRT_TEST_MAIN_PRELOAD): Likewise.
* tests/testutils.c (virtTestMain): Likewise.
(virtTestCaptureProgramOutput): Use symbolic name.
---
 cfg.mk   | 7 +++
 tests/commandhelper.c| 7 +++
 tests/qemumonitorjsontest.c  | 8 +++-
 tests/seclabeltest.c | 8 
 tests/securityselinuxlabeltest.c | 6 +++---
 tests/securityselinuxtest.c  | 6 +++---
 tests/testutils.c| 8 
 tests/testutils.h| 4 ++--
 8 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index d56f7e3..b95a90b 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -709,6 +709,13 @@ sc_prohibit_semicolon_at_eol_in_python:
halt=Don't use semicolon at eol in python files   \
  $(_sc_search_regexp)

+# mymain() in test files should use return, not exit, for nicer output
+sc_prohibit_exit_in_tests:
+   @prohibit='\exit *\('  \
+   in_vc_files='^tests/'   \
+   halt='use return, not exit(), in tests' \
+ $(_sc_search_regexp)
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null

diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index 39f3c53..92f031f 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -1,7 +1,7 @@
 /*
  * commandhelper.c: Auxiliary program for commandtest
  *
- * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2010-2013 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -71,9 +71,8 @@ int main(int argc, char **argv) {
 origenv++;
 }

-if (VIR_ALLOC_N(newenv, n)  0) {
-exit(EXIT_FAILURE);
-}
+if (VIR_ALLOC_N(newenv, n)  0)
+return EXIT_FAILURE;

 origenv = environ;
 n = i = 0;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index e2f8cb1..fa5ef7c 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -448,11 +448,9 @@ mymain(void)
 return EXIT_AM_SKIP;
 #endif

-if (virThreadInitialize()  0)
-exit(EXIT_FAILURE);
-
-if (!(caps = testQemuCapsInit()))
-exit(EXIT_FAILURE);
+if (virThreadInitialize()  0 ||
+!(caps = testQemuCapsInit()))
+return EXIT_FAILURE;

 virEventRegisterDefaultImpl();

diff --git a/tests/seclabeltest.c b/tests/seclabeltest.c
index 93b4902..cd34b6b 100644
--- a/tests/seclabeltest.c
+++ b/tests/seclabeltest.c
@@ -15,12 +15,12 @@ main(int argc ATTRIBUTE_UNUSED, char **argv 
ATTRIBUTE_UNUSED)
 const char *doi, *model;

 if (virThreadInitialize()  0)
-exit(EXIT_FAILURE);
+return EXIT_FAILURE;

 mgr = virSecurityManagerNew(NULL, QEMU, false, true, false);
 if (mgr == NULL) {
 fprintf(stderr, Failed to start security driver);
-exit(EXIT_FAILURE);
+return EXIT_FAILURE;
 }

 model = virSecurityManagerGetModel(mgr);
@@ -28,7 +28,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
 {
 fprintf(stderr, Failed to copy secModel model: %s,
 strerror(errno));
-exit(EXIT_FAILURE);
+return EXIT_FAILURE;
 }

 doi = virSecurityManagerGetDOI(mgr);
@@ -36,7 +36,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
 {
 fprintf(stderr, Failed to copy secModel DOI: %s,
 strerror(errno));
-exit(EXIT_FAILURE);
+return EXIT_FAILURE;
 }

 virObjectUnref(mgr);
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index 7445ab6..2454772 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -317,15 +317,15 @@ mymain(void)
 if (!(mgr = virSecurityManagerNew(selinux, QEMU, false, true, false))) 
{
 virErrorPtr err = virGetLastError();
 if (err-code == VIR_ERR_CONFIG_UNSUPPORTED)
-exit(EXIT_AM_SKIP);
+return EXIT_AM_SKIP;

 fprintf(stderr, Unable to initialize security driver: %s\n,
 err-message);
-exit(EXIT_FAILURE);
+return EXIT_FAILURE;
 }

 if ((caps = testQemuCapsInit()) == NULL)
-exit(EXIT_FAILURE);
+return EXIT_FAILURE;

 #define DO_TEST_LABELING(name) \
 if (virtTestRun(Labelling  # name, 1, testSELinuxLabeling, name)  0) \
diff --git