SQLite

Check-in [60c22bde52]
Login

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

Overview
Comment:Minor changes to checksum related test cases.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 60c22bde52121993d4bea11eef38ab285c737e2c
User & Date: dan 2010-05-29 06:18:55.000
Original Comment: i i Minor changes to checksum related test cases.
Context
2010-05-29
08:40
Add tests to fkey2.test to check that ON CONFLICT clauses do not affect SQLite's behaviour when an FK constraint is violated. (check-in: e9e5b10019 user: dan tags: trunk)
06:18
Minor changes to checksum related test cases. (check-in: 60c22bde52 user: dan tags: trunk)
2010-05-28
11:16
Add a test to walcksum.test to stress the checksum calculation. (check-in: 778d0c1768 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/wal2.test.
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42

  if {[llength $args]>1} {
    return -code error {wrong # args: should be "set_tvfs_hdr fileName ?val?"}
  }

  set blob [tvfs shm $file]
  if {[llength $args]} {
    set blob [

      binary format i${nInt}a* [lindex $args 0] [string range $blob $nHdr end]
    ]
    tvfs shm $file $blob
  }

  binary scan $blob i${nInt} ints
  return $ints
}








|
>
|
<







26
27
28
29
30
31
32
33
34
35

36
37
38
39
40
41
42

  if {[llength $args]>1} {
    return -code error {wrong # args: should be "set_tvfs_hdr fileName ?val?"}
  }

  set blob [tvfs shm $file]
  if {[llength $args]} {
    set ia [lindex $args 0]
    set tail [string range $blob [expr $nHdr*2] end]
    set blob [binary format i${nInt}i${nInt}a* $ia $ia $tail]

    tvfs shm $file $blob
  }

  binary scan $blob i${nInt} ints
  return $ints
}

97
98
99
100
101
102
103


104
105
106
107
108
109
110
111
         3    6   {6 21}    1             {READ RECOVER READ UNLOCK}
         4    7   {7 28}    2             {READ RECOVER READ UNLOCK}
         5    8   {8 36}    3             {READ RECOVER READ UNLOCK}
         6    9   {9 45}    4             {READ RECOVER READ UNLOCK}
         7   10   {10 55}   5             {READ RECOVER READ UNLOCK}
         8   11   {11 66}   6             {READ RECOVER READ UNLOCK}
         9   12   {12 78}   7             {READ RECOVER READ UNLOCK}


        10   13   {13 91}   -1            {READ UNLOCK}
} {

  do_test wal2-1.$tn.1 {
    execsql { INSERT INTO t1 VALUES($iInsert) }

    set ::locks [list]
    set ::cb_done 0







>
>
|







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
         3    6   {6 21}    1             {READ RECOVER READ UNLOCK}
         4    7   {7 28}    2             {READ RECOVER READ UNLOCK}
         5    8   {8 36}    3             {READ RECOVER READ UNLOCK}
         6    9   {9 45}    4             {READ RECOVER READ UNLOCK}
         7   10   {10 55}   5             {READ RECOVER READ UNLOCK}
         8   11   {11 66}   6             {READ RECOVER READ UNLOCK}
         9   12   {12 78}   7             {READ RECOVER READ UNLOCK}
        10   13   {13 91}   8             {READ RECOVER READ UNLOCK}
        11   14   {14 105}  9             {READ RECOVER READ UNLOCK}
        12   15   {15 120}  -1            {READ UNLOCK}
} {

  do_test wal2-1.$tn.1 {
    execsql { INSERT INTO t1 VALUES($iInsert) }

    set ::locks [list]
    set ::cb_done 0
Changes to test/walcksum.test.
356
357
358
359
360
361
362
363


364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
  file copy -force test.db-wal test2.db-wal
  file copy -force test.db test2.db
  sqlite3 db2 test2.db
  execsql { SELECT a FROM t1 } db2
} {1 2 3}
db2 close
file copy -force test.db test2.db
for {set incr 1} {$incr <= 255} {incr incr 21} {


  do_test walcksum-3.3.$incr {
    set FAIL 0
    for {set iOff 0} {$iOff < [log_file_size 1 1024]} {incr iOff} {

      file copy -force test.db-wal test2.db-wal
      set fd [open test2.db-wal r+]
      fconfigure $fd -encoding binary
      fconfigure $fd -translation binary
  
      seek $fd $iOff
      binary scan [read $fd 1] c x
      seek $fd $iOff
      puts -nonewline $fd [binary format c [expr {$x+$incr}]]
      close $fd
    
      sqlite3 db2 test2.db
      if { [execsql { SELECT a FROM t1 } db2] != "1 2" } {set FAIL 1}
      db2 close
    }
    set FAIL







|
>
>












|







356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
  file copy -force test.db-wal test2.db-wal
  file copy -force test.db test2.db
  sqlite3 db2 test2.db
  execsql { SELECT a FROM t1 } db2
} {1 2 3}
db2 close
file copy -force test.db test2.db


foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} {
  do_test walcksum-3.3.$incr {
    set FAIL 0
    for {set iOff 0} {$iOff < [log_file_size 1 1024]} {incr iOff} {

      file copy -force test.db-wal test2.db-wal
      set fd [open test2.db-wal r+]
      fconfigure $fd -encoding binary
      fconfigure $fd -translation binary
  
      seek $fd $iOff
      binary scan [read $fd 1] c x
      seek $fd $iOff
      puts -nonewline $fd [binary format c [expr {($x+$incr)&0xFF}]]
      close $fd
    
      sqlite3 db2 test2.db
      if { [execsql { SELECT a FROM t1 } db2] != "1 2" } {set FAIL 1}
      db2 close
    }
    set FAIL