]> git.proxmox.com Git - mirror_ovs.git/blob - tests/uuid.at
Rework and simplify the "lcov" support for the testsuite.
[mirror_ovs.git] / tests / uuid.at
1 AT_BANNER([UUID unit tests])
2
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\}$]])
5
6 m4_define([CHECK_UUID],
7 [if expr "$uuid" : 'UUID_REGEX' > /dev/null
8 then
9 :
10 else
11 echo "$uuid: not a random UUID"
12 exit 1
13 fi])
14
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])
18 AT_KEYWORDS([UUID])
19 AT_CHECK([test-uuid > uuid])
20 AT_CHECK([
21 uuid=`cat uuid`
22 CHECK_UUID])
23 AT_CLEANUP
24
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])
28 AT_KEYWORDS([UUID])
29 AT_CHECK([test-uuid f47ac10b-58cc-4372-a567-0e02b2c3d479], [0],
30 [f47ac10b-58cc-4372-a567-0e02b2c3d479
31 ])
32 AT_CLEANUP
33
34 AT_SETUP([UUID generation, parsing, serialization])
35 AT_SKIP_IF([test "$CHECK_LCOV" = true]) # lcov makes this test absurdly slow
36 AT_KEYWORDS([UUID])
37 AT_CHECK([
38 uuids=
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.
41 uuid=`test-uuid`
42 CHECK_UUID
43
44 # Verify that $uuid does not duplicate any UUID generated so far.
45 case $uuids in
46 *$uuid*)
47 echo "$uuid: generated duplicate UUID"
48 exit 1
49 esac
50 uuids="$uuids $uuid"
51
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"
56 exit 1
57 fi
58 done], [0])
59 AT_CLEANUP