summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-06-20 16:17:44 -0700
committerBen Pfaff <blp@nicira.com>2011-06-21 15:09:56 -0700
commit2096903b45d28594c04b47b592a5b7e62b5e1ccc (patch)
treee73d3727fbb85a584f4a9c49476f92f97338df99 /tests
parente2eed6a7581193da43210a26ad182fb2a697eaf5 (diff)
downloadopenvswitch-2096903b45d28594c04b47b592a5b7e62b5e1ccc.tar.gz
ovsdb-idl: Plug hole in state machine.
The state machine didn't have a proper state for "not yet committed or aborted", which meant that destroying an ovsdb_idl_txn without committing or aborting it caused a segfault. This fixes the problem by adding a new state TXN_UNCOMMITTED to the state machine. This is related to commit 79554078d "ovsdb-idl: Fix bad logic in ovsdb_idl_txn_commit() state transitions", which fixed a related bug. Bug #2438.
Diffstat (limited to 'tests')
-rw-r--r--tests/ovsdb-idl.at28
-rw-r--r--tests/test-ovsdb.c7
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index 5956f72db..f9c8286f7 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -221,6 +221,34 @@ OVSDB_CHECK_IDL([simple idl, increment operation],
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",
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index 5594b40f0..e8d87b6c5 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -1828,6 +1828,13 @@ idl_set(struct ovsdb_idl *idl, char *commands, int step)
}
ovsdb_idl_txn_increment(txn, arg1, arg2, NULL);
increment = true;
+ } else if (!strcmp(name, "abort")) {
+ ovsdb_idl_txn_abort(txn);
+ break;
+ } else if (!strcmp(name, "destroy")) {
+ printf("%03d: destroy\n", step);
+ ovsdb_idl_txn_destroy(txn);
+ return;
} else {
ovs_fatal(0, "unknown command %s", name);
}