chiark / gitweb /
working on testing cdb-wr
authorian <ian>
Thu, 30 Mar 2006 00:38:35 +0000 (00:38 +0000)
committerian <ian>
Thu, 30 Mar 2006 00:38:35 +0000 (00:38 +0000)
cdb/.cvsignore
cdb/tests [new file with mode: 0755]
cdb/writeable.c

index 67f5c18d771e0e8a5c8eaad07726bf7c915f430f..57f8c52386b416be8e5c1d9880723624d8953825 100644 (file)
@@ -1,3 +1,4 @@
 *+tcmdif.*
 *.d
 a.out
+vgcore.*
diff --git a/cdb/tests b/cdb/tests
new file mode 100755 (executable)
index 0000000..45c9061
--- /dev/null
+++ b/cdb/tests
@@ -0,0 +1,23 @@
+#!/usr/bin/tclsh8.3
+
+proc addpath {p before after default} {
+    upvar #0 env($p) lc
+    if {[info exists lc]} {
+       set l [split $lc :]
+    } else {
+       set l $default
+    }
+    set l [append $before $l $after]
+    set lc [join $l :]
+}
+
+addpath LD_LIBRARY_PATH {../base ../hbytes} {} {}
+
+load ./chiark_tcl_cdb.so
+
+#
+# CURRENTLY TESTING WITH
+#  rm -f test-out.*
+#  LD_LIBRARY_PATH=../base:../hbytes:. ../../sauce/convertdb test-out 0 db.addr-list.main db.addr-list.log 
+#  LD_LIBRARY_PATH=../base:../hbytes:. strace ../../sauce/convertdb test-out 0 db.addr-list.main db.addr-list.log 
+#  LD_LIBRARY_PATH=../base:../hbytes:. valgrind --db-attach=yes tclsh8.3 ../../sauce/convertdb test-out 0 db.addr-list.main db.addr-list.log 
index 2b7adcc486fa1ada9e41336e2d4aa9cc12c1cd0b..cf9a65e11dfe0319068000d145c0f7f5bb501064 100644 (file)
@@ -23,14 +23,13 @@ typedef struct Pathbuf {
   char *buf, *sfx;
 } Pathbuf;
 
-#define MAX_SUFFIX 4
+#define MAX_SUFFIX 5
 
 static void pathbuf_init(Pathbuf *pb, const char *pathb) {
   int l= strlen(pathb);
-  pb->buf= TALLOC(l + 4);
+  pb->buf= TALLOC(l + MAX_SUFFIX + 1);
   memcpy(pb->buf, pathb, l);
   pb->sfx= pb->buf + l;
-  *pb->sfx++= '.';
 }
 static const char *pathbuf_sfx(Pathbuf *pb, const char *suffix) {
   assert(strlen(suffix) <= MAX_SUFFIX);
@@ -191,7 +190,7 @@ static int acquire_lock(Tcl_Interp *ip, Pathbuf *pb, int *lockfd_r) {
   /* Remove r where umask would remove w;
    * eg umask intending 0664 here gives 0660 */
   
-  *lockfd_r= open(pathbuf_sfx(pb,".lock"), O_RDONLY|O_CREAT, lockmode);
+  *lockfd_r= open(pathbuf_sfx(pb,".lock"), O_RDWR|O_CREAT, lockmode);
   if (*lockfd_r < 0)
     return cht_posixerr(ip, errno, "could not open/create lockfile");