System.Data.SQLite

Check-in [9c7aa64aed]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9c7aa64aed3c997aa6e2e6c95dd0be9e0b94c648
User & Date: mistachkin 2014-12-08 22:25:03.015
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
Unified Diff Ignore Whitespace Patch
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
1635
1636
1637
1638
1639
1640
1641








1642
1643
1644
1645
1646
1647
1648

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern IntPtr sqlite3_compileoption_get(int N);









#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern SQLiteErrorCode sqlite3_enable_load_extension(







>
>
>
>
>
>
>
>







1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern IntPtr sqlite3_compileoption_get(int N);

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern SQLiteErrorCode sqlite3_enable_shared_cache(
        int enable);

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern SQLiteErrorCode sqlite3_enable_load_extension(
Changes to Tests/common.eagle.
1668
1669
1670
1671
1672
1673
1674




















1675
1676
1677
1678
1679
1680
1681
        #          ["magical"] meta-flags).
        #
        return [appendArgs "Flags=" $flags \;]
      }

      return ""
    }





















    proc setupDb {
            fileName {mode ""} {dateTimeFormat ""} {dateTimeKind ""} {flags ""}
            {extra ""} {qualify true} {delete true} {uri false}
            {temporary true} {varName db} {quiet false} } {
      #
      # NOTE: First, see if our caller has requested an in-memory database.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
        #          ["magical"] meta-flags).
        #
        return [appendArgs "Flags=" $flags \;]
      }

      return ""
    }

    proc enableSharedCache { channel enable {quiet false} } {
      if {[catch {
        object invoke -flags +NonPublic \
            System.Data.SQLite.UnsafeNativeMethods \
            sqlite3_enable_shared_cache [expr int($enable)]
      } result] == 0} then {
        if {!$quiet} then {
          tputs $channel [appendArgs \
              "---- call sqlite3_enable_shared_cache(" $enable \
              ")... ok: " $result \n]
        }
      } else {
        if {!$quiet} then {
          tputs $channel [appendArgs \
              "---- call sqlite3_enable_shared_cache(" $enable \
              ")... error: " \n\t $result \n]
        }
      }
    }

    proc setupDb {
            fileName {mode ""} {dateTimeFormat ""} {dateTimeKind ""} {flags ""}
            {extra ""} {qualify true} {delete true} {uri false}
            {temporary true} {varName db} {quiet false} } {
      #
      # NOTE: First, see if our caller has requested an in-memory database.
3175
3176
3177
3178
3179
3180
3181





3182
3183
3184
3185
3186
3187
3188
        #       tests that rely on the "opened from pool" count being greater
        #       than zero.  These tests may fail due to the non-deterministic
        #       behavior of the CLR GC, even when there is no bug in the code
        #       being tested.
        #
        checkForRuntimeOption $::test_channel noPoolCounts






        #
        # NOTE: Report the resource usage prior to running any tests.
        #
        reportSQLiteResources $::test_channel

        #
        # NOTE: Grab the list of native modules for the current process and







>
>
>
>
>







3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
        #       tests that rely on the "opened from pool" count being greater
        #       than zero.  These tests may fail due to the non-deterministic
        #       behavior of the CLR GC, even when there is no bug in the code
        #       being tested.
        #
        checkForRuntimeOption $::test_channel noPoolCounts

        #
        # NOTE: Check if the test suite should use shared-cache mode.
        #
        checkForRuntimeOption $::test_channel sharedCache

        #
        # NOTE: Report the resource usage prior to running any tests.
        #
        reportSQLiteResources $::test_channel

        #
        # NOTE: Grab the list of native modules for the current process and
3255
3256
3257
3258
3259
3260
3261







3262
3263
3264
3265
3266
3267
3268
        }

        #
        # NOTE: Load the "after-constraints" custom per-user and/or per-host
        #       test settings now.
        #
        uplevel 1 [list loadSQLiteTestSettings $::test_channel .after]








        #
        # NOTE: Show when our tests actually began (now).
        #
        tputs $::test_channel [appendArgs \
            "---- System.Data.SQLite tests began at " \
            [clock format [clock seconds]] \n]







>
>
>
>
>
>
>







3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
        }

        #
        # NOTE: Load the "after-constraints" custom per-user and/or per-host
        #       test settings now.
        #
        uplevel 1 [list loadSQLiteTestSettings $::test_channel .after]

        #
        # NOTE: If necessary, enable shared-cache mode now.
        #
        if {[hasRuntimeOption sharedCache]} then {
          enableSharedCache $::test_channel true
        }

        #
        # NOTE: Show when our tests actually began (now).
        #
        tputs $::test_channel [appendArgs \
            "---- System.Data.SQLite tests began at " \
            [clock format [clock seconds]] \n]
