|
@@ -213,6 +213,42 @@ _graph_remove (LSUP_StoreType type)
|
|
|
}
|
|
|
|
|
|
|
|
|
+static int
|
|
|
+_graph_txn (LSUP_StoreType type)
|
|
|
+{
|
|
|
+ const LSUP_StoreInt *sif = LSUP_store_int (type);
|
|
|
+ if (!(sif->features & LSUP_STORE_TXN)) return 0;
|
|
|
+
|
|
|
+ if (sif->setup_fn) sif->setup_fn (NULL, true);
|
|
|
+
|
|
|
+ LSUP_Triple *trp = create_triples();
|
|
|
+
|
|
|
+ LSUP_Graph *gr = LSUP_graph_new (
|
|
|
+ LSUP_iriref_new (NULL, NULL), type, NULL, NULL, 0);
|
|
|
+
|
|
|
+ void *txn;
|
|
|
+ size_t ct;
|
|
|
+
|
|
|
+ EXPECT_PASS (LSUP_graph_begin (gr, 0, &txn));
|
|
|
+ EXPECT_PASS (LSUP_graph_add_txn (txn, gr, trp, &ct));
|
|
|
+ LSUP_graph_abort (gr, txn);
|
|
|
+
|
|
|
+ // NOTE that ct reports the count before the txn was aborted. This is
|
|
|
+ // intentional.
|
|
|
+ EXPECT_INT_EQ (ct, 8);
|
|
|
+ EXPECT_INT_EQ (LSUP_graph_size (gr), 0);
|
|
|
+
|
|
|
+ EXPECT_PASS (LSUP_graph_begin (gr, 0, &txn));
|
|
|
+ EXPECT_PASS (LSUP_graph_add_txn (txn, gr, trp, &ct));
|
|
|
+ LSUP_graph_commit (gr, txn);
|
|
|
+
|
|
|
+ EXPECT_INT_EQ (ct, 8);
|
|
|
+ EXPECT_INT_EQ (LSUP_graph_size (gr), 8);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
static int
|
|
|
test_environment()
|
|
|
{
|
|
@@ -276,6 +312,20 @@ BACKEND_TBL
|
|
|
}
|
|
|
|
|
|
|
|
|
+static int test_graph_txn()
|
|
|
+{
|
|
|
+ /*
|
|
|
+ * Test transactions only if the backend supports them.
|
|
|
+ */
|
|
|
+#define ENTRY(a, b) \
|
|
|
+ if (_graph_txn (LSUP_STORE_##a) != 0) return -1;
|
|
|
+BACKEND_TBL
|
|
|
+#undef ENTRY
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
static int test_graph_copy()
|
|
|
{
|
|
|
LSUP_Triple *trp = create_triples();
|
|
@@ -329,6 +379,7 @@ int graph_tests()
|
|
|
RUN (test_graph_lookup);
|
|
|
RUN (test_graph_remove);
|
|
|
RUN (test_graph_copy);
|
|
|
+ RUN (test_graph_txn);
|
|
|
|
|
|
return 0;
|
|
|
}
|