/ Check-in [1be70015]
Login

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

Overview
Comment:Get the io.test tests working on windows. (CVS 4381)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1be70015e24f715a4276f253d2e0c0eec44650ee
User & Date: drh 2007-09-03 17:02:50
Context
2007-09-03
17:09
Fix the open file counter on windows. (CVS 4382) check-in: 40cf0c17 user: drh tags: trunk
17:02
Get the io.test tests working on windows. (CVS 4381) check-in: 1be70015 user: drh tags: trunk
16:45
Fix the incrblob.test on windows. Disable line terminator translation. (CVS 4380) check-in: ccbd2efe user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

   707    707     OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte);
   708    708     SimulateIOError(return SQLITE_IOERR_TRUNCATE);
   709    709     SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
   710    710     SetEndOfFile(pFile->h);
   711    711     return SQLITE_OK;
   712    712   }
   713    713   
          714  +#ifdef SQLITE_TEST
          715  +/*
          716  +** Count the number of fullsyncs and normal syncs.  This is used to test
          717  +** that syncs and fullsyncs are occuring at the right times.
          718  +*/
          719  +int sqlite3_sync_count = 0;
          720  +int sqlite3_fullsync_count = 0;
          721  +#endif
          722  +
   714    723   /*
   715    724   ** Make sure all writes to a particular file are committed to disk.
   716    725   */
   717    726   static int winSync(sqlite3_file *id, int flags){
   718    727     winFile *pFile = (winFile*)id;
   719    728     OSTRACE3("SYNC %d lock=%d\n", pFile->h, pFile->locktype);
          729  +#ifdef SQLITE_TEST
          730  +  if( flags & SQLITE_SYNC_FULL ){
          731  +    sqlite3_fullsync_count++;
          732  +  }
          733  +  sqlite3_sync_count++;
          734  +#endif
   720    735     if( FlushFileBuffers(pFile->h) ){
   721    736       return SQLITE_OK;
   722    737     }else{
   723    738       return SQLITE_IOERR;
   724    739     }
   725    740   }
   726    741   

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing all sorts of SQLite interfaces.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.275 2007/09/03 11:04:22 danielk1977 Exp $
           16  +** $Id: test1.c,v 1.276 2007/09/03 17:02:50 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
    22     22   
    23     23   /*
................................................................................
  4465   4465         (char*)&sqlite_static_bind_value, TCL_LINK_STRING);
  4466   4466     Tcl_LinkVar(interp, "sqlite_static_bind_nbyte",
  4467   4467         (char*)&sqlite_static_bind_nbyte, TCL_LINK_INT);
  4468   4468     Tcl_LinkVar(interp, "sqlite_temp_directory",
  4469   4469         (char*)&sqlite3_temp_directory, TCL_LINK_STRING);
  4470   4470     Tcl_LinkVar(interp, "bitmask_size",
  4471   4471         (char*)&bitmask_size, TCL_LINK_INT|TCL_LINK_READ_ONLY);
  4472         -#if OS_UNIX
  4473   4472     Tcl_LinkVar(interp, "sqlite_sync_count",
  4474   4473         (char*)&sqlite3_sync_count, TCL_LINK_INT);
  4475   4474     Tcl_LinkVar(interp, "sqlite_fullsync_count",
  4476   4475         (char*)&sqlite3_fullsync_count, TCL_LINK_INT);
  4477         -#endif /* OS_UNIX */
  4478         -
  4479   4476     return TCL_OK;
  4480   4477   }

Changes to test/io.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12     12   # The focus of this file is testing some specific characteristics of the 
    13     13   # IO traffic generated by SQLite (making sure SQLite is not writing out
    14     14   # more database pages than it has to, stuff like that).
    15     15   #
    16         -# $Id: io.test,v 1.8 2007/09/01 18:24:55 danielk1977 Exp $
           16  +# $Id: io.test,v 1.9 2007/09/03 17:02:50 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Test summary:
    22     22   #
    23     23   # io-1.* -  Test that quick-balance does not journal pages unnecessarily.
