/ Check-in [f6baa7e1]
Login

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

Overview
Comment:Add test file wal2snapshot.test that should have been added as part of an earlier commit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wal2
Files: files | file ages | folders
SHA3-256:f6baa7e1163ed5f61375b0554337030fec23e8a9f60c6412e1b5d626961e93f9
User & Date: dan 2018-12-06 16:54:44
Wiki:wal2
Context
2018-12-11
13:44
Merge latest trunk changes into this branch. check-in: d8dd98a3 user: dan tags: wal2
2018-12-06
16:54
Add test file wal2snapshot.test that should have been added as part of an earlier commit. check-in: f6baa7e1 user: dan tags: wal2
2018-12-05
17:31
Fix a test script problem on this branch. check-in: 285d1c59 user: dan tags: wal2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/wal2snapshot.test.

            1  +# 2018 December 5
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this file is testing the operation of the library in
           13  +# "PRAGMA journal_mode=WAL2" mode.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +
           19  +set testprefix wal2snapshot
           20  +ifcapable !wal {finish_test ; return }
           21  +ifcapable !snapshot {finish_test; return}
           22  +
           23  +foreach {tn mode} {1 wal 2 wal2} {
           24  +  reset_db
           25  +  do_execsql_test $tn.1 "PRAGMA journal_mode = $mode" $mode
           26  +
           27  +  do_execsql_test $tn.2 {
           28  +    CREATE TABLE t1(a, b);
           29  +    INSERT INTO t1 VALUES(1, 2);
           30  +    INSERT INTO t1 VALUES(3, 4);
           31  +    BEGIN;
           32  +  }
           33  +
           34  +  # Check that sqlite3_snapshot_get() is an error for a wal2 db.
           35  +  #
           36  +  if {$tn==1} {
           37  +    do_test 1.3 {
           38  +      set S [sqlite3_snapshot_get db main]
           39  +      sqlite3_snapshot_free $S
           40  +    } {}
           41  +  } else {
           42  +    do_test 2.3 {
           43  +      list [catch { sqlite3_snapshot_get db main } msg] $msg
           44  +    } {1 SQLITE_ERROR}
           45  +  }
           46  +  
           47  +  # Check that sqlite3_snapshot_recover() is an error for a wal2 db.
           48  +  #
           49  +  do_execsql_test $tn.4 COMMIT
           50  +  if {$tn==1} {
           51  +    do_test 1.5 {
           52  +      sqlite3_snapshot_recover db main
           53  +    } {}
           54  +  } else {
           55  +    do_test 2.5 {
           56  +      list [catch { sqlite3_snapshot_recover db main } msg] $msg
           57  +    } {1 SQLITE_ERROR}
           58  +  }
           59  + 
           60  +  # Check that sqlite3_snapshot_open() is an error for a wal2 db.
           61  +  #
           62  +  if {$tn==1} {
           63  +    do_test 1.6 {
           64  +      execsql BEGIN
           65  +      set SNAPSHOT [sqlite3_snapshot_get_blob db main]
           66  +      sqlite3_snapshot_open_blob db main $SNAPSHOT
           67  +      execsql COMMIT
           68  +    } {}
           69  +  } else {
           70  +    do_test 2.6 {
           71  +      execsql BEGIN
           72  +      set res [
           73  +        list [catch { sqlite3_snapshot_open_blob db main $SNAPSHOT } msg] $msg
           74  +      ]
           75  +      execsql COMMIT
           76  +      set res
           77  +    } {1 SQLITE_ERROR}
           78  +  }
           79  +}
           80  +
           81  +
           82  +finish_test
           83  +
           84  +