pkubat / rpms / sqlite

Forked from rpms/sqlite 4 years ago
Clone
Blob Blame History Raw
Index: test/walro2.test
==================================================================
--- test/walro2.test
+++ test/walro2.test
@@ -37,10 +37,22 @@
   } else {
     forcecopy test.db-shm test.db2-shm
   }
 }
 
+# Most systems allocate the *-shm file in 32KB trunks. But on UNIX systems
+# for which the getpagesize() call returns greater than 32K, the *-shm
+# file is allocated in page-sized units (since you cannot mmap part of
+# a page). The following code sets variable $MINSHMSZ to the smallest
+# possible *-shm file (i.e. the greater of 32KB and the system page-size).
+#
+do_execsql_test 0.0 {
+  PRAGMA journal_mode = wal;
+  CREATE TABLE t1(x);
+} {wal}
+set MINSHMSZ [file size test.db-shm]
+
 foreach bZeroShm {0 1} {
 set TN [expr $bZeroShm+1]
 do_multiclient_test tn {
   
   # Close all connections and delete the database.
@@ -167,11 +179,11 @@
     code2 { db2 close }
     sql1 { SELECT * FROM t1 }
   } {a b c d e f g h 1 2}
   do_test $TN.3.2.2 {
     list [file size test.db-wal] [file size test.db-shm]
-  } {0 32768}
+  } [list 0 $MINSHMSZ]
 
   do_test $TN.3.3.0 {
     code2 { sqlite3 db2 test.db }
     sql2 { 
       INSERT INTO t1 VALUES(3, 4);
@@ -180,11 +192,11 @@
       INSERT INTO t1 VALUES(9, 10);
     }
     code2 { db2 close }
     code1 { db close }
     list [file size test.db-wal] [file size test.db-shm]
-  } [list [wal_file_size 4 1024] 32768]
+  } [list [wal_file_size 4 1024] $MINSHMSZ]
   do_test $TN.3.3.1 {
     code1 { sqlite3 db file:test.db?readonly_shm=1 }
     sql1 { SELECT * FROM t1 }
   } {a b c d e f g h 1 2 3 4 5 6 7 8 9 10}
   do_test $TN.3.3.2 {
@@ -194,11 +206,11 @@
       DELETE FROM t1;
       INSERT INTO t1 VALUES('i', 'ii');
     }
     code2 { db2 close }
     list [file size test.db-wal] [file size test.db-shm]
-  } [list [wal_file_size 4 1024] 32768]
+  } [list [wal_file_size 4 1024] $MINSHMSZ]
   do_test $TN.3.3.3 {
     sql1 { SELECT * FROM t1 }
   } {i ii}
 
   #-----------------------------------------------------------------------