/ Check-in [562687d9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Modify a few test scripts to avoid leaving the sqlite3Config structure in a non-default state.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 562687d9f56bf4bb0f5f07f97cbbb7649c81faf8
User & Date: dan 2015-07-24 14:17:17
References
2015-07-24
18:22
Fix a test script bug introduced by [562687d9]. check-in: a343745d user: dan tags: trunk
Context
2015-07-24
15:49
More robust handling of zeroblob() with oversized arguments. Fix fuzzcheck so that it can be run with limited heap memory. check-in: 4e3e516a user: drh tags: trunk
14:17
Modify a few test scripts to avoid leaving the sqlite3Config structure in a non-default state. check-in: 562687d9 user: dan tags: trunk
00:02
Update RBU description comment in the header file. No changes to code. check-in: 119883a2 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_malloc.c.

   935    935   static int test_config_pagecache(
   936    936     void * clientData,
   937    937     Tcl_Interp *interp,
   938    938     int objc,
   939    939     Tcl_Obj *CONST objv[]
   940    940   ){
   941    941     int sz, N, rc;
   942         -  Tcl_Obj *pResult;
          942  +  Tcl_Obj *pRes;
   943    943     static char *buf = 0;
   944    944     if( objc!=3 ){
   945    945       Tcl_WrongNumArgs(interp, 1, objv, "SIZE N");
   946    946       return TCL_ERROR;
   947    947     }
   948    948     if( Tcl_GetIntFromObj(interp, objv[1], &sz) ) return TCL_ERROR;
   949    949     if( Tcl_GetIntFromObj(interp, objv[2], &N) ) return TCL_ERROR;
   950    950     free(buf);
          951  +  buf = 0;
          952  +
          953  +  /* Set the return value */
          954  +  pRes = Tcl_NewObj();
          955  +  Tcl_ListObjAppendElement(0, pRes, Tcl_NewIntObj(sqlite3GlobalConfig.szPage));
          956  +  Tcl_ListObjAppendElement(0, pRes, Tcl_NewIntObj(sqlite3GlobalConfig.nPage));
          957  +  Tcl_SetObjResult(interp, pRes);
          958  +
   951    959     if( sz<0 ){
   952         -    buf = 0;
   953    960       rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, 0, 0, 0);
   954    961     }else{
   955    962       buf = malloc( sz*N );
   956    963       rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, buf, sz, N);
   957    964     }
   958         -  pResult = Tcl_NewObj();
   959         -  Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(rc));
   960         -  Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(N));
   961         -  Tcl_SetObjResult(interp, pResult);
   962    965     return TCL_OK;
   963    966   }
   964    967   
   965    968   /*
   966    969   ** Usage:    sqlite3_config_alt_pcache INSTALL_FLAG DISCARD_CHANCE PRNG_SEED
   967    970   **
   968    971   ** Set up the alternative test page cache.  Install if INSTALL_FLAG is

Changes to test/fuzz3.test.

    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # These tests deal with corrupt database files
    22     22   #
    23     23   database_may_be_corrupt
    24         -db close
    25         -sqlite3_shutdown
    26         -sqlite3_config_pagecache 0 0
    27         -sqlite3_initialize
    28         -autoinstall_test_functions
    29         -sqlite3 db test.db
           24  +test_set_config_pagecache 0 0
    30     25   
    31     26   
    32     27   expr srand(123)
    33     28   
    34     29   proc rstring {n} {
    35     30     set str s
    36     31     while {[string length $str] < $n} {
................................................................................
   172    167     purge_pcache
   173    168     modify_database $iOld
   174    169     do_test fuzz3-$ii.$iNew.[incr iTest] {
   175    170       db_checksum
   176    171     } $::cksum
   177    172   }
   178    173   
          174  +test_restore_config_pagecache
   179    175   finish_test
          176  +

Changes to test/lookaside.test.

    25     25   # connection is opened. This will not work if there is any "presql"
    26     26   # configured (SQL run within the [sqlite3] wrapper in tester.tcl).
    27     27   if {[info exists ::G(perm:presql)]} {
    28     28     finish_test
    29     29     return
    30     30   }
    31     31   
           32  +test_set_config_pagecache 0 0
           33  +
    32     34   catch {db close}
    33     35   sqlite3_shutdown
    34         -sqlite3_config_pagecache 0 0
    35     36   sqlite3_config_scratch 0 0
    36     37   sqlite3_initialize
    37     38   autoinstall_test_functions
    38     39   sqlite3 db test.db
    39     40   
    40     41   # Make sure sqlite3_db_config() and sqlite3_db_status are working.
    41     42   #
................................................................................
   125    126     db close
   126    127     sqlite3_shutdown
   127    128     catch sqlite3_config_error
   128    129   } {0}
   129    130   sqlite3_initialize
   130    131   autoinstall_test_functions
   131    132   
          133  +test_restore_config_pagecache
   132    134   finish_test

Changes to test/malloc5.test.

    16     16   # the configured soft heap limit could cause sqlite to upgrade database 
    17     17   # locks and flush dirty pages to the file system. As of 3.6.2, this is
    18     18   # no longer the case. In version 3.6.2, sqlite3_release_memory() only
    19     19   # reclaims clean pages. This test file has been updated accordingly.
    20     20   #
    21     21   # $Id: malloc5.test,v 1.22 2009/04/11 19:09:54 drh Exp $
    22     22   
    23         -sqlite3_shutdown
    24         -sqlite3_config_pagecache 0 100
    25         -sqlite3_initialize
    26         -autoinstall_test_functions
    27         -
    28     23   set testdir [file dirname $argv0]
    29     24   source $testdir/tester.tcl
    30     25   source $testdir/malloc_common.tcl
    31     26   db close
    32     27   
    33     28   # Only run these tests if memory debugging is turned on.
    34     29   #
................................................................................
    39     34   }
    40     35   
    41     36   # Skip these tests if OMIT_MEMORY_MANAGEMENT was defined at compile time.
    42     37   ifcapable !memorymanage {
    43     38      finish_test
    44     39      return
    45     40   }
           41  +
           42  +test_set_config_pagecache 0 100
    46     43   
    47     44   sqlite3_soft_heap_limit 0
    48     45   sqlite3 db test.db
    49     46   db eval {PRAGMA cache_size=1}
    50     47   
    51     48   do_test malloc5-1.1 {
    52     49     # Simplest possible test. Call sqlite3_release_memory when there is exactly
................................................................................
   411    408     sqlite3_release_memory 31459
   412    409     list [nPage db] [nPage db2]
   413    410   } {1 3}
   414    411   
   415    412   db2 close
   416    413   
   417    414   sqlite3_soft_heap_limit $::soft_limit
          415  +test_restore_config_pagecache
   418    416   finish_test
   419    417   catch {db close}

Changes to test/memsubsys1.test.

    20     20   # by default when a new database connection is opened. As a result, it
    21     21   # will not work with the "memsubsys1" permutation.
    22     22   #
    23     23   if {[permutation] == "memsubsys1"} {
    24     24     finish_test
    25     25     return
    26     26   }
           27  +
           28  +test_set_config_pagecache 0 0
    27     29   
    28     30   # This procedure constructs a new database in test.db.  It fills
    29     31   # this database with many small records (enough to force multiple
    30     32   # rebalance operations in the btree-layer and to require a large
    31     33   # page cache), verifies correct results, then returns.
    32     34   #
    33     35   proc build_test_db {testname pragmas} {
................................................................................
   306    308     }
   307    309   } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
   308    310   
   309    311   
   310    312   db close
   311    313   sqlite3_shutdown
   312    314   sqlite3_config_memstatus 1
   313         -sqlite3_config_pagecache 0 0
   314    315   sqlite3_config_scratch 0 0
   315    316   sqlite3_config_lookaside 100 500
   316    317   sqlite3_config serialized
   317    318   sqlite3_initialize
   318    319   autoinstall_test_functions
          320  +
          321  +test_restore_config_pagecache
   319    322   finish_test

Changes to test/pcache2.test.

    11     11   #
    12     12   # This file is focused on testing the pcache module.
    13     13   #
    14     14   # $Id: pcache2.test,v 1.5 2009/07/18 14:36:24 danielk1977 Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
           18  +
           19  +test_set_config_pagecache 0 0
    18     20   
    19     21   # Set up a pcache memory pool so that we can easily track how many
    20     22   # pages are being used for cache.
    21     23   #
    22     24   do_test pcache2-1.1 {
    23     25     db close
    24     26     sqlite3_reset_auto_extension
................................................................................
    74     76   sqlite3_reset_auto_extension
    75     77   sqlite3_shutdown
    76     78   sqlite3_config_pagecache 0 0
    77     79   sqlite3_config serialized
    78     80   sqlite3_initialize
    79     81   autoinstall_test_functions
    80     82   
           83  +test_restore_config_pagecache
    81     84   finish_test

Changes to test/permutations.test.

   413    413   # causes the effective limit on the page-cache to be just 24 pages.
   414    414   #
   415    415   test_suite "memsubsys1" -description {
   416    416     Tests using pre-allocated page and scratch blocks
   417    417   } -files [
   418    418     test_set $::allquicktests -exclude ioerr5.test malloc5.test mmap1.test
   419    419   ] -initialize {
          420  +  test_set_config_pagecache 4096 24
   420    421     catch {db close}
   421    422     sqlite3_shutdown
   422         -  sqlite3_config_pagecache 4096 24
   423    423     sqlite3_config_scratch 25000 1
   424    424     sqlite3_initialize
   425    425     autoinstall_test_functions
   426    426   } -shutdown {
          427  +  test_restore_config_pagecache
   427    428     catch {db close}
   428    429     sqlite3_shutdown
   429         -  sqlite3_config_pagecache 0 0
   430    430     sqlite3_config_scratch 0 0
   431    431     sqlite3_initialize
   432    432     autoinstall_test_functions
   433    433   }
   434    434   
   435    435   # Run some tests using pre-allocated page and scratch blocks. This time
   436    436   # the allocations are too small to use in most cases.
................................................................................
   440    440   # This functionality is disabled if a pre-allocated page block is provided.
   441    441   #
   442    442   test_suite "memsubsys2" -description {
   443    443     Tests using small pre-allocated page and scratch blocks
   444    444   } -files [
   445    445     test_set $::allquicktests -exclude ioerr5.test malloc5.test
   446    446   ] -initialize {
          447  +  test_set_config_pagecache 512 5
   447    448     catch {db close}
   448    449     sqlite3_shutdown
   449         -  sqlite3_config_pagecache 512 5
   450    450     sqlite3_config_scratch 1000 1
   451    451     sqlite3_initialize
   452    452     autoinstall_test_functions
   453    453   } -shutdown {
          454  +  test_restore_config_pagecache
   454    455     catch {db close}
   455    456     sqlite3_shutdown
   456         -  sqlite3_config_pagecache 0 0
   457    457     sqlite3_config_scratch 0 0
   458    458     sqlite3_initialize
   459    459     autoinstall_test_functions
   460    460   }
   461    461   
   462    462   # Run all tests with the lookaside allocator disabled.
   463    463   #

Changes to test/tester.tcl.

  2036   2036     sqlite3 db $dbfile
  2037   2037   }
  2038   2038   proc db_delete_and_reopen {{file test.db}} {
  2039   2039     catch { db close }
  2040   2040     foreach f [glob -nocomplain test.db*] { forcedelete $f }
  2041   2041     sqlite3 db $file
  2042   2042   }
         2043  +
         2044  +# Close any connections named [db], [db2] or [db3]. Then use sqlite3_config
         2045  +# to configure the size of the PAGECACHE allocation using the parameters
         2046  +# provided to this command. Save the old PAGECACHE parameters in a global 
         2047  +# variable so that [test_restore_config_pagecache] can restore the previous
         2048  +# configuration.
         2049  +#
         2050  +# Before returning, reopen connection [db] on file test.db.
         2051  +#
         2052  +proc test_set_config_pagecache {sz nPg} {
         2053  +  catch {db close}
         2054  +  catch {db2 close}
         2055  +  catch {db3 close}
         2056  +
         2057  +  sqlite3_shutdown
         2058  +  set ::old_pagecache_config [sqlite3_config_pagecache $sz $nPg]
         2059  +  sqlite3_initialize
         2060  +  autoinstall_test_functions
         2061  +  sqlite3 db test.db
         2062  +}
         2063  +
         2064  +# Close any connections named [db], [db2] or [db3]. Then use sqlite3_config
         2065  +# to configure the size of the PAGECACHE allocation to the size saved in
         2066  +# the global variable by an earlier call to [test_set_config_pagecache].
         2067  +#
         2068  +# Before returning, reopen connection [db] on file test.db.
         2069  +#
         2070  +proc test_restore_config_pagecache {} {
         2071  +  catch {db close}
         2072  +  catch {db2 close}
         2073  +  catch {db3 close}
         2074  +
         2075  +  sqlite3_shutdown
         2076  +  eval sqlite3_config_pagecache $::old_pagecache_config
         2077  +  unset ::old_pagecache_config 
         2078  +  sqlite3_initialize
         2079  +  autoinstall_test_functions
         2080  +  sqlite3 db test.db
         2081  +}
  2043   2082   
  2044   2083   # If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
  2045   2084   # to non-zero, then set the global variable $AUTOVACUUM to 1.
  2046   2085   set AUTOVACUUM $sqlite_options(default_autovacuum)
  2047   2086   
  2048   2087   # Make sure the FTS enhanced query syntax is disabled.
  2049   2088   set sqlite_fts3_enable_parentheses 0

Changes to test/zeroblob.test.

    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   ifcapable !incrblob {
    22     22     finish_test
    23     23     return
    24     24   }
           25  +
           26  +test_set_config_pagecache 0 0
    25     27   
    26     28   # When zeroblob() is used for the last field of a column, then the
    27     29   # content of the zeroblob is never instantiated on the VDBE stack.
    28     30   # But it does get inserted into the database correctly.
    29     31   #
    30     32   db eval {PRAGMA cache_size=10}
    31     33   sqlite3_memory_highwater 1
................................................................................
    37     39     }
    38     40     set ::sqlite3_max_blobsize 0
    39     41     execsql {
    40     42       INSERT INTO t1 VALUES(2,3,4,zeroblob(1000000));
    41     43     }
    42     44     set ::sqlite3_max_blobsize
    43     45   } {10}
           46  +
    44     47   do_test zeroblob-1.1.1 {
    45     48     expr {[sqlite3_memory_highwater]<$::memused+25000}
    46     49   } {1}
    47     50   do_test zeroblob-1.2 {
    48     51     execsql {
    49     52       SELECT length(d) FROM t1
    50     53     }
................................................................................
   261    264     db eval {
   262    265       CREATE TABLE t10(a,b,c);
   263    266     }
   264    267     catchsql {INSERT INTO t10 VALUES(zeroblob(1e9),zeroblob(1e9),zeroblob(1e9))}
   265    268   } {1 {string or blob too big}}
   266    269   
   267    270   
          271  +test_restore_config_pagecache
   268    272   finish_test