sqlite/test/mjournal.test

84 lines
2.2 KiB
Plaintext

# 2017 September 15
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix mjournal
# Test that nothing bad happens if a journal file contains a pointer to
# a master journal file that does not have a "-" in the name. At one point
# this was causing a segfault on unix.
#
do_execsql_test 1.0 {
CREATE TABLE t1(a, b);
}
do_test 1.1 {
forcedelete test.db2journal test.db-journal
close [open test.db-journal w]
hexio_write test.db-journal 0 746573742e6462326a6f75726e616c00
hexio_write test.db-journal 16 00000010
hexio_write test.db-journal 20 000005e1
hexio_write test.db-journal 24 d9d505f920a163d7
close [open test.db2journal w]
hexio_write test.db2journal 0 abcd
} {2}
do_execsql_test 1.2 {
SELECT * FROM t1;
}
do_test 1.3 {
forcedelete test0db2journal test.db-journal
close [open test.db-journal w]
hexio_write test.db-journal 0 74657374306462326a6f75726e616c00
hexio_write test.db-journal 16 00000010
hexio_write test.db-journal 20 000005e3
hexio_write test.db-journal 24 d9d505f920a163d7
close [open test0db2journal w]
hexio_write test0db2journal 0 abcd
} {2}
do_execsql_test 1.4 {
SELECT * FROM t1;
}
# And now test that nothing bad happens if a master journal contains a
# pointer to a journal file that does not have a "-" in the name.
#
do_test 1.5 {
forcedelete test.db2-master test.db-journal test1
close [open test.db-journal w]
hexio_write test.db-journal 0 746573742e6462322d6d617374657200
hexio_write test.db-journal 16 00000010
hexio_write test.db-journal 20 0000059f
hexio_write test.db-journal 24 d9d505f920a163d7
close [open test.db2-master w]
hexio_write test.db2-master 0 746573743100
close [open test1 w]
hexio_write test1 0 abcd
} {2}
do_execsql_test 1.6 {
SELECT * FROM t1;
}
finish_test