/ Check-in [df939c89]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix the shmlock.test script so that it works with the Windows restriction that UnlockFile must exactly correspond to a prior LockFile.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: df939c89fa90b7f9ccf961027ca4eca4f987c49eabf530b5719a83e5ab0d346d
User & Date: drh 2019-01-03 16:00:23
Context
2019-01-03
16:03
Fix the csv01.test module so that it works on systems with \r\n line endings. check-in: 36eaf5a5 user: drh tags: trunk
16:00
Fix the shmlock.test script so that it works with the Windows restriction that UnlockFile must exactly correspond to a prior LockFile. check-in: df939c89 user: drh tags: trunk
15:22
Fix a harmless compiler warning in the CSV extension. check-in: fbcd7256 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/shmlock.test.

110
111
112
113
114
115
116





117
118
119
120
121
122
123
...
130
131
132
133
134
135
136




137
138
139
140
141
142
143
...
165
166
167
168
169
170
171
172
173
  }
}

sqlite3 db0 test.db
sqlite3 db1 test.db
do_test 3.1 { execsql { SELECT * FROM t1 } db0 } {1 2}
do_test 3.2 { execsql { SELECT * FROM t1 } db1 } {1 2}






set L(0) {n n n n n n n n}
set L(1) {n n n n n n n n}
proc random_lock_test {idx} {
  global L
  set iSlot [expr int(rand()*8)]
  if {[expr int(rand()*2)]} {
................................................................................
    # Lock operation
    if {[lindex $L($idx) $iSlot]=="n"} {
      set locktype [lindex {e s} [expr int(rand()*2)]]
      set n 1
      if {$locktype=="e"} {
        for {set l $iSlot} {$l<8 && [lindex $L($idx) $l]=="n"} {incr l} {}
        set n [expr int(rand()*($l-$iSlot))+1]




        # puts "iSlot=$iSlot l=$l L=$L($idx)"
        # puts "$iSlot $n"
      }
      set res [vfs_shmlock db$idx main $locktype lock $iSlot $n]

      set bBusy 0
      for {set i $iSlot} {$i<($iSlot+$n)} {incr i} {
................................................................................
  random_lock_test 1
}

db0 close
db1 close

finish_test









>
>
>
>
>







 







>
>
>
>







 







<
<
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
174
175
176
177
178
179
180


  }
}

sqlite3 db0 test.db
sqlite3 db1 test.db
do_test 3.1 { execsql { SELECT * FROM t1 } db0 } {1 2}
do_test 3.2 { execsql { SELECT * FROM t1 } db1 } {1 2}
if {$tcl_platform(platform)=="windows"} {
  set isWindows 1
} else {
  set isWindows 0
}

set L(0) {n n n n n n n n}
set L(1) {n n n n n n n n}
proc random_lock_test {idx} {
  global L
  set iSlot [expr int(rand()*8)]
  if {[expr int(rand()*2)]} {
................................................................................
    # Lock operation
    if {[lindex $L($idx) $iSlot]=="n"} {
      set locktype [lindex {e s} [expr int(rand()*2)]]
      set n 1
      if {$locktype=="e"} {
        for {set l $iSlot} {$l<8 && [lindex $L($idx) $l]=="n"} {incr l} {}
        set n [expr int(rand()*($l-$iSlot))+1]
        # The LockFile() and UnlockFile() apis on windows require that
        # every unlock correspond exactly to a prior lock.  Hence, we cannot
        # lock arbitrary ranges in this test on windows.
        if {$::isWindows} {set n 1}
        # puts "iSlot=$iSlot l=$l L=$L($idx)"
        # puts "$iSlot $n"
      }
      set res [vfs_shmlock db$idx main $locktype lock $iSlot $n]

      set bBusy 0
      for {set i $iSlot} {$i<($iSlot+$n)} {incr i} {
................................................................................
  random_lock_test 1
}

db0 close
db1 close

finish_test