ofproto: Inline trivial functions.
[sliver-openvswitch.git] / tests / ovsdb-idl.at
index 5956f72..89752f0 100644 (file)
@@ -1,7 +1,8 @@
 AT_BANNER([OVSDB -- interface description language (IDL)])
 
-# OVSDB_CHECK_IDL(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
-#                 [FILTER])
+OVS_RUNDIR=`pwd`; export OVS_RUNDIR
+# OVSDB_CHECK_IDL_C(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
+#                   [FILTER])
 #
 # Creates a database with a schema derived from idltest.ovsidl, runs
 # each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
@@ -16,21 +17,89 @@ AT_BANNER([OVSDB -- interface description language (IDL)])
 # through the specified program.
 #
 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
-m4_define([OVSDB_CHECK_IDL], 
-  [AT_SETUP([$1])
+m4_define([OVSDB_CHECK_IDL_C],
+  [AT_SETUP([$1 - C])
    AT_KEYWORDS([ovsdb server idl positive $5])
+   OVS_RUNDIR=`pwd`; export OVS_RUNDIR
    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
                   [0], [stdout], [ignore])
-   AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
+   AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
    m4_if([$2], [], [],
      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
-   AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3], 
+   AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3],
             [0], [stdout], [ignore], [kill `cat pid`])
-   AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
+   AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
             [0], [$4], [], [kill `cat pid`])
    OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
 
+# same as OVSDB_CHECK_IDL but uses the Python IDL implementation.
+m4_define([OVSDB_CHECK_IDL_PY],
+  [AT_SETUP([$1 - Python])
+   AT_SKIP_IF([test $HAVE_PYTHON = no])
+   AT_KEYWORDS([ovsdb server idl positive Python $5])
+   OVS_RUNDIR=`pwd`; export OVS_RUNDIR
+   AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
+                  [0], [stdout], [ignore])
+   AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
+   m4_if([$2], [], [],
+     [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
+   AT_CHECK([$PYTHON $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
+            [0], [stdout], [ignore], [kill `cat pid`])
+   AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
+            [0], [$4], [], [kill `cat pid`])
+   OVSDB_SERVER_SHUTDOWN
+   AT_CLEANUP])
+
+# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
+m4_define([OVSDB_CHECK_IDL_TCP_PY],
+  [AT_SETUP([$1 - Python tcp])
+   AT_SKIP_IF([test $HAVE_PYTHON = no])
+   AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
+   OVS_RUNDIR=`pwd`; export OVS_RUNDIR
+   OVS_LOGDIR=`pwd`; export OVS_LOGDIR
+   AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
+                  [0], [stdout], [ignore])
+   AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
+   TCP_PORT=`parse_listening_port < ovsdb-server.log`
+
+   m4_if([$2], [], [],
+     [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore], [kill `cat pid`])])
+   AT_CHECK([$PYTHON $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3],
+            [0], [stdout], [ignore], [kill `cat pid`])
+   AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
+            [0], [$4], [], [kill `cat pid`])
+   OVSDB_SERVER_SHUTDOWN
+   AT_CLEANUP])
+
+# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6
+m4_define([OVSDB_CHECK_IDL_TCP6_PY],
+  [AT_SETUP([$1 - Python tcp6])
+   AT_SKIP_IF([test $HAVE_PYTHON = no])
+   AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
+   OVS_RUNDIR=`pwd`; export OVS_RUNDIR
+   OVS_LOGDIR=`pwd`; export OVS_LOGDIR
+   AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
+                  [0], [stdout], [ignore])
+   AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
+   TCP_PORT=`parse_listening_port < ovsdb-server.log`
+   echo "TCP_PORT=$TCP_PORT"
+
+   m4_if([$2], [], [],
+     [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore], [kill `cat pid`])])
+   AT_CHECK([$PYTHON $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $3],
+            [0], [stdout], [ignore], [kill `cat pid`])
+   AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
+            [0], [$4], [], [kill `cat pid`])
+   OVSDB_SERVER_SHUTDOWN
+   AT_CLEANUP])
+
+m4_define([OVSDB_CHECK_IDL],
+  [OVSDB_CHECK_IDL_C($@)
+   OVSDB_CHECK_IDL_PY($@)
+   OVSDB_CHECK_IDL_TCP_PY($@)
+   OVSDB_CHECK_IDL_TCP6_PY($@)])
+
 OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
   [],
   [],
