1 AT_BANNER([UUID unit tests])
3 m4_define([UUID_REGEX],
4 [[[0-9a-f]\{8\}-[0-9a-f]\{4\}-4[0-9a-f]\{3\}-[89ab][0-9a-f]\{3\}-[0-9a-f]\{12\}$]])
6 m4_define([CHECK_UUID],
7 [if expr "$uuid" : 'UUID_REGEX' > /dev/null
11 echo "$uuid: not a random UUID"
15 # This test is a strict subset of the larger test down below, but it
16 # completes in a realistic amount of time with the "lcov" wrapper.
17 AT_SETUP([UUID generation])
19 AT_CHECK([test-uuid > uuid])
25 # This test is a strict subset of the larger test down below, but it
26 # completes in a realistic amount of time with the "lcov" wrapper.
27 AT_SETUP([UUID parsing and serialization])
29 AT_CHECK([test-uuid f47ac10b-58cc-4372-a567-0e02b2c3d479], [0],
30 [f47ac10b-58cc-4372-a567-0e02b2c3d479
34 AT_SETUP([UUID generation, parsing, serialization])
35 AT_SKIP_IF([test "$CHECK_LCOV" = true]) # lcov makes this test absurdly slow
39 for i in m4_for([count], [1], [100], [1], [count ]); do
40 # Generate random UUID and check that it is in the expected format.
44 # Verify that $uuid does not duplicate any UUID generated so far.
47 echo "$uuid: generated duplicate UUID"
52 # Verify that test-uuid parses and re-serializes this UUID correctly.
53 serialized=`test-uuid $uuid`
54 if test "$uuid" != "$serialized"; then
55 echo "$uuid: test-uuid serialized this as $serialized"