So that testsuite can compare log messages including the string.

Signed-off-by: YAMAMOTO Takashi <yamam...@midokura.com>
---
 lib/util.c              | 20 ++++++++++++++++++++
 tests/ofproto-macros.at |  1 -
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/util.c b/lib/util.c
index f06dee5..36abeed 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -413,6 +413,21 @@ ovs_strerror(int error)
     char *buffer;
     char *s;
 
+    if (error == 0) {
+        /*
+         * strerror(0) varies among platforms:
+         *
+         *   Success
+         *   No error
+         *   Undefined error: 0
+         *
+         * We want to provide a consistent result here because
+         * our testsuite has test cases which strictly matches
+         * log messages containing this string.
+         */
+        return "Success";
+    }
+
     save_errno = errno;
     buffer = strerror_buffer_get()->s;
 
@@ -2049,6 +2064,11 @@ ovs_format_message(int error)
     enum { BUFSIZE = sizeof strerror_buffer_get()->s };
     char *buffer = strerror_buffer_get()->s;
 
+    if (error == 0) {
+        /* See ovs_strerror */
+        return "Success";
+    }
+
     FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                   NULL, error, 0, buffer, BUFSIZE, NULL);
     return buffer;
diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 18114d9..d4e61f3 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -30,7 +30,6 @@ prt==1 { sub(/[ \t]*$/, ""); print $0 }
 vconn_sub() {
     sed '
 s/tcp:127.0.0.1:[0-9][0-9]*:/unix:/
-s/No error/Success/
 '
 }
 ]
-- 
2.5.4 (Apple Git-61)

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to