System.Data.SQLite
Check-in [9c7aa64aed]
Not logged in

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

Overview
Comment:Modify the test suite to support testing with shared-cache enabled.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9c7aa64aed3c997aa6e2e6c95dd0be9e0b94c648
User & Date: mistachkin 2014-12-08 22:25:03
Context
2014-12-09
19:23
Update the included core library documentation. check-in: 9ade973926 user: mistachkin tags: trunk
2014-12-08
22:25
Modify the test suite to support testing with shared-cache enabled. check-in: 9c7aa64aed user: mistachkin tags: trunk
2014-12-05
23:08
Fix compilation error in the LINQ test tool with VS 2008. check-in: 3c3a197fad user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

  1635   1635   
  1636   1636   #if !PLATFORM_COMPACTFRAMEWORK
  1637   1637       [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
  1638   1638   #else
  1639   1639       [DllImport(SQLITE_DLL)]
  1640   1640   #endif
  1641   1641       internal static extern IntPtr sqlite3_compileoption_get(int N);
         1642  +
         1643  +#if !PLATFORM_COMPACTFRAMEWORK
         1644  +    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
         1645  +#else
         1646  +    [DllImport(SQLITE_DLL)]
         1647  +#endif
         1648  +    internal static extern SQLiteErrorCode sqlite3_enable_shared_cache(
         1649  +        int enable);
  1642   1650   
  1643   1651   #if !PLATFORM_COMPACTFRAMEWORK
  1644   1652       [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
  1645   1653   #else
  1646   1654       [DllImport(SQLITE_DLL)]
  1647   1655   #endif
  1648   1656       internal static extern SQLiteErrorCode sqlite3_enable_load_extension(

Changes to Tests/common.eagle.

  1668   1668           #          ["magical"] meta-flags).
  1669   1669           #
  1670   1670           return [appendArgs "Flags=" $flags \;]
  1671   1671         }
  1672   1672   
  1673   1673         return ""
  1674   1674       }
         1675  +
         1676  +    proc enableSharedCache { channel enable {quiet false} } {
         1677  +      if {[catch {
         1678  +        object invoke -flags +NonPublic \
         1679  +            System.Data.SQLite.UnsafeNativeMethods \
         1680  +            sqlite3_enable_shared_cache [expr int($enable)]
         1681  +      } result] == 0} then {
         1682  +        if {!$quiet} then {
         1683  +          tputs $channel [appendArgs \
         1684  +              "---- call sqlite3_enable_shared_cache(" $enable \
         1685  +              ")... ok: " $result \n]
         1686  +        }
         1687  +      } else {
         1688  +        if {!$quiet} then {
         1689  +          tputs $channel [appendArgs \
         1690  +              "---- call sqlite3_enable_shared_cache(" $enable \
         1691  +              ")... error: " \n\t $result \n]
         1692  +        }
         1693  +      }
         1694  +    }
  1675   1695   
  1676   1696       proc setupDb {
  1677   1697               fileName {mode ""} {dateTimeFormat ""} {dateTimeKind ""} {flags ""}
  1678   1698               {extra ""} {qualify true} {delete true} {uri false}
  1679   1699               {temporary true} {varName db} {quiet false} } {
  1680   1700         #
  1681   1701         # NOTE: First, see if our caller has requested an in-memory database.
................................................................................
  3175   3195           #       tests that rely on the "opened from pool" count being greater
  3176   3196           #       than zero.  These tests may fail due to the non-deterministic
  3177   3197           #       behavior of the CLR GC, even when there is no bug in the code
  3178   3198           #       being tested.
  3179   3199           #
  3180   3200           checkForRuntimeOption $::test_channel noPoolCounts
  3181   3201   
         3202  +        #
         3203  +        # NOTE: Check if the test suite should use shared-cache mode.
         3204  +        #
         3205  +        checkForRuntimeOption $::test_channel sharedCache
         3206  +
  3182   3207           #
  3183   3208           # NOTE: Report the resource usage prior to running any tests.
  3184   3209           #
  3185   3210           reportSQLiteResources $::test_channel
  3186   3211   
  3187   3212           #
  3188   3213           # NOTE: Grab the list of native modules for the current process and
................................................................................
  3255   3280           }
  3256   3281   
  3257   3282           #
  3258   3283           # NOTE: Load the "after-constraints" custom per-user and/or per-host
  3259   3284           #       test settings now.
  3260   3285           #
  3261   3286           uplevel 1 [list loadSQLiteTestSettings $::test_channel .after]
         3287  +
         3288  +        #
         3289  +        # NOTE: If necessary, enable shared-cache mode now.
         3290  +        #
         3291  +        if {[hasRuntimeOption sharedCache]} then {
         3292  +          enableSharedCache $::test_channel true
         3293  +        }
  3262   3294   
  3263   3295           #
  3264   3296           # NOTE: Show when our tests actually began (now).
  3265   3297           #
  3266   3298           tputs $::test_channel [appendArgs \
  3267   3299               "---- System.Data.SQLite tests began at " \
  3268   3300               [clock format [clock seconds]] \n]
................................................................................
  3516   3548           #
  3517   3549           reportSQLiteResources $::test_channel
  3518   3550   
  3519   3551           #
  3520   3552           # NOTE: Report the critical handle counts after running the tests.
  3521   3553           #
  3522   3554           getSQLiteHandleCounts $::test_channel
         3555  +
         3556  +        #
         3557  +        # NOTE: If necessary, disable shared-cache mode now.
         3558  +        #
         3559  +        if {[hasRuntimeOption sharedCache]} then {
         3560  +          enableSharedCache $::test_channel false
         3561  +        }
  3523   3562         }
  3524   3563       }
  3525   3564   
  3526   3565       ###########################################################################
  3527   3566       ############################# END Eagle ONLY ##############################
  3528   3567       ###########################################################################
  3529   3568     }