3516
3517
3518
3519
3520
3521
3522







3523
3524
3525
3526
3527
3528
3529
        #
        reportSQLiteResources $::test_channel

        #
        # NOTE: Report the critical handle counts after running the tests.
        #
        getSQLiteHandleCounts $::test_channel







      }
    }

    ###########################################################################
    ############################# END Eagle ONLY ##############################
    ###########################################################################
  }







>
>
>
>
>
>
>







3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
        #
        reportSQLiteResources $::test_channel

        #
        # NOTE: Report the critical handle counts after running the tests.
        #
        getSQLiteHandleCounts $::test_channel

        #
        # NOTE: If necessary, disable shared-cache mode now.
        #
        if {[hasRuntimeOption sharedCache]} then {
          enableSharedCache $::test_channel false
        }
      }
    }

    ###########################################################################
    ############################# END Eagle ONLY ##############################
    ###########################################################################
  }
Changes to Tests/stress.eagle.
388
389
390
391
392
393
394





















395
396
397
398
399
400
401
  #
  # HACK: Make sure the effective connection flags for this test are logged.
  #
  getConnectionFlags "stress test" "" false; # IGNORED

  #############################################################################






















  tputs $test_channel [appendArgs \
      "---- workloads will repeat " $count(0) " time(s)\n"]

  tputs $test_channel [appendArgs \
      "---- workloads will have " $count(1) " iteration(s)\n"]

  tputs $test_channel [appendArgs \







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
  #
  # HACK: Make sure the effective connection flags for this test are logged.
  #
  getConnectionFlags "stress test" "" false; # IGNORED

  #############################################################################

  #
  # NOTE: In shared-cache mode, skip the backup tests.  The SQLite core library
  #       documentation states:
  #
  #       "If running in shared cache mode, the application must guarantee
  #        that the shared cache used by the destination database is not
  #        accessed while the backup is running. In practice this means that
  #        the application must guarantee that the disk file being backed up
  #        to is not accessed by any connection within the process, not just
  #        the specific connection that was passed to sqlite3_backup_init()."
  #
  #       The only reasonable way that this test can guarantee this condition
  #       is to disable the backup tests when shared-cache mode is being used
  #       for testing.
  #
  if {[hasRuntimeOption sharedCache]} then {
    lappend noWorkload 12 13; # TODO: Update if the workload numbers change.
  }

  #############################################################################

  tputs $test_channel [appendArgs \
      "---- workloads will repeat " $count(0) " time(s)\n"]

  tputs $test_channel [appendArgs \
      "---- workloads will have " $count(1) " iteration(s)\n"]

  tputs $test_channel [appendArgs \
1348
1349
1350
1351
1352
1353
1354



1355
1356
1357
1358
1359
1360
1361
    tputs $test_channel [appendArgs \
        "---- starting workload run #" $index(0) ...\n]

    unset -nocomplain thread status; doneTest

    sql execute $srcDb "CREATE TABLE IF NOT EXISTS t1(x PRIMARY KEY, y, z);"
    sql execute $db "CREATE TABLE IF NOT EXISTS t1(x PRIMARY KEY, y, z);"




    foreach index(1) [lsort -integer $workloadNames(enabled)] {
      set workloadCallbacks($index(1)) [list \
          apply $workload($index(1)) $fileName(1) $fileName(2) t1 $count(1) \
          $count(3) $count(4)]

      set thread($index(1)) [object create -alias System.Threading.Thread \







>
>
>







1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
    tputs $test_channel [appendArgs \
        "---- starting workload run #" $index(0) ...\n]

    unset -nocomplain thread status; doneTest

    sql execute $srcDb "CREATE TABLE IF NOT EXISTS t1(x PRIMARY KEY, y, z);"
    sql execute $db "CREATE TABLE IF NOT EXISTS t1(x PRIMARY KEY, y, z);"

    sql execute $srcDb "CREATE INDEX IF NOT EXISTS i1 ON t1(y);"
    sql execute $db "CREATE INDEX IF NOT EXISTS i1 ON t1(y);"

    foreach index(1) [lsort -integer $workloadNames(enabled)] {
      set workloadCallbacks($index(1)) [list \
          apply $workload($index(1)) $fileName(1) $fileName(2) t1 $count(1) \
          $count(3) $count(4)]

      set thread($index(1)) [object create -alias System.Threading.Thread \