1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/bigfile.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,193 @@
1.4 +# 2002 November 30
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library. The
1.15 +# focus of this script testing the ability of SQLite to handle database
1.16 +# files larger than 4GB.
1.17 +#
1.18 +# $Id: bigfile.test,v 1.10 2007/08/18 10:59:21 danielk1977 Exp $
1.19 +#
1.20 +
1.21 +set testdir [file dirname $argv0]
1.22 +source $testdir/tester.tcl
1.23 +
1.24 +# If SQLITE_DISABLE_LFS is defined, omit this file.
1.25 +ifcapable !lfs {
1.26 + finish_test
1.27 + return
1.28 +}
1.29 +
1.30 +# These tests only work for Tcl version 8.4 and later. Prior to 8.4,
1.31 +# Tcl was unable to handle large files.
1.32 +#
1.33 +scan $::tcl_version %f vx
1.34 +if {$vx<8.4} return
1.35 +
1.36 +# Mac OS X does not handle large files efficiently. So skip this test
1.37 +# on that platform.
1.38 +if {$tcl_platform(os)=="Darwin"} return
1.39 +
1.40 +# This is the md5 checksum of all the data in table t1 as created
1.41 +# by the first test. We will use this number to make sure that data
1.42 +# never changes.
1.43 +#
1.44 +set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}
1.45 +
1.46 +do_test bigfile-1.1 {
1.47 + execsql {
1.48 + BEGIN;
1.49 + CREATE TABLE t1(x);
1.50 + INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');
1.51 + INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
1.52 + INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
1.53 + INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
1.54 + INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
1.55 + INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
1.56 + INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
1.57 + INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
1.58 + COMMIT;
1.59 + }
1.60 + execsql {
1.61 + SELECT md5sum(x) FROM t1;
1.62 + }
1.63 +} $::MAGIC_SUM
1.64 +
1.65 +# Try to create a large file - a file that is larger than 2^32 bytes.
1.66 +# If this fails, it means that the system being tested does not support
1.67 +# large files. So skip all of the remaining tests in this file.
1.68 +#
1.69 +db close
1.70 +if {[catch {fake_big_file 4096 test.db} msg]} {
1.71 + puts "**** Unable to create a file larger than 4096 MB. *****"
1.72 + puts "$msg"
1.73 + finish_test
1.74 + return
1.75 +}
1.76 +
1.77 +do_test bigfile-1.2 {
1.78 + sqlite3 db test.db
1.79 + execsql {
1.80 + SELECT md5sum(x) FROM t1;
1.81 + }
1.82 +} $::MAGIC_SUM
1.83 +
1.84 +# The previous test may fail on some systems because they are unable
1.85 +# to handle large files. If that is so, then skip all of the following
1.86 +# tests. We will know the above test failed because the "db" command
1.87 +# does not exist.
1.88 +#
1.89 +if {[llength [info command db]]>0} {
1.90 +
1.91 +do_test bigfile-1.3 {
1.92 + execsql {
1.93 + CREATE TABLE t2 AS SELECT * FROM t1;
1.94 + SELECT md5sum(x) FROM t2;
1.95 + }
1.96 +} $::MAGIC_SUM
1.97 +do_test bigfile-1.4 {
1.98 + db close
1.99 + sqlite3 db test.db
1.100 + execsql {
1.101 + SELECT md5sum(x) FROM t1;
1.102 + }
1.103 +} $::MAGIC_SUM
1.104 +do_test bigfile-1.5 {
1.105 + execsql {
1.106 + SELECT md5sum(x) FROM t2;
1.107 + }
1.108 +} $::MAGIC_SUM
1.109 +
1.110 +db close
1.111 +if {[catch {fake_big_file 8192 test.db}]} {
1.112 + puts "**** Unable to create a file larger than 8192 MB. *****"
1.113 + finish_test
1.114 + return
1.115 +}
1.116 +
1.117 +do_test bigfile-1.6 {
1.118 + sqlite3 db test.db
1.119 + execsql {
1.120 + SELECT md5sum(x) FROM t1;
1.121 + }
1.122 +} $::MAGIC_SUM
1.123 +do_test bigfile-1.7 {
1.124 + execsql {
1.125 + CREATE TABLE t3 AS SELECT * FROM t1;
1.126 + SELECT md5sum(x) FROM t3;
1.127 + }
1.128 +} $::MAGIC_SUM
1.129 +do_test bigfile-1.8 {
1.130 + db close
1.131 + sqlite3 db test.db
1.132 + execsql {
1.133 + SELECT md5sum(x) FROM t1;
1.134 + }
1.135 +} $::MAGIC_SUM
1.136 +do_test bigfile-1.9 {
1.137 + execsql {
1.138 + SELECT md5sum(x) FROM t2;
1.139 + }
1.140 +} $::MAGIC_SUM
1.141 +do_test bigfile-1.10 {
1.142 + execsql {
1.143 + SELECT md5sum(x) FROM t3;
1.144 + }
1.145 +} $::MAGIC_SUM
1.146 +
1.147 +db close
1.148 +if {[catch {fake_big_file 16384 test.db}]} {
1.149 + puts "**** Unable to create a file larger than 16384 MB. *****"
1.150 + finish_test
1.151 + return
1.152 +}
1.153 +
1.154 +do_test bigfile-1.11 {
1.155 + sqlite3 db test.db
1.156 + execsql {
1.157 + SELECT md5sum(x) FROM t1;
1.158 + }
1.159 +} $::MAGIC_SUM
1.160 +do_test bigfile-1.12 {
1.161 + execsql {
1.162 + CREATE TABLE t4 AS SELECT * FROM t1;
1.163 + SELECT md5sum(x) FROM t4;
1.164 + }
1.165 +} $::MAGIC_SUM
1.166 +do_test bigfile-1.13 {
1.167 + db close
1.168 + sqlite3 db test.db
1.169 + execsql {
1.170 + SELECT md5sum(x) FROM t1;
1.171 + }
1.172 +} $::MAGIC_SUM
1.173 +do_test bigfile-1.14 {
1.174 + execsql {
1.175 + SELECT md5sum(x) FROM t2;
1.176 + }
1.177 +} $::MAGIC_SUM
1.178 +do_test bigfile-1.15 {
1.179 + execsql {
1.180 + SELECT md5sum(x) FROM t3;
1.181 + }
1.182 +} $::MAGIC_SUM
1.183 +do_test bigfile-1.16 {
1.184 + execsql {
1.185 + SELECT md5sum(x) FROM t3;
1.186 + }
1.187 +} $::MAGIC_SUM
1.188 +do_test bigfile-1.17 {
1.189 + execsql {
1.190 + SELECT md5sum(x) FROM t4;
1.191 + }
1.192 +} $::MAGIC_SUM
1.193 +
1.194 +} ;# End of the "if( db command exists )"
1.195 +
1.196 +finish_test