--- /dev/null
+AT_BANNER([OVSDB -- ovsdb-server monitors])
+
+# OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], MONITOR-ARGS,
+# TRANSACTIONS, OUTPUT, [KEYWORDS])
+#
+# Creates a database with the given SCHEMA, starts an ovsdb-server on
+# that database, and runs each of the TRANSACTIONS (which should be a
+# quoted list of quoted strings) against it with ovsdb-client one at a
+# time.
+#
+# Checks that the overall output is OUTPUT, but UUIDs in the output
+# are replaced by markers of the form <N> where N is a number. The
+# first unique UUID is replaced by <0>, the next by <1>, and so on.
+# If a given UUID appears more than once it is always replaced by the
+# same marker.
+#
+# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
+m4_define([OVSDB_CHECK_MONITOR],
+ [AT_SETUP([$1])
+ AT_KEYWORDS([ovsdb server monitor positive $7])
+ AT_DATA([schema], [$2
+])
+ OVS_CHECK_LCOV([ovsdb-tool create db schema], [0], [stdout], [ignore])
+ m4_if([$3], [], [],
+ [OVS_CHECK_LCOV([ovsdb-tool transact db '$2'], [0], [ignore], [ignore])])
+ AT_CHECK([ovsdb-server --detach --pidfile=$PWD/server-pid --listen=punix:socket --unixctl=$PWD/unixctl db])
+ AT_CHECK([ovsdb-client monitor --format=csv unix:socket $4 > output & echo $! > monitor-pid],
+ [0], [ignore], [ignore], [kill `cat server-pid`])
+ m4_foreach([txn], [$5],
+ [OVS_CHECK_LCOV([ovsdb-client transact unix:socket 'txn'], [0],
+ [ignore], [ignore], [kill `cat server-pid monitor-pid`])])
+ AT_CHECK([ovs-appctl -t $PWD/unixctl -e exit], [0], [ignore], [ignore])
+ wait
+ AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$6])
+ AT_CLEANUP])
+
+OVSDB_CHECK_MONITOR([monitor initially empty table],
+ [ORDINAL_SCHEMA],
+ [],
+ [ordinals],
+ [[[[{"op": "insert",
+ "table": "ordinals",
+ "row": {"number": 0, "name": "zero"}}]]]],
+ [[row,action,name,number,_version
+<0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
+]])