[ovs-dev] [PATCH 08/12] python tests: Ignore stderr output

Paul Boca pboca at cloudbasesolutions.com
Mon Aug 29 17:55:00 UTC 2016



From: Guru Shetty [mailto:guru at ovn.org]
Sent: Monday, August 29, 2016 8:44 PM
To: Paul Boca
Cc: dev at openvswitch.org
Subject: Re: [ovs-dev] [PATCH 08/12] python tests: Ignore stderr output



On 29 August 2016 at 10:36, Paul Boca <pboca at cloudbasesolutions.com<mailto:pboca at cloudbasesolutions.com>> wrote:
Hi Guru,

please see my comments inline.

Thanks,
Paul

From: Guru Shetty [mailto:guru at ovn.org<mailto:guru at ovn.org>]
Sent: Friday, August 26, 2016 9:04 PM
To: Paul Boca
Cc: dev at openvswitch.org<mailto:dev at openvswitch.org>
Subject: Re: [ovs-dev] [PATCH 08/12] python tests: Ignore stderr output



On 26 August 2016 at 07:40, Paul Boca <pboca at cloudbasesolutions.com<mailto:pboca at cloudbasesolutions.com>> wrote:
test-unixctl.py and test-vlog.py outputs on stderr and on Windows
stderr is not overriden by every AT_CHECK call, the logs are only
apended to the file and subsequent AT_CHECKs get errors from previous
call.

Signed-off-by: Paul-Daniel Boca <pboca at cloudbasesolutions.com<mailto:pboca at cloudbasesolutions.com>>
---
 tests/unixctl-py.at<http://unixctl-py.at> | 3 ++-
 tests/vlog.at<http://vlog.at>       | 9 +++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/unixctl-py.at<http://unixctl-py.at> b/tests/unixctl-py.at<http://unixctl-py.at>
index 2031897..0ed3c41 100644
--- a/tests/unixctl-py.at<http://unixctl-py.at>
+++ b/tests/unixctl-py.at<http://unixctl-py.at>
@@ -114,7 +114,8 @@ m4_define([UNIXCTL_SERVER_PYN],
    AT_SKIP_IF([test $2 = no])
    on_exit 'kill `cat test-unixctl.py.pid`'
    AT_CAPTURE_FILE([`pwd`/test-unixctl.py.log])
-   AT_CHECK([$3 $srcdir/test-unixctl.py --log-file --pidfile --detach])
+   AT_CHECK([$3 $srcdir/test-unixctl.py --log-file --pidfile --detach],
+     [0], [], [ignore])


    AT_CHECK([APPCTL -t test-unixctl.py help], [0], [stdout])
    AT_CHECK([cat stdout], [0], [dnl
diff --git a/tests/vlog.at<http://vlog.at> b/tests/vlog.at<http://vlog.at>
index a689809..468e872 100644
--- a/tests/vlog.at<http://vlog.at>
+++ b/tests/vlog.at<http://vlog.at>
@@ -195,7 +195,7 @@ m4_define([VLOG_REOPEN_WITHOUT_FILE_PYN],
    AT_SKIP_IF([test $2 = no])
    on_exit 'kill `cat test-unixctl.py.pid`'

-   AT_CHECK([$3 $srcdir/test-unixctl.py --pidfile --detach])
+   AT_CHECK([$3 $srcdir/test-unixctl.py --pidfile --detach], [0], [], [ignore])

    AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen], [0],
      [Logging to file not configured
@@ -322,7 +322,7 @@ m4_define([VLOG_CLOSE_PYN],

    AT_CAPTURE_FILE([log])
    AT_CAPTURE_FILE([log.old])
-   AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
+   AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach 2>/dev/null])

Why do we need the 2>/dev/null ? i.e. can you explain why the approach is different than the previous change?
[Paul Boca] Here we need redirection to /dev/null of stderr because the next commands will check stderr and
will fail if it is not empty.

So you are saying that running $srcdir/test-unixctl.py on Windows produces output in stderr. Why? Is there a bug with Windows port?
[Paul Boca] This is the way logging library works on both Windows and Linux (https://docs.python.org/2/howto/logging.html -
“If you call the functions debug()<https://docs.python.org/2/library/logging.html#logging.debug>, info()<https://docs.python.org/2/library/logging.html#logging.info>,warning()<https://docs.python.org/2/library/logging.html#logging.warning>, error()<https://docs.python.org/2/library/logging.html#logging.error> and critical()<https://docs.python.org/2/library/logging.html#logging.critical>, they will check to see if no
destination is set; and if one is not set, they will set a destination of the console (sys.stderr)”)
but the difference is that on Windows the stderr is appended in a file (the same file) and on Linux a stderr instance
is used for every command.

On Windows the output to stdout or stderr is appended for every command executed, so the test-unixctl.py
will write the output to stderr and if we would only ignore it then the next APPCTL command will fail because
the stderr is not empty.
On previous case it is enough to ignore the stderr output so the test-unixctl.py will not fail, the next APPCLT command will
reset the stderr on reopen (observed by testing – didn’t found documentation for it).

    AT_CHECK([APPCTL -t test-unixctl.py log message])
    AT_CHECK([APPCTL -t test-unixctl.py log message2])
@@ -406,7 +406,8 @@ m4_define([VLOG_SET_AND_LIST_PYN],
    on_exit 'kill `cat test-unixctl.py.pid`'

    AT_CAPTURE_FILE([log])
-   AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
+   AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
+     --detach 2>/dev/null])

    AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
                  console    syslog    file
@@ -502,7 +503,7 @@ m4_define([VLOG_RFC5424_PYN],
 ])

    AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
--vFACILITY:daemon --detach])
+-vFACILITY:daemon --detach], [0], [], [ignore])

    AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:invalid], [0],
 [Facility invalid is invalid
--
2.7.2.windows.1
_______________________________________________
dev mailing list
dev at openvswitch.org<mailto:dev at openvswitch.org>
http://openvswitch.org/mailman/listinfo/dev




More information about the dev mailing list