datapath: remove rtnl_delete_link support for older Linux
[cascardo/ovs.git] / tests / ovsdb-lock.at
1 AT_BANNER([OVSDB -- lock])
2
3 # OVSDB_CHECK_LOCK_SETUP(TITILE, KEYWORDS)
4 #
5 # Starts an OVSDB server and the default lock transaction, acquire "lock0",
6 # using the ovsdb-client tool.  Execute additional <LOCK_TRANSACTIONS>,
7 # and compare output file catured from ovsdb-client tools to <OUTPUT>.
8
9 m4_define([OVSDB_CHECK_LOCK_SETUP],
10    [AT_SETUP([ovsdb lock -- $1])
11     AT_SKIP_IF([test "$IS_WIN32" = "yes"])
12     AT_KEYWORDS([ovsdb lock $2])
13     ordinal_schema > schema
14     AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
15     AT_CAPTURE_FILE([ovsdb-server-log])
16     AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1], [0], [], [])])
17
18 #
19 # Two sessions create two locks. Both sessions should be able to get their
20 # own lock immediately.
21 OVSDB_CHECK_LOCK_SETUP([lock], [positive])
22 AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c1-output 2>&1],
23       [0], [], [])
24 AT_CHECK([ovsdb-client --detach lock unix:socket lock1 >c2-output 2>&1],
25       [0], [], [])
26 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
27 AT_CHECK([cat c1-output], 0, [{"locked":true}
28 ], [])
29 AT_CHECK([cat c2-output], 0, [{"locked":true}
30 ], [])
31 AT_CLEANUP
32
33 #
34 # Two session wait on the same lock. The first session should be able
35 # to get the lock immediately, the second session will get a notification
36 # after the first session unlocks.
37 OVSDB_CHECK_LOCK_SETUP([unlock], [positive])
38 AT_CHECK([ovsdb-client --detach --pidfile lock unix:socket lock0 >c1-output 2>&1],
39       [0], [], [])
40 AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c2-output 2>&1],
41       [0], [], [])
42 AT_CHECK([ovs-appctl -t ovsdb-client unlock lock0], [0], [], [])
43 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
44 AT_CHECK([cat c1-output], 0, [{"locked":true}
45 {}
46 ])
47 AT_CHECK([cat c2-output], 0, [{"locked":false}
48 locked
49 [["lock0"]]
50 ], [])
51 AT_CLEANUP
52
53 #
54 # Two session waits on the same lock. The first session should be able
55 # to get the lock immediately. The second session tries to steal the lock, then
56 # unlocks the lock.
57 OVSDB_CHECK_LOCK_SETUP([steal], [positive])
58 AT_CHECK([ovsdb-client --detach lock unix:socket lock0 >c1-output 2>&1],
59       [0], [], [])
60 AT_CHECK([ovsdb-client --detach --pidfile steal unix:socket lock0 >c2-output 2>&1],
61       [0], [], [])
62 AT_CHECK([ovs-appctl -t ovsdb-client unlock lock0], [0], [], [])
63 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
64 AT_CHECK([cat c1-output], 0, [{"locked":true}
65 stolen
66 [["lock0"]]
67 locked
68 [["lock0"]]
69 ])
70 AT_CHECK([cat c2-output], 0, [{"locked":true}
71 {}
72 ], [])
73 AT_CLEANUP