[ovs-dev] [PATCH v2 3/7] test-util: Changes for 'assert' test on Windows.

Gurucharan Shetty shettyg at nicira.com
Fri Jun 13 14:40:02 UTC 2014


There is no 'kill -l' type functionality available on Windows.
So instead of looking for the string 'ABRT', check for the exit
code in both platforms. On msys (unit test environment), it is 9
and on Linux, it is 134 (SIGABRT + 128).

On Windows, stderr is fully buffered if connected to a pipe.
Make it _IONBF so that an abort does not miss log contents.

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
v1-v2:
  * Check for exit status instead of 'kill -l' for all platforms.
  * For Windows, make stderr _IONBF.
---
 tests/library.at  |   11 ++++++++---
 tests/test-util.c |    3 +++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tests/library.at b/tests/library.at
index a94ee5c..a5dfd82 100644
--- a/tests/library.at
+++ b/tests/library.at
@@ -175,9 +175,14 @@ AT_CLEANUP
 
 AT_SETUP([ovs_assert])
 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
-AT_CHECK([ovstest test-util -voff -vfile:info '-vPATTERN:file:%c|%p|%m' --log-file assert || kill -l $?],
-  [0], [ABRT
-], [stderr])
+if test "$IS_WIN32" = "yes"; then
+  exit_status=9
+else
+  # SIGABRT + 128
+  exit_status=134
+fi
+AT_CHECK([ovstest test-util -voff -vfile:info '-vPATTERN:file:%c|%p|%m' --log-file assert],
+  [$exit_status], [], [stderr])
 
 AT_CHECK([sed 's/\(opened log file\) .*/\1/
 s/|[[^|]]*: /|/' test-util.log], [0], [dnl
diff --git a/tests/test-util.c b/tests/test-util.c
index ffd4dce..093ee9c 100644
--- a/tests/test-util.c
+++ b/tests/test-util.c
@@ -1086,6 +1086,9 @@ test_util_main(int argc, char *argv[])
 {
     set_program_name(argv[0]);
     parse_options(argc, argv);
+#ifdef _WIN32
+    setvbuf(stderr, NULL, _IONBF, 0);
+#endif
     run_command(argc - optind, argv + optind, commands);
 }
 
-- 
1.7.9.5




More information about the dev mailing list