@@ -51,7 +120,7 @@ OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
                "ia": ["set", [1, 2, 3]],
                "ra": ["set", [-0.5]],
                "ba": ["set", [true]],
-               "sa": ["set", ["abc", "def"]], 
+               "sa": ["set", ["abc", "def"]],
                "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
                               ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
       {"op": "insert",
@@ -77,7 +146,7 @@ OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
                "ia": ["set", [1]],
                "ra": ["set", [1.5]],
                "ba": ["set", [false]],
-               "sa": ["set", []], 
+               "sa": ["set", []],
                "ua": ["set", []]}}]' \
     '["idltest",
       {"op": "update",
@@ -128,7 +197,7 @@ OVSDB_CHECK_IDL([simple idl, initially populated],
                "ia": ["set", [1, 2, 3]],
                "ra": ["set", [-0.5]],
                "ba": ["set", [true]],
-               "sa": ["set", ["abc", "def"]], 
+               "sa": ["set", ["abc", "def"]],
                "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
                               ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
       {"op": "insert",
@@ -159,7 +228,7 @@ OVSDB_CHECK_IDL([simple idl, writing via IDL],
                "ia": ["set", [1, 2, 3]],
                "ra": ["set", [-0.5]],
                "ba": ["set", [true]],
-               "sa": ["set", ["abc", "def"]], 
+               "sa": ["set", ["abc", "def"]],
                "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
                               ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
       {"op": "insert",
@@ -214,13 +283,41 @@ OVSDB_CHECK_IDL([simple idl, increment operation],
       {"op": "insert",
        "table": "simple",
        "row": {}}]']],
-  [['set 0 r 2.0, increment simple i']],
+  [['set 0 r 2.0, increment 0']],
   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
 001: commit, status=success, increment=1
 002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
 003: done
 ]])
 
+OVSDB_CHECK_IDL([simple idl, aborting],
+  [['["idltest",
+      {"op": "insert",
+       "table": "simple",
+       "row": {}}]']],
+  [['set 0 r 2.0, abort' \
+'+set 0 b 1']],
+  [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
+001: commit, status=aborted
+002: commit, status=success
+003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
+004: done
+]])
+
+OVSDB_CHECK_IDL([simple idl, destroy without commit or abort],
+  [['["idltest",
+      {"op": "insert",
+       "table": "simple",
+       "row": {}}]']],
+  [['set 0 r 2.0, destroy' \
+'+set 0 b 1']],
+  [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
+001: destroy
+002: commit, status=success
+003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
+004: done
+]])
+
 OVSDB_CHECK_IDL([self-linking idl, consistent ops],
   [],
   [['["idltest",
@@ -380,3 +477,22 @@ OVSDB_CHECK_IDL([external-linking idl, consistent ops],
 002: i=1 k=1 ka=[] l2=0 uuid=<1>
 003: done
 ]])
+
+OVSDB_CHECK_IDL_PY([external-linking idl, insert ops],
+  [],
+  [['linktest']],
+  [[000: empty
+001: commit, status=success
+002: i=1 k=1 ka=[1] l2= uuid=<0>
+002: i=2 k=1 ka=[1 2] l2= uuid=<1>
+003: done
+]])
+
+OVSDB_CHECK_IDL_PY([getattr idl, insert ops],
+  [],
+  [['getattrtest']],
+  [[000: empty
+001: commit, status=success
+002: i=2 k=2 ka=[] l2= uuid=<0>
+003: done
+]])