<div dir="ltr">I think I actually know the point of the test.<div><br></div><div>It tries to verify that size, alloc, and data were initialized to 0, rather than left uninitialized - but the difficulty is that uninitialized memory is often already filled with 0s. So the test repeats the process a whole bunch of times, hoping to eventually catch non-0 uninitialized memory.</div><div><br></div><div>(That doesn't mean it's a good way to test it, though, so I have nothing against removing it. Something like valgrind is probably better.)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 27, 2016 at 8:03 PM, Yong Bakos <span dir="ltr"><<a href="mailto:junk@humanoriented.com" target="_blank">junk@humanoriented.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Yong Bakos <<a href="mailto:ybakos@humanoriented.com">ybakos@humanoriented.com</a>><br>
<br>
Include wayland-util.h in addition to wayland-private.h, to be more explicit<br>
about where wl_array is defined.<br>
<br>
Remove the useless repeated testing of wl_array_init, because if it fails once<br>
out of thousands of iterations we're all doomed anyway.<br>
<br>
Signed-off-by: Yong Bakos <<a href="mailto:ybakos@humanoriented.com">ybakos@humanoriented.com</a>><br>
Reviewed-by: Eric Engestrom <<a href="mailto:eric.engestrom@imgtec.com">eric.engestrom@imgtec.com</a>><br>
Reviewed-by: Pekka Paalanen <<a href="mailto:pekka.paalanen@collabora.co.uk">pekka.paalanen@collabora.co.<wbr>uk</a>><br>
---<br>
v2: Add empty line (pq)<br>
<br>
 tests/array-test.c | 18 ++++++------------<br>
 1 file changed, 6 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/tests/array-test.c b/tests/array-test.c<br>
index b0de8e6..ed6fbfb 100644<br>
--- a/tests/array-test.c<br>
+++ b/tests/array-test.c<br>
@@ -25,24 +25,18 @@<br>
<br>
 #include <stdlib.h><br>
 #include <assert.h><br>
+#include "wayland-util.h"<br>
 #include "wayland-private.h"<br>
 #include "test-runner.h"<br>
<br>
 TEST(array_init)<br>
 {<br>
-       const int iterations = 4122; /* this is arbitrary */<br>
-       int i;<br>
-<br>
-       /* Init array an arbitray amount of times and verify the<br>
-        * defaults are sensible. */<br>
+       struct wl_array array;<br>
<br>
-       for (i = 0; i < iterations; i++) {<br>
-               struct wl_array array;<br>
-               wl_array_init(&array);<br>
-               assert(array.size == 0);<br>
-               assert(array.alloc == 0);<br>
-               assert(array.data == 0);<br>
-       }<br>
+       wl_array_init(&array);<br>
+       assert(array.size == 0);<br>
+       assert(array.alloc == 0);<br>
+       assert(array.data == 0);<br>
 }<br>
<br>
 TEST(array_release)<br>
--<br>
2.7.2<br>
<br>
______________________________<wbr>_________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.<wbr>freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/wayland-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/wayland-devel</a><br>
</blockquote></div><br></div>