Message ID | 1458131974-4040-2-git-send-email-yamamoto@midokura.com |
---|---|
State | Accepted |
Headers | show |
On Wed, Mar 16, 2016 at 09:39:32PM +0900, YAMAMOTO Takashi wrote: > So that testsuite can compare log messages including the string. > > Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com> Thanks. I didn't know about this problem. Maybe the testsuite should be more lenient, but I guess that this is OK too, and less work. Acked-by: Ben Pfaff <blp@ovn.org>
On Thu, Mar 24, 2016 at 12:44 AM, Ben Pfaff <blp@ovn.org> wrote: > On Wed, Mar 16, 2016 at 09:39:32PM +0900, YAMAMOTO Takashi wrote: >> So that testsuite can compare log messages including the string. >> >> Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com> > > Thanks. I didn't know about this problem. Maybe the testsuite should > be more lenient, but I guess that this is OK too, and less work. > > Acked-by: Ben Pfaff <blp@ovn.org> thank you. pushed to master.
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/ ' } ]
So that testsuite can compare log messages including the string. Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com> --- lib/util.c | 20 ++++++++++++++++++++ tests/ofproto-macros.at | 1 - 2 files changed, 20 insertions(+), 1 deletion(-)