Changes to Tests/stress.eagle.

   388    388     #
   389    389     # HACK: Make sure the effective connection flags for this test are logged.
   390    390     #
   391    391     getConnectionFlags "stress test" "" false; # IGNORED
   392    392   
   393    393     #############################################################################
   394    394   
          395  +  #
          396  +  # NOTE: In shared-cache mode, skip the backup tests.  The SQLite core library
          397  +  #       documentation states:
          398  +  #
          399  +  #       "If running in shared cache mode, the application must guarantee
          400  +  #        that the shared cache used by the destination database is not
          401  +  #        accessed while the backup is running. In practice this means that
          402  +  #        the application must guarantee that the disk file being backed up
          403  +  #        to is not accessed by any connection within the process, not just
          404  +  #        the specific connection that was passed to sqlite3_backup_init()."
          405  +  #
          406  +  #       The only reasonable way that this test can guarantee this condition
          407  +  #       is to disable the backup tests when shared-cache mode is being used
          408  +  #       for testing.
          409  +  #
          410  +  if {[hasRuntimeOption sharedCache]} then {
          411  +    lappend noWorkload 12 13; # TODO: Update if the workload numbers change.
          412  +  }
          413  +
          414  +  #############################################################################
          415  +
   395    416     tputs $test_channel [appendArgs \
   396    417         "---- workloads will repeat " $count(0) " time(s)\n"]
   397    418   
   398    419     tputs $test_channel [appendArgs \
   399    420         "---- workloads will have " $count(1) " iteration(s)\n"]
   400    421   
   401    422     tputs $test_channel [appendArgs \
................................................................................
  1348   1369       tputs $test_channel [appendArgs \
  1349   1370           "---- starting workload run #" $index(0) ...\n]
  1350   1371   
  1351   1372       unset -nocomplain thread status; doneTest
  1352   1373   
  1353   1374       sql execute $srcDb "CREATE TABLE IF NOT EXISTS t1(x PRIMARY KEY, y, z);"
  1354   1375       sql execute $db "CREATE TABLE IF NOT EXISTS t1(x PRIMARY KEY, y, z);"
         1376  +
         1377  +    sql execute $srcDb "CREATE INDEX IF NOT EXISTS i1 ON t1(y);"
         1378  +    sql execute $db "CREATE INDEX IF NOT EXISTS i1 ON t1(y);"
  1355   1379   
  1356   1380       foreach index(1) [lsort -integer $workloadNames(enabled)] {
  1357   1381         set workloadCallbacks($index(1)) [list \
  1358   1382             apply $workload($index(1)) $fileName(1) $fileName(2) t1 $count(1) \
  1359   1383             $count(3) $count(4)]
  1360   1384   
  1361   1385         set thread($index(1)) [object create -alias System.Threading.Thread \