From: Ryan Lortie Date: Fri, 2 Dec 2011 22:47:34 +0000 (-0500) Subject: menumodel test: don't get stuck in a loop X-Git-Tag: 2.31.4~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ef8c443092e52e5f4a934c77b1e30a06f59451d9;p=platform%2Fupstream%2Fglib.git menumodel test: don't get stuck in a loop Sometimes randa and randb end up having the same state, causing them to return the same stream of 'random numbers'. This is a problem for the testcase that is looping to find unequal menus. If we find ourselves in this state, throw one of the random generators away and recreate it so we have a better chance of getting some unequal menus. --- diff --git a/gio/tests/gmenumodel.c b/gio/tests/gmenumodel.c index 59ffaac..aa42943 100644 --- a/gio/tests/gmenumodel.c +++ b/gio/tests/gmenumodel.c @@ -506,6 +506,13 @@ test_equality (void) g_assert_cmpstr (as->str, ==, bs->str); g_string_free (bs, TRUE); g_string_free (as, TRUE); + + /* we're here because randa and randb just generated equal + * menus. they may do it again, so throw away randb and make + * a fresh one. + */ + g_rand_free (randb); + randb = g_rand_new_with_seed (g_rand_int (randa)); } else /* make sure we get enough unequals (ie: no GRand failure) */