Gluster test: Using TESTS_EXPECTED_IN_LOOP

One frequently asked question on Gluster test framework is how to encapsulate the TEST/EXPECT/EXPECT_WITHIN statements within a function without getting "bad test plan" errors. I wrote a sample test to demonstrate the solution using TESTS_EXPECTED_IN_LOOP . The trick here is to count the number of invocations (n) of the "function" and then set
TESTS_EXPECTED_IN_LOOP=(n-1) * (test statements in function).

Yes, this trick does not work when the number of times a function is called is not deterministic. For such cases, you would have to prefix the function invocation with a test statement and lose the granularity of the tests.