<div dir="ltr"><div><div>Hi,<br><br></div>I fixed the comment as Bryce wrote (s/came/come) and fixed a white-space error.<br></div><div>The logic of this version of the patch is equivalent to the old one.<br></div><div><br>
</div>Thanks,<br>Marek<br><div><div class="gmail_extra"><br><br><div class="gmail_quote">On 7 July 2014 20:41, Bryce W. Harrington <span dir="ltr"><<a href="mailto:b.harrington@samsung.com" target="_blank">b.harrington@samsung.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, Jul 07, 2014 at 05:47:41PM +0300, Pekka Paalanen wrote:<br>
> On Thu, 19 Jun 2014 02:37:40 +0000<br>
> "Bryce W. Harrington" <<a href="mailto:b.harrington@samsung.com">b.harrington@samsung.com</a>> wrote:<br>
><br>
> > On Mon, May 26, 2014 at 04:58:05PM +0200, Marek Chalupa wrote:<br>
> > > This function checks if a particular protocol error came in wire.<br>
> > > It's usefull in the cases where we hitherto used FAIL_TEST.<br>
> > > The problem with FAIL_TEST is that *any* assert will pass the test,<br>
> > > but we want only some asserts to pass the test (i. e. we don't<br>
> > > want the test to pass when it, for example, can't connect to display).<br>
> > > FAIL_TESTs are good only for sanity testing.<br>
> > ><br>
> > > The expect_protocol_error allows us to turn all FAIL_TESTs to TESTs<br>
> > > as will be introduced in following patches.<br>
> > > ---<br>
> > > tests/weston-test-client-helper.c | 49 +++++++++++++++++++++++++++++++++++++++<br>
> > > tests/weston-test-client-helper.h | 4 ++++<br>
> > > 2 files changed, 53 insertions(+)<br>
> > ><br>
> > > diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c<br>
> > > index 186b395..fb2e477 100644<br>
> > > --- a/tests/weston-test-client-helper.c<br>
> > > +++ b/tests/weston-test-client-helper.c<br>
> > > @@ -26,6 +26,7 @@<br>
> > > #include <stdio.h><br>
> > > #include <string.h><br>
> > > #include <unistd.h><br>
> > > +#include <errno.h><br>
> > > #include <sys/mman.h><br>
> > ><br>
> > > #include "../shared/os-compatibility.h"<br>
> > > @@ -512,6 +513,54 @@ skip(const char *fmt, ...)<br>
> > > exit(77);<br>
> > > }<br>
> > ><br>
> > > +void<br>
> > > +expect_protocol_error(struct client *client,<br>
> > > + const struct wl_interface *intf,<br>
> > > + uint32_t code)<br>
> > > +{<br>
> > > + int err;<br>
> > > + uint32_t errcode, failed = 0;<br>
> > > + const struct wl_interface *interface;<br>
> > > + unsigned int id;<br>
> > > +<br>
> > > + /* if the error has not came yet, make it happen */<br>
> ><br>
> > "has not come yet"<br>
> ><br>
> > > + wl_display_roundtrip(client->wl_display);<br>
> > > +<br>
> > > + err = wl_display_get_error(client->wl_display);<br>
> > > +<br>
> > > + assert(err && "Expected protocol error but nothing came");<br>
> > > + assert(err == EPROTO && "Expected protocol error but got local error");<br>
> > > +<br>
> > > +<br>
> > > + errcode = wl_display_get_protocol_error(client->wl_display,<br>
> > > + &interface, &id);<br>
> > > +<br>
> > > + /* check error */<br>
> > > + if (errcode != code) {<br>
> > > + fprintf(stderr, "Should get error code %d but got %d\n",<br>
> > > + code, errcode);<br>
> > > + failed = 1;<br>
> > > + }<br>
> > > +<br>
> > > + /* this should be definitely set */<br>
> > > + assert(interface);<br>
> > > +<br>
> > > + if (strcmp(intf->name, interface->name) != 0) {<br>
> > > + fprintf(stderr, "Should get interface '%s' but got '%s'\n",<br>
> > > + intf->name, interface->name);<br>
> > > + failed = 1;<br>
> > > + }<br>
> > > +<br>
> > > + if (failed) {<br>
> > > + fprintf(stderr, "Expected other protocol error\n");<br>
> > > + abort();<br>
> > > + }<br>
> > > +<br>
> > > + /* all OK */<br>
> > > + fprintf(stderr, "Got expected protocol error on '%s' (object id: %d) "<br>
> > > + "with code %d\n", interface->name, id, errcode);<br>
> > > +}<br>
> > > +<br>
> ><br>
> > I think if you move the assert higher, you can condense the logic a<br>
> > bit. Maybe it's clearer:<br>
> ><br>
> > /* this should be definitely set */<br>
> > assert(interface);<br>
> ><br>
> > if (errcode != code) {<br>
> > fprintf(stderr, "Should get error code %d but got %d\n",<br>
> > code, errcode);<br>
> > } else if (strcmp(intf->name, interface->name) != 0) {<br>
> > fprintf(stderr, "Should get interface '%s' but got '%s'\n",<br>
> > intf->name, interface->name);<br>
> > } else {<br>
> > fprintf(stderr, "Got expected protocol error on '%s' (object id: %d) "<br>
> > "with code %d\n", interface->name, id, errcode);<br>
> > return;<br>
> > }<br>
> ><br>
> > fprintf(stderr, "Expected a different protocol error\n");<br>
> > abort();<br>
> > }<br>
> ><br>
> > I wonder if the final error message is a bit redundant.<br>
> ><br>
> > > static void<br>
> > > log_handler(const char *fmt, va_list args)<br>
> > > {<br>
> > > diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h<br>
> > > index 4bfc3fa..f154661 100644<br>
> > > --- a/tests/weston-test-client-helper.h<br>
> > > +++ b/tests/weston-test-client-helper.h<br>
> > > @@ -129,4 +129,8 @@ get_n_egl_buffers(struct client *client);<br>
> > > void<br>
> > > skip(const char *fmt, ...);<br>
> > ><br>
> > > +void<br>
> > > +expect_protocol_error(struct client *client,<br>
> > > + const struct wl_interface *intf, uint32_t code);<br>
> > > +<br>
> > > #endif<br>
> ><br>
> ><br>
> > Reviewed-by: Bryce Harrington <<a href="mailto:b.harrington@samsung.com">b.harrington@samsung.com</a>><br>
><br>
> Hi Bryce,<br>
><br>
> is this a reviewed-by also for the original patch without<br>
> suggested changes?<br>
<br>
</div></div>Yes<br>
<div class=""><br>
> And only for patch 1?<br>
<br>
</div>I didn't see any issues with patches 2 and 3.<br>
<span class="HOEnZb"><font color="#888888"><br>
Bryce</font></span></blockquote></div><br></div></div></div>