................................................................................
   400    400   # Test cases io-4.* test the IOCAP_SAFE_APPEND optimization.
   401    401   #
   402    402   sqlite3_simulate_device -char safe_append
   403    403   
   404    404   # With the SAFE_APPEND flag set, simple transactions require 3, rather
   405    405   # than 4, calls to fsync(). The fsync() calls are on:
   406    406   #
   407         -#   1) The directory in which the journal file is created,
          407  +#   1) The directory in which the journal file is created, (unix only)
   408    408   #   2) The journal file (to sync the page data),
   409    409   #   3) The database file.
   410    410   #
   411    411   # Normally, when the SAFE_APPEND flag is not set, there is another fsync()
   412    412   # on the journal file between steps (2) and (3) above.
   413    413   #
          414  +if {$::tcl_platform(platform)=="unix"} {
          415  +  set expected_sync_count 3
          416  +} else {
          417  +  set expected_sync_count 2
          418  +}
   414    419   do_test io-4.1 {
   415    420     execsql { DELETE FROM abc }
   416    421     nSync
   417    422     execsql { INSERT INTO abc VALUES('a', 'b') }
   418    423     nSync
   419         -} {3}
          424  +} $expected_sync_count
   420    425   
   421    426   # With SAFE_APPEND set, the nRec field of the journal file header should
   422    427   # be set to 0xFFFFFFFF before the first journal sync. The nRec field
   423    428   # occupies bytes 8-11 of the journal file.
   424    429   #
   425    430   do_test io-4.2.1 {
   426    431     execsql { BEGIN }
   427    432     execsql { INSERT INTO abc VALUES('c', 'd') }
   428    433     file exists test.db-journal
   429    434   } {1}
   430         -do_test io-4.2.2 {
   431         -  set fd [open test.db-journal]
   432         -  fconfigure $fd -translation binary -encoding binary
   433         -  seek $fd 8
   434         -  set blob [read $fd 4]
   435         -  close $fd
   436         -  binary scan $blob i res
   437         -  format 0x%X $res
   438         -} {0xFFFFFFFF}
          435  +if {$::tcl_platform(platform)=="unix"} {
          436  +  do_test io-4.2.2 {
          437  +    set fd [open test.db-journal]
          438  +    fconfigure $fd -translation binary -encoding binary
          439  +    seek $fd 8
          440  +    set blob [read $fd 4]
          441  +    close $fd
          442  +    binary scan $blob i res
          443  +    format 0x%X $res
          444  +  } {0xFFFFFFFF}
          445  +}
   439    446   do_test io-4.2.3 {
   440    447     execsql { COMMIT }
   441    448     nSync
   442         -} {3}
   443         -
          449  +} $expected_sync_count
   444    450   sqlite3_simulate_device -char safe_append
   445    451   
   446    452   # With SAFE_APPEND set, there should only ever be one journal-header
   447    453   # written to the database, even though the sync-mode is "full".
   448    454   #
   449    455   do_test io-4.3.1 {
   450    456     execsql {

Changes to test/mallocD.test.

     5      5   #
     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12         -# $Id: mallocD.test,v 1.2 2007/09/03 07:31:10 danielk1977 Exp $
           12  +# $Id: mallocD.test,v 1.3 2007/09/03 17:02:50 drh Exp $
    13     13   
    14     14   set testdir [file dirname $argv0]
    15     15   source $testdir/tester.tcl
    16     16   
    17         -if {![source $testdir/malloc_common.tcl]} return
           17  +# Only run these tests if memory debugging is turned on.
           18  +#
           19  +ifcapable !memdebug {
           20  +   puts "Skipping mallocD tests: not compiled with -DSQLITE_MEMDEBUG..."
           21  +   finish_test
           22  +   return
           23  +}
           24  +source $testdir/malloc_common.tcl
    18     25   
    19     26   sqlite3_simulate_device -char atomic
    20     27   
    21     28   set PREP { 
    22     29     PRAGMA page_size = 1024;
    23     30     CREATE TABLE abc(a, b, c);
    24     31   }
................................................................................
    48     55     INSERT INTO abc VALUES(4, 5, 6);
    49     56     COMMIT;
    50     57   }
    51     58   
    52     59   sqlite3_simulate_device -char {}
    53     60   
    54     61   finish_test
    55         -