os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/mallocA.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# 2007 April 30
sl@0
     2
#
sl@0
     3
# The author disclaims copyright to this source code.  In place of
sl@0
     4
# a legal notice, here is a blessing:
sl@0
     5
#
sl@0
     6
#    May you do good and not evil.
sl@0
     7
#    May you find forgiveness for yourself and forgive others.
sl@0
     8
#    May you share freely, never taking more than you give.
sl@0
     9
#
sl@0
    10
#***********************************************************************
sl@0
    11
# This file contains additional out-of-memory checks (see malloc.tcl).
sl@0
    12
#
sl@0
    13
# $Id: mallocA.test,v 1.8 2008/02/18 22:24:58 drh Exp $
sl@0
    14
sl@0
    15
set testdir [file dirname $argv0]
sl@0
    16
source $testdir/tester.tcl
sl@0
    17
source $testdir/malloc_common.tcl
sl@0
    18
sl@0
    19
# Only run these tests if memory debugging is turned on.
sl@0
    20
#
sl@0
    21
if {!$MEMDEBUG} {
sl@0
    22
   puts "Skipping mallocA tests: not compiled with -DSQLITE_MEMDEBUG..."
sl@0
    23
   finish_test
sl@0
    24
   return
sl@0
    25
}
sl@0
    26
sl@0
    27
sl@0
    28
# Construct a test database
sl@0
    29
#
sl@0
    30
file delete -force test.db.bu
sl@0
    31
db eval {
sl@0
    32
  CREATE TABLE t1(a COLLATE NOCASE,b,c);
sl@0
    33
  INSERT INTO t1 VALUES(1,2,3);
sl@0
    34
  INSERT INTO t1 VALUES(1,2,4);
sl@0
    35
  INSERT INTO t1 VALUES(2,3,4);
sl@0
    36
  CREATE INDEX t1i1 ON t1(a);
sl@0
    37
  CREATE INDEX t1i2 ON t1(b,c);
sl@0
    38
  CREATE TABLE t2(x,y,z);
sl@0
    39
}
sl@0
    40
db close
sl@0
    41
file copy test.db test.db.bu
sl@0
    42
sl@0
    43
sl@0
    44
do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody {
sl@0
    45
  ANALYZE
sl@0
    46
}
sl@0
    47
do_malloc_test mallocA-1.1 -testdb test.db.bu -sqlbody {
sl@0
    48
  ANALYZE t1
sl@0
    49
}
sl@0
    50
do_malloc_test mallocA-1.2 -testdb test.db.bu -sqlbody {
sl@0
    51
  ANALYZE main
sl@0
    52
}
sl@0
    53
do_malloc_test mallocA-1.3 -testdb test.db.bu -sqlbody {
sl@0
    54
  ANALYZE main.t1
sl@0
    55
}
sl@0
    56
ifcapable reindex {
sl@0
    57
  do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody {
sl@0
    58
    REINDEX;
sl@0
    59
  }
sl@0
    60
  do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody {
sl@0
    61
    REINDEX t1;
sl@0
    62
  }
sl@0
    63
  do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody {
sl@0
    64
    REINDEX main.t1;
sl@0
    65
  }
sl@0
    66
  do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody {
sl@0
    67
    REINDEX nocase;
sl@0
    68
  }
sl@0
    69
}
sl@0
    70
sl@0
    71
# Ensure that no file descriptors were leaked.
sl@0
    72
do_test malloc-99.X {
sl@0
    73
  catch {db close}
sl@0
    74
  set sqlite_open_file_count
sl@0
    75
} {0}
sl@0
    76
sl@0
    77
file delete -force test.db.bu
sl@0
    78
finish_test