Browse Source

Remove DB BEFORE starting test; small fixes.

Stefano Cossu 4 years ago
parent
commit
0746b5939e
4 changed files with 23 additions and 7 deletions
  1. 4 0
      include/store_mdb.h
  2. 0 2
      src/store_mdb.c
  3. 5 0
      src/term.c
  4. 14 5
      test/test_store_mdb.c

+ 4 - 0
include/store_mdb.h

@@ -11,6 +11,10 @@
  * per session. Within that session multiple R/W operations can be performed
  * using transactions.
  *
+ * Note that, even though the terms "graph", "context", etc. are used, no code
+ * in this module checks for valid RDF data. In theory any term can be any
+ * binary data. This allows using the store for non-RDF graph data.
+ *
  * TODO more doc
  */
 

+ 0 - 2
src/store_mdb.c

@@ -624,8 +624,6 @@ LSUP_store_free(LSUP_MDBStore *store)
 
     if (store->default_ctx != NULL) LSUP_buffer_done(store->default_ctx);
 
-    mdb_env_close(store->env);
-
     free(store);
 }
 

+ 5 - 0
src/term.c

@@ -7,6 +7,11 @@ static regex_t ptn;
 static bool ptn_init = false;
 
 
+/* Global inline prototypes. */
+
+LSUP_Term * LSUP_uri_new(const char *data);
+
+
 /**
  * Free global regex struct. Register with atexit().
  */

+ 14 - 5
test/test_store_mdb.c

@@ -6,18 +6,27 @@
 #include "assets.h"
 
 
+static char *path = "/tmp/testdb";
+
+
 static void rmdb() {
-    remove("/tmp/testdb/data.mdb");
-    remove("/tmp/testdb/lock.mdb");
-    remove("/tmp/testdb");
+    char data_path[32], lock_path[32];
+    sprintf(data_path, "%s/data.mdb", path);
+    sprintf(lock_path, "%s/lock.mdb", path);
+    printf("Removing %s\n", data_path);
+    remove(data_path);
+    printf("Removing %s\n", lock_path);
+    remove(lock_path);
+    remove(path);
 }
 
 
+/** @brief Test triple store.
+ */
 static int test_triple_store()
 {
-    char *path = "/tmp/testdb";
+    rmdb();
     EXPECT_PASS(LSUP_store_setup(&path));
-    atexit(rmdb);
 
     LSUP_MDBStore *store;
     store = LSUP_store_new(path, NULL); // triple store.