xref: /sqlite-3.40.0/test/fallocate.test (revision 6e09d69c)
1# 2010 July 28
2#
3# The author disclaims copyright to this source code.  In place of
4# a legal notice, here is a blessing:
5#
6#    May you do good and not evil.
7#    May you find forgiveness for yourself and forgive others.
8#    May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15
16if {$::tcl_platform(platform)!="unix"} {
17  finish_test
18  return
19}
20
21file_control_chunksize_test db main [expr 1024*1024]
22
23do_test fallocate-1.1 {
24  execsql {
25    PRAGMA page_size = 1024;
26    PRAGMA auto_vacuum = 1;
27    CREATE TABLE t1(a, b);
28  }
29  file size test.db
30} [expr 1*1024*1024]
31
32do_test fallocate-1.2 {
33  execsql { INSERT INTO t1 VALUES(1, zeroblob(1024*900)) }
34  file size test.db
35} [expr 1*1024*1024]
36
37do_test fallocate-1.3 {
38  execsql { INSERT INTO t1 VALUES(2, zeroblob(1024*900)) }
39  file size test.db
40} [expr 2*1024*1024]
41
42do_test fallocate-1.4 {
43  execsql { DELETE FROM t1 WHERE a = 1 }
44  file size test.db
45} [expr 1*1024*1024]
46
47do_test fallocate-1.5 {
48  execsql { DELETE FROM t1 WHERE a = 2 }
49  file size test.db
50} [expr 1*1024*1024]
51
52do_test fallocate-1.6 {
53  execsql { PRAGMA freelist_count }
54} {0}
55
56finish_test
57