ovsdb.at: Run Python tests for Python 2 and 3.
[cascardo/ovs.git] / tests / ovsdb.at
1 # OVSDB_CHECK_POSITIVE(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS], [PREREQ])
2 #
3 # Runs "test-ovsdb TEST-OVSDB-ARGS" and checks that it exits with
4 # status 0 and prints OUTPUT on stdout.
5 #
6 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
7 m4_define([OVSDB_CHECK_POSITIVE], 
8   [AT_SETUP([$1])
9    AT_KEYWORDS([ovsdb positive $4])
10    AT_CHECK([test-ovsdb $2], [0], [$3
11 ], [])
12    AT_CLEANUP])
13
14 # OVSDB_CHECK_POSITIVE_PY(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS], [PREREQ],
15 #                         [PY-CHECK])
16 #
17 # Runs "test-ovsdb.py TEST-OVSDB-ARGS" and checks that it exits with
18 # status 0 and prints OUTPUT on stdout.
19 #
20 # PY-CHECK is expanded before the check.  It can check for features of the
21 # Python implementation that are required for the test to pass.
22 #
23 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
24 m4_define([OVSDB_CHECK_POSITIVE_PY], 
25   [AT_SETUP([$1])
26    AT_SKIP_IF([test $HAVE_PYTHON = no])
27    $6
28    AT_KEYWORDS([ovsdb positive Python $4])
29    AT_CHECK([$PYTHON $srcdir/test-ovsdb.py $2], [0], [$3
30 ], [])
31    AT_CLEANUP])
32
33 # OVSDB_CHECK_POSITIVE_PY3(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS], [PREREQ],
34 #                          [PY-CHECK])
35 #
36 # Runs "test-ovsdb.py TEST-OVSDB-ARGS" and checks that it exits with
37 # status 0 and prints OUTPUT on stdout.
38 #
39 # PY-CHECK is expanded before the check.  It can check for features of the
40 # Python implementation that are required for the test to pass.
41 #
42 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
43 m4_define([OVSDB_CHECK_POSITIVE_PY3],
44   [AT_SETUP([$1])
45    AT_SKIP_IF([test $HAVE_PYTHON3 = no])
46    $6
47    AT_KEYWORDS([ovsdb positive Python $4])
48    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py $2], [0], [$3
49 ], [])
50    AT_CLEANUP])
51
52 # OVSDB_CHECK_POSITIVE_CPY(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS],
53 #                          [PREREQ], [PY2-CHECK], [PY3-CHECK])
54 #
55 # Runs identical C and Python tests, as specified.
56 m4_define([OVSDB_CHECK_POSITIVE_CPY],
57   [OVSDB_CHECK_POSITIVE([$1 - C], [$2], [$3], [$4], [$5])
58    OVSDB_CHECK_POSITIVE_PY([$1 - Python2], [$2], [$3], [$4], [$5], [$6])
59    OVSDB_CHECK_POSITIVE_PY([$1 - Python3], [$2], [$3], [$4], [$5], [$7])])
60
61 # OVSDB_CHECK_NEGATIVE(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS], [PREREQ])
62 #
63 # Runs "test-ovsdb TEST-OVSDB-ARGS" and checks that it exits with
64 # status 1 and that its output on stdout contains substring OUTPUT.
65 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.  
66 m4_define([OVSDB_CHECK_NEGATIVE], 
67   [AT_SETUP([$1])
68    AT_KEYWORDS([ovsdb negative $4])
69    AT_CHECK([test-ovsdb $2], [1], [], [stderr])
70    m4_assert(m4_len([$3]))
71    AT_CHECK(
72      [if grep -F -e "AS_ESCAPE([$3])" stderr
73       then
74         :
75       else
76         exit 99
77       fi], 
78             [0], [ignore], [ignore])
79    AT_CLEANUP])
80
81 # OVSDB_CHECK_NEGATIVE_PY(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS], [PREREQ])
82 #
83 # Runs "test-ovsdb TEST-OVSDB-ARGS" and checks that it exits with
84 # status 1 and that its output on stdout contains substring OUTPUT.
85 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
86 m4_define([OVSDB_CHECK_NEGATIVE_PY],
87   [AT_SETUP([$1])
88    AT_SKIP_IF([test $HAVE_PYTHON = no])
89    AT_KEYWORDS([ovsdb negative $4])
90    AT_CHECK([$PYTHON $srcdir/test-ovsdb.py $2], [1], [], [stderr])
91    m4_assert(m4_len([$3]))
92    AT_CHECK(
93      [if grep -F -e "AS_ESCAPE([$3])" stderr
94       then
95         :
96       else
97         exit 99
98       fi], 
99             [0], [ignore], [ignore])
100    AT_CLEANUP])
101
102 # OVSDB_CHECK_NEGATIVE_PY3(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS], [PREREQ])
103 #
104 # Runs "test-ovsdb TEST-OVSDB-ARGS" and checks that it exits with
105 # status 1 and that its output on stdout contains substring OUTPUT.
106 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
107 m4_define([OVSDB_CHECK_NEGATIVE_PY],
108   [AT_SETUP([$1])
109    AT_SKIP_IF([test $HAVE_PYTHON3 = no])
110    AT_KEYWORDS([ovsdb negative $4])
111    AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py $2], [1], [], [stderr])
112    m4_assert(m4_len([$3]))
113    AT_CHECK(
114      [if grep -F -e "AS_ESCAPE([$3])" stderr
115       then
116         :
117       else
118         exit 99
119       fi],
120             [0], [ignore], [ignore])
121    AT_CLEANUP])
122
123 # OVSDB_CHECK_NEGATIVE_CPY(TITLE, TEST-OVSDB-ARGS, OUTPUT, [KEYWORDS],
124 #                          [PREREQ])
125 #
126 # Runs identical C and Python tests, as specified.
127 m4_define([OVSDB_CHECK_NEGATIVE_CPY],
128   [OVSDB_CHECK_NEGATIVE([$1 - C], [$2], [$3], [$4], [$5])
129    OVSDB_CHECK_NEGATIVE_PY([$1 - Python2], [$2], [$3], [$4], [$5])
130    OVSDB_CHECK_NEGATIVE_PY3([$1 - Python3], [$2], [$3], [$4], [$5])])
131
132 m4_include([tests/ovsdb-log.at])
133 m4_include([tests/ovsdb-types.at])
134 m4_include([tests/ovsdb-data.at])
135 m4_include([tests/ovsdb-column.at])
136 m4_include([tests/ovsdb-table.at])
137 m4_include([tests/ovsdb-row.at])
138 m4_include([tests/ovsdb-schema.at])
139 m4_include([tests/ovsdb-condition.at])
140 m4_include([tests/ovsdb-mutation.at])
141 m4_include([tests/ovsdb-query.at])
142 m4_include([tests/ovsdb-transaction.at])
143 m4_include([tests/ovsdb-execution.at])
144 m4_include([tests/ovsdb-trigger.at])
145 m4_include([tests/ovsdb-tool.at])
146 m4_include([tests/ovsdb-server.at])
147 m4_include([tests/ovsdb-monitor.at])
148 m4_include([tests/ovsdb-idl.at])