[ovs-dev] [warnings 1/8] tests: Check test output more carefully.

Ethan Jackson ethan at nicira.com
Fri May 13 01:33:14 UTC 2011


Looks Good.

On Mon, May 2, 2011 at 12:57, Ben Pfaff <blp at nicira.com> wrote:
> It's better to check output than to ignore it, because ignoring
> output can fail to detect real bugs later if the output changes.
> ---
>  tests/daemon-py.at    |   10 +++++-----
>  tests/jsonrpc-py.at   |    6 +++---
>  tests/jsonrpc.at      |    6 +++---
>  tests/library.at      |   21 +++++++++++++--------
>  tests/test-strtok_r.c |    2 +-
>  5 files changed, 25 insertions(+), 20 deletions(-)
>
> diff --git a/tests/daemon-py.at b/tests/daemon-py.at
> index 9a2549c..bc5a051 100644
> --- a/tests/daemon-py.at
> +++ b/tests/daemon-py.at
> @@ -6,7 +6,7 @@ AT_CAPTURE_FILE([pid])
>  AT_CAPTURE_FILE([expected])
>  # Start the daemon and wait for the pidfile to get created
>  # and that its contents are the correct pid.
> -AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/pid& echo $! > expected], [0], [ignore], [ignore])
> +AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/pid& echo $! > expected], [0])
>  OVS_WAIT_UNTIL([test -s pid], [kill `cat expected`])
>  AT_CHECK(
>   [pid=`cat pid` && expected=`cat expected` && test "$pid" = "$expected"],
> @@ -25,7 +25,7 @@ AT_CAPTURE_FILE([parent])
>  AT_CAPTURE_FILE([parentpid])
>  AT_CAPTURE_FILE([newpid])
>  # Start the daemon and wait for the pidfile to get created.
> -AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/pid --monitor& echo $! > parent], [0], [ignore], [ignore])
> +AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/pid --monitor& echo $! > parent], [0])
>  OVS_WAIT_UNTIL([test -s pid], [kill `cat parent`])
>  # Check that the pidfile names a running process,
>  # and that the parent process of that process is our child process.
> @@ -68,7 +68,7 @@ AT_CAPTURE_FILE([parent])
>  AT_CAPTURE_FILE([parentpid])
>  AT_CAPTURE_FILE([newpid])
>  # Start the daemon and wait for the pidfile to get created.
> -AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/pid --monitor& echo $! > parent], [0], [ignore], [ignore])
> +AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/pid --monitor& echo $! > parent], [0])
>  OVS_WAIT_UNTIL([test -s pid], [kill `cat parent`])
>  # Check that the pidfile names a running process,
>  # and that the parent process of that process is our child process.
> @@ -110,7 +110,7 @@ AT_CAPTURE_FILE([pid])
>  # Start the daemon and make sure that the pidfile exists immediately.
>  # We don't wait for the pidfile to get created because the daemon is
>  # supposed to do so before the parent exits.
> -AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/pid --detach], [0], [ignore], [ignore])
> +AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/pid --detach], [0])
>  AT_CHECK([test -s pid])
>  AT_CHECK([kill -0 `cat pid`])
>  # Kill the daemon and make sure that the pidfile gets deleted.
> @@ -133,7 +133,7 @@ AT_CAPTURE_FILE([init])
>  # Start the daemon and make sure that the pidfile exists immediately.
>  # We don't wait for the pidfile to get created because the daemon is
>  # supposed to do so before the parent exits.
> -AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/daemon --detach --monitor], [0], [ignore], [ignore])
> +AT_CHECK([$PYTHON $srcdir/test-daemon.py --pidfile-name=$PWD/daemon --detach --monitor], [0])
>  AT_CHECK([test -s daemon])
>  # Check that the pidfile names a running process,
>  # and that the parent process of that process is a running process,
> diff --git a/tests/jsonrpc-py.at b/tests/jsonrpc-py.at
> index e8a98bb..cda34ab 100644
> --- a/tests/jsonrpc-py.at
> +++ b/tests/jsonrpc-py.at
> @@ -8,7 +8,7 @@ AT_CHECK([kill -0 `cat pid`])
>  AT_CHECK(
>   [[$PYTHON $srcdir/test-jsonrpc.py request unix:socket echo '[{"a": "b", "x": null}]']], [0],
>   [[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
> -]], [ignore], [test ! -e pid || kill `cat pid`])
> +]], [], [test ! -e pid || kill `cat pid`])
>  AT_CHECK([kill `cat pid`])
>  AT_CLEANUP
>
> @@ -20,7 +20,7 @@ AT_CHECK([kill -0 `cat pid`])
>  AT_CHECK(
>   [[$PYTHON $srcdir/test-jsonrpc.py request unix:socket bad-request '[]']], [0],
>   [[{"error":{"error":"unknown method"},"id":0,"result":null}
> -]], [ignore], [test ! -e pid || kill `cat pid`])
> +]], [], [test ! -e pid || kill `cat pid`])
>  AT_CHECK([kill `cat pid`])
>  AT_CLEANUP
>
> @@ -32,7 +32,7 @@ AT_CHECK([test -s pid])
>  AT_CHECK([cp pid pid2])
>  AT_CHECK([kill -0 `cat pid2`])
>  AT_CHECK([[$PYTHON $srcdir/test-jsonrpc.py notify unix:socket shutdown '[]']], [0], [],
> -  [ignore], [kill `cat pid2`])
> +  [], [kill `cat pid2`])
>  AT_CHECK(
>   [pid=`cat pid2`
>    # First try a quick sleep, so that the test completes very quickly
> diff --git a/tests/jsonrpc.at b/tests/jsonrpc.at
> index 856fa46..b669a39 100644
> --- a/tests/jsonrpc.at
> +++ b/tests/jsonrpc.at
> @@ -7,7 +7,7 @@ AT_CHECK([kill -0 `cat pid`])
>  AT_CHECK(
>   [[test-jsonrpc request unix:socket echo '[{"a": "b", "x": null}]']], [0],
>   [[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
> -]], [ignore], [test ! -e pid || kill `cat pid`])
> +]], [], [test ! -e pid || kill `cat pid`])
>  AT_CHECK([kill `cat pid`])
>  AT_CLEANUP
>
> @@ -18,7 +18,7 @@ AT_CHECK([kill -0 `cat pid`])
>  AT_CHECK(
>   [[test-jsonrpc request unix:socket bad-request '[]']], [0],
>   [[{"error":{"error":"unknown method"},"id":0,"result":null}
> -]], [ignore], [test ! -e pid || kill `cat pid`])
> +]], [], [test ! -e pid || kill `cat pid`])
>  AT_CHECK([kill `cat pid`])
>  AT_CLEANUP
>
> @@ -29,7 +29,7 @@ AT_CHECK([test -s pid])
>  AT_CHECK([cp pid pid2])
>  AT_CHECK([kill -0 `cat pid2`])
>  AT_CHECK([[test-jsonrpc notify unix:socket shutdown '[]']], [0], [],
> -  [ignore], [kill `cat pid2`])
> +  [], [kill `cat pid2`])
>  AT_CHECK(
>   [pid=`cat pid2`
>    # First try a quick sleep, so that the test completes very quickly
> diff --git a/tests/library.at b/tests/library.at
> index d199373..ec50e23 100644
> --- a/tests/library.at
> +++ b/tests/library.at
> @@ -7,19 +7,22 @@ AT_CHECK([test-flows <flows 3<pcap], [0], [checked 247 packets, 0 errors
>  AT_CLEANUP
>
>  AT_SETUP([test TCP/IP checksumming])
> -AT_CHECK([test-csum], [0], [ignore])
> +AT_CHECK([test-csum], [0], [....#....#....##................................#................................#
> +])
>  AT_CLEANUP
>
>  AT_SETUP([test hash functions])
> -AT_CHECK([test-hash], [0], [ignore])
> +AT_CHECK([test-hash])
>  AT_CLEANUP
>
>  AT_SETUP([test hash map])
> -AT_CHECK([test-hmap], [0], [ignore])
> +AT_CHECK([test-hmap], [0], [.........
> +])
>  AT_CLEANUP
>
>  AT_SETUP([test linked lists])
> -AT_CHECK([test-list], [0], [ignore])
> +AT_CHECK([test-list], [0], [..
> +])
>  AT_CLEANUP
>
>  AT_SETUP([test packet library])
> @@ -27,20 +30,22 @@ AT_CHECK([test-packets])
>  AT_CLEANUP
>
>  AT_SETUP([test SHA-1])
> -AT_CHECK([test-sha1], [0], [ignore])
> +AT_CHECK([test-sha1], [0], [.........
> +])
>  AT_CLEANUP
>
>  AT_SETUP([test type properties])
> -AT_CHECK([test-type-props], [0], [ignore])
> +AT_CHECK([test-type-props])
>  AT_CLEANUP
>
>  AT_SETUP([test strtok_r bug fix])
> -AT_CHECK([test-strtok_r], [0], [ignore])
> +AT_CHECK([test-strtok_r], [0], [NULL NULL
> +])
>  AT_CLEANUP
>
>  AT_SETUP([test byte order conversion])
>  AT_KEYWORDS([byte order])
> -AT_CHECK([test-byte-order], [0], [ignore])
> +AT_CHECK([test-byte-order])
>  AT_CLEANUP
>
>  AT_SETUP([test random number generator])
> diff --git a/tests/test-strtok_r.c b/tests/test-strtok_r.c
> index 9f8d898..b302630 100644
> --- a/tests/test-strtok_r.c
> +++ b/tests/test-strtok_r.c
> @@ -33,6 +33,6 @@ main(void)
>     char *token1, *token2;
>     token1 = strtok_r(string, ":", &save_ptr);
>     token2 = strtok_r(NULL, ":", &save_ptr);
> -    printf ("%s %s\n", token1, token2);
> +    printf ("%s %s\n", token1 ? token1 : "NULL", token2 ? token2 : "NULL");
>     return 0;
>  }
> --
> 1.7.4.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list