Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/sqlite/src/test/tester.tcl

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/tclsqlite.test ('k') | third_party/sqlite/src/test/threadtest2.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2001 September 15 1 # 2001 September 15
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 # 74 #
75 # Commands to help create test files that run with the "WAL" and other 75 # Commands to help create test files that run with the "WAL" and other
76 # permutations (see file permutations.test): 76 # permutations (see file permutations.test):
77 # 77 #
78 # wal_is_wal_mode 78 # wal_is_wal_mode
79 # wal_set_journal_mode ?DB? 79 # wal_set_journal_mode ?DB?
80 # wal_check_journal_mode TESTNAME?DB? 80 # wal_check_journal_mode TESTNAME?DB?
81 # permutation 81 # permutation
82 # presql 82 # presql
83 # 83 #
84 # Command to test whether or not --verbose=1 was specified on the command
85 # line (returns 0 for not-verbose, 1 for verbose and 2 for "verbose in the
86 # output file only").
87 #
88 # verbose
89 #
84 90
85 # Set the precision of FP arithmatic used by the interpreter. And 91 # Set the precision of FP arithmatic used by the interpreter. And
86 # configure SQLite to take database file locks on the page that begins 92 # configure SQLite to take database file locks on the page that begins
87 # 64KB into the database file instead of the one 1GB in. This means 93 # 64KB into the database file instead of the one 1GB in. This means
88 # the code that handles that special case can be tested without creating 94 # the code that handles that special case can be tested without creating
89 # very large database files. 95 # very large database files.
90 # 96 #
91 set tcl_precision 15 97 set tcl_precision 15
92 sqlite3_test_control_pending_byte 0x0010000 98 sqlite3_test_control_pending_byte 0x0010000
93 99
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 # --soft-heap-limit=NN 387 # --soft-heap-limit=NN
382 # --maxerror=NN 388 # --maxerror=NN
383 # --malloctrace=N 389 # --malloctrace=N
384 # --backtrace=N 390 # --backtrace=N
385 # --binarylog=N 391 # --binarylog=N
386 # --soak=N 392 # --soak=N
387 # --file-retries=N 393 # --file-retries=N
388 # --file-retry-delay=N 394 # --file-retry-delay=N
389 # --start=[$permutation:]$testfile 395 # --start=[$permutation:]$testfile
390 # --match=$pattern 396 # --match=$pattern
397 # --verbose=$val
398 # --output=$filename
399 # --help
391 # 400 #
392 set cmdlinearg(soft-heap-limit) 0 401 set cmdlinearg(soft-heap-limit) 0
393 set cmdlinearg(maxerror) 1000 402 set cmdlinearg(maxerror) 1000
394 set cmdlinearg(malloctrace) 0 403 set cmdlinearg(malloctrace) 0
395 set cmdlinearg(backtrace) 10 404 set cmdlinearg(backtrace) 10
396 set cmdlinearg(binarylog) 0 405 set cmdlinearg(binarylog) 0
397 set cmdlinearg(soak) 0 406 set cmdlinearg(soak) 0
398 set cmdlinearg(file-retries) 0 407 set cmdlinearg(file-retries) 0
399 set cmdlinearg(file-retry-delay) 0 408 set cmdlinearg(file-retry-delay) 0
400 set cmdlinearg(start) "" 409 set cmdlinearg(start) ""
401 set cmdlinearg(match) "" 410 set cmdlinearg(match) ""
411 set cmdlinearg(verbose) ""
412 set cmdlinearg(output) ""
402 413
403 set leftover [list] 414 set leftover [list]
404 foreach a $argv { 415 foreach a $argv {
405 switch -regexp -- $a { 416 switch -regexp -- $a {
406 {^-+pause$} { 417 {^-+pause$} {
407 # Wait for user input before continuing. This is to give the user an 418 # Wait for user input before continuing. This is to give the user an
408 # opportunity to connect profiling tools to the process. 419 # opportunity to connect profiling tools to the process.
409 puts -nonewline "Press RETURN to begin..." 420 puts -nonewline "Press RETURN to begin..."
410 flush stdout 421 flush stdout
411 gets stdin 422 gets stdin
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 set ::G(start:file) ${s.file} 461 set ::G(start:file) ${s.file}
451 } 462 }
452 if {$::G(start:file) == ""} {unset ::G(start:file)} 463 if {$::G(start:file) == ""} {unset ::G(start:file)}
453 } 464 }
454 {^-+match=.+$} { 465 {^-+match=.+$} {
455 foreach {dummy cmdlinearg(match)} [split $a =] break 466 foreach {dummy cmdlinearg(match)} [split $a =] break
456 467
457 set ::G(match) $cmdlinearg(match) 468 set ::G(match) $cmdlinearg(match)
458 if {$::G(match) == ""} {unset ::G(match)} 469 if {$::G(match) == ""} {unset ::G(match)}
459 } 470 }
471
472 {^-+output=.+$} {
473 foreach {dummy cmdlinearg(output)} [split $a =] break
474 if {$cmdlinearg(verbose)==""} {
475 set cmdlinearg(verbose) 2
476 }
477 }
478 {^-+verbose=.+$} {
479 foreach {dummy cmdlinearg(verbose)} [split $a =] break
480 if {$cmdlinearg(verbose)=="file"} {
481 set cmdlinearg(verbose) 2
482 } elseif {[string is boolean -strict $cmdlinearg(verbose)]==0} {
483 error "option --verbose= must be set to a boolean or to \"file\""
484 }
485 }
486
460 default { 487 default {
461 lappend leftover $a 488 lappend leftover $a
462 } 489 }
463 } 490 }
464 } 491 }
465 set argv $leftover 492 set argv $leftover
466 493
467 # Install the malloc layer used to inject OOM errors. And the 'automatic' 494 # Install the malloc layer used to inject OOM errors. And the 'automatic'
468 # extensions. This only needs to be done once for the process. 495 # extensions. This only needs to be done once for the process.
469 # 496 #
470 sqlite3_shutdown 497 sqlite3_shutdown
471 install_malloc_faultsim 1 498 install_malloc_faultsim 1
472 sqlite3_initialize 499 sqlite3_initialize
473 autoinstall_test_functions 500 autoinstall_test_functions
474 501
475 # If the --binarylog option was specified, create the logging VFS. This 502 # If the --binarylog option was specified, create the logging VFS. This
476 # call installs the new VFS as the default for all SQLite connections. 503 # call installs the new VFS as the default for all SQLite connections.
477 # 504 #
478 if {$cmdlinearg(binarylog)} { 505 if {$cmdlinearg(binarylog)} {
479 vfslog new binarylog {} vfslog.bin 506 vfslog new binarylog {} vfslog.bin
480 } 507 }
481 508
482 # Set the backtrace depth, if malloc tracing is enabled. 509 # Set the backtrace depth, if malloc tracing is enabled.
483 # 510 #
484 if {$cmdlinearg(malloctrace)} { 511 if {$cmdlinearg(malloctrace)} {
485 sqlite3_memdebug_backtrace $cmdlinearg(backtrace) 512 sqlite3_memdebug_backtrace $cmdlinearg(backtrace)
486 } 513 }
514
515 if {$cmdlinearg(output)!=""} {
516 puts "Copying output to file $cmdlinearg(output)"
517 set ::G(output_fd) [open $cmdlinearg(output) w]
518 fconfigure $::G(output_fd) -buffering line
519 }
520
521 if {$cmdlinearg(verbose)==""} {
522 set cmdlinearg(verbose) 1
523 }
487 } 524 }
488 525
489 # Update the soft-heap-limit each time this script is run. In that 526 # Update the soft-heap-limit each time this script is run. In that
490 # way if an individual test file changes the soft-heap-limit, it 527 # way if an individual test file changes the soft-heap-limit, it
491 # will be reset at the start of the next test file. 528 # will be reset at the start of the next test file.
492 # 529 #
493 sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) 530 sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
494 531
495 # Create a test database 532 # Create a test database
496 # 533 #
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 # Record the fact that a test failed. 584 # Record the fact that a test failed.
548 # 585 #
549 proc fail_test {name} { 586 proc fail_test {name} {
550 set f [set_test_counter fail_list] 587 set f [set_test_counter fail_list]
551 lappend f $name 588 lappend f $name
552 set_test_counter fail_list $f 589 set_test_counter fail_list $f
553 set_test_counter errors [expr [set_test_counter errors] + 1] 590 set_test_counter errors [expr [set_test_counter errors] + 1]
554 591
555 set nFail [set_test_counter errors] 592 set nFail [set_test_counter errors]
556 if {$nFail>=$::cmdlinearg(maxerror)} { 593 if {$nFail>=$::cmdlinearg(maxerror)} {
557 puts "*** Giving up..." 594 output2 "*** Giving up..."
558 finalize_testing 595 finalize_testing
559 } 596 }
560 } 597 }
561 598
562 # Remember a warning message to be displayed at the conclusion of all testing 599 # Remember a warning message to be displayed at the conclusion of all testing
563 # 600 #
564 proc warning {msg {append 1}} { 601 proc warning {msg {append 1}} {
565 puts "Warning: $msg" 602 output2 "Warning: $msg"
566 set warnList [set_test_counter warn_list] 603 set warnList [set_test_counter warn_list]
567 if {$append} { 604 if {$append} {
568 lappend warnList $msg 605 lappend warnList $msg
569 } 606 }
570 set_test_counter warn_list $warnList 607 set_test_counter warn_list $warnList
571 } 608 }
572 609
573 610
574 # Increment the number of tests run 611 # Increment the number of tests run
575 # 612 #
576 proc incr_ntest {} { 613 proc incr_ntest {} {
577 set_test_counter count [expr [set_test_counter count] + 1] 614 set_test_counter count [expr [set_test_counter count] + 1]
578 } 615 }
579 616
617 # Return true if --verbose=1 was specified on the command line. Otherwise,
618 # return false.
619 #
620 proc verbose {} {
621 return $::cmdlinearg(verbose)
622 }
623
624 # Use the following commands instead of [puts] for test output within
625 # this file. Test scripts can still use regular [puts], which is directed
626 # to stdout and, if one is open, the --output file.
627 #
628 # output1: output that should be printed if --verbose=1 was specified.
629 # output2: output that should be printed unconditionally.
630 # output2_if_no_verbose: output that should be printed only if --verbose=0.
631 #
632 proc output1 {args} {
633 set v [verbose]
634 if {$v==1} {
635 uplevel output2 $args
636 } elseif {$v==2} {
637 uplevel puts [lrange $args 0 end-1] $::G(output_fd) [lrange $args end end]
638 }
639 }
640 proc output2 {args} {
641 set nArg [llength $args]
642 uplevel puts $args
643 }
644 proc output2_if_no_verbose {args} {
645 set v [verbose]
646 if {$v==0} {
647 uplevel output2 $args
648 } elseif {$v==2} {
649 uplevel puts [lrange $args 0 end-1] stdout [lrange $args end end]
650 }
651 }
652
653 # Override the [puts] command so that if no channel is explicitly
654 # specified the string is written to both stdout and to the file
655 # specified by "--output=", if any.
656 #
657 proc puts_override {args} {
658 set nArg [llength $args]
659 if {$nArg==1 || ($nArg==2 && [string first [lindex $args 0] -nonewline]==0)} {
660 uplevel puts_original $args
661 if {[info exists ::G(output_fd)]} {
662 uplevel puts [lrange $args 0 end-1] $::G(output_fd) [lrange $args end end]
663 }
664 } else {
665 # A channel was explicitly specified.
666 uplevel puts_original $args
667 }
668 }
669 rename puts puts_original
670 proc puts {args} { uplevel puts_override $args }
671
580 672
581 # Invoke the do_test procedure to run a single test 673 # Invoke the do_test procedure to run a single test
582 # 674 #
583 proc do_test {name cmd expected} { 675 proc do_test {name cmd expected} {
584 global argv cmdlinearg 676 global argv cmdlinearg
585 677
586 fix_testname name 678 fix_testname name
587 679
588 sqlite3_memdebug_settitle $name 680 sqlite3_memdebug_settitle $name
589 681
590 # if {[llength $argv]==0} { 682 # if {[llength $argv]==0} {
591 # set go 1 683 # set go 1
592 # } else { 684 # } else {
593 # set go 0 685 # set go 0
594 # foreach pattern $argv { 686 # foreach pattern $argv {
595 # if {[string match $pattern $name]} { 687 # if {[string match $pattern $name]} {
596 # set go 1 688 # set go 1
597 # break 689 # break
598 # } 690 # }
599 # } 691 # }
600 # } 692 # }
601 693
602 if {[info exists ::G(perm:prefix)]} { 694 if {[info exists ::G(perm:prefix)]} {
603 set name "$::G(perm:prefix)$name" 695 set name "$::G(perm:prefix)$name"
604 } 696 }
605 697
606 incr_ntest 698 incr_ntest
607 puts -nonewline $name... 699 output1 -nonewline $name...
608 flush stdout 700 flush stdout
609 701
610 if {![info exists ::G(match)] || [string match $::G(match) $name]} { 702 if {![info exists ::G(match)] || [string match $::G(match) $name]} {
611 if {[catch {uplevel #0 "$cmd;\n"} result]} { 703 if {[catch {uplevel #0 "$cmd;\n"} result]} {
612 puts "\nError: $result" 704 output2_if_no_verbose -nonewline $name...
705 output2 "\nError: $result"
613 fail_test $name 706 fail_test $name
614 } else { 707 } else {
615 if {[regexp {^~?/.*/$} $expected]} { 708 if {[regexp {^~?/.*/$} $expected]} {
616 # "expected" is of the form "/PATTERN/" then the result if correct if 709 # "expected" is of the form "/PATTERN/" then the result if correct if
617 # regular expression PATTERN matches the result. "~/PATTERN/" means 710 # regular expression PATTERN matches the result. "~/PATTERN/" means
618 # the regular expression must not match. 711 # the regular expression must not match.
619 if {[string index $expected 0]=="~"} { 712 if {[string index $expected 0]=="~"} {
620 set re [string range $expected 2 end-1] 713 set re [string range $expected 2 end-1]
621 if {[string index $re 0]=="*"} { 714 if {[string index $re 0]=="*"} {
622 # If the regular expression begins with * then treat it as a glob in stead 715 # If the regular expression begins with * then treat it as a glob in stead
(...skipping 23 matching lines...) Expand all
646 } else { 739 } else {
647 set ok [string match $expected $result] 740 set ok [string match $expected $result]
648 } 741 }
649 } else { 742 } else {
650 set ok [expr {[string compare $result $expected]==0}] 743 set ok [expr {[string compare $result $expected]==0}]
651 } 744 }
652 if {!$ok} { 745 if {!$ok} {
653 # if {![info exists ::testprefix] || $::testprefix eq ""} { 746 # if {![info exists ::testprefix] || $::testprefix eq ""} {
654 # error "no test prefix" 747 # error "no test prefix"
655 # } 748 # }
656 puts "\nExpected: \[$expected\]\n Got: \[$result\]" 749 output1 ""
750 output2 "! $name expected: \[$expected\]\n! $name got: \[$result\]"
657 fail_test $name 751 fail_test $name
658 } else { 752 } else {
659 puts " Ok" 753 output1 " Ok"
660 } 754 }
661 } 755 }
662 } else { 756 } else {
663 puts " Omitted" 757 output1 " Omitted"
664 omit_test $name "pattern mismatch" 0 758 omit_test $name "pattern mismatch" 0
665 } 759 }
666 flush stdout 760 flush stdout
667 } 761 }
668 762
763 proc dumpbytes {s} {
764 set r ""
765 for {set i 0} {$i < [string length $s]} {incr i} {
766 if {$i > 0} {append r " "}
767 append r [format %02X [scan [string index $s $i] %c]]
768 }
769 return $r
770 }
771
669 proc catchcmd {db {cmd ""}} { 772 proc catchcmd {db {cmd ""}} {
670 global CLI 773 global CLI
671 set out [open cmds.txt w] 774 set out [open cmds.txt w]
672 puts $out $cmd 775 puts $out $cmd
673 close $out 776 close $out
674 set line "exec $CLI $db < cmds.txt" 777 set line "exec $CLI $db < cmds.txt"
675 set rc [catch { eval $line } msg] 778 set rc [catch { eval $line } msg]
676 list $rc $msg 779 list $rc $msg
677 } 780 }
678 781
782 proc catchcmdex {db {cmd ""}} {
783 global CLI
784 set out [open cmds.txt w]
785 fconfigure $out -encoding binary -translation binary
786 puts -nonewline $out $cmd
787 close $out
788 set line "exec -keepnewline -- $CLI $db < cmds.txt"
789 set chans [list stdin stdout stderr]
790 foreach chan $chans {
791 catch {
792 set modes($chan) [fconfigure $chan]
793 fconfigure $chan -encoding binary -translation binary -buffering none
794 }
795 }
796 set rc [catch { eval $line } msg]
797 foreach chan $chans {
798 catch {
799 eval fconfigure [list $chan] $modes($chan)
800 }
801 }
802 # puts [dumpbytes $msg]
803 list $rc $msg
804 }
805
679 proc filepath_normalize {p} { 806 proc filepath_normalize {p} {
680 # test cases should be written to assume "unix"-like file paths 807 # test cases should be written to assume "unix"-like file paths
681 if {$::tcl_platform(platform)!="unix"} { 808 if {$::tcl_platform(platform)!="unix"} {
682 # lreverse*2 as a hack to remove any unneeded {} after the string map 809 # lreverse*2 as a hack to remove any unneeded {} after the string map
683 lreverse [lreverse [string map {\\ /} [regsub -nocase -all {[a-z]:[/\\]+} $p {/}]]] 810 lreverse [lreverse [string map {\\ /} [regsub -nocase -all {[a-z]:[/\\]+} $p {/}]]]
684 } { 811 } {
685 set p 812 set p
686 } 813 }
687 } 814 }
688 proc do_filepath_test {name cmd expected} { 815 proc do_filepath_test {name cmd expected} {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 proc delete_all_data {} { 924 proc delete_all_data {} {
798 db eval {SELECT tbl_name AS t FROM sqlite_master WHERE type = 'table'} { 925 db eval {SELECT tbl_name AS t FROM sqlite_master WHERE type = 'table'} {
799 db eval "DELETE FROM '[string map {' ''} $t]'" 926 db eval "DELETE FROM '[string map {' ''} $t]'"
800 } 927 }
801 } 928 }
802 929
803 # Run an SQL script. 930 # Run an SQL script.
804 # Return the number of microseconds per statement. 931 # Return the number of microseconds per statement.
805 # 932 #
806 proc speed_trial {name numstmt units sql} { 933 proc speed_trial {name numstmt units sql} {
807 puts -nonewline [format {%-21.21s } $name...] 934 output2 -nonewline [format {%-21.21s } $name...]
808 flush stdout 935 flush stdout
809 set speed [time {sqlite3_exec_nr db $sql}] 936 set speed [time {sqlite3_exec_nr db $sql}]
810 set tm [lindex $speed 0] 937 set tm [lindex $speed 0]
811 if {$tm == 0} { 938 if {$tm == 0} {
812 set rate [format %20s "many"] 939 set rate [format %20s "many"]
813 } else { 940 } else {
814 set rate [format %20.5f [expr {1000000.0*$numstmt/$tm}]] 941 set rate [format %20.5f [expr {1000000.0*$numstmt/$tm}]]
815 } 942 }
816 set u2 $units/s 943 set u2 $units/s
817 puts [format {%12d uS %s %s} $tm $rate $u2] 944 output2 [format {%12d uS %s %s} $tm $rate $u2]
818 global total_time 945 global total_time
819 set total_time [expr {$total_time+$tm}] 946 set total_time [expr {$total_time+$tm}]
820 lappend ::speed_trial_times $name $tm 947 lappend ::speed_trial_times $name $tm
821 } 948 }
822 proc speed_trial_tcl {name numstmt units script} { 949 proc speed_trial_tcl {name numstmt units script} {
823 puts -nonewline [format {%-21.21s } $name...] 950 output2 -nonewline [format {%-21.21s } $name...]
824 flush stdout 951 flush stdout
825 set speed [time {eval $script}] 952 set speed [time {eval $script}]
826 set tm [lindex $speed 0] 953 set tm [lindex $speed 0]
827 if {$tm == 0} { 954 if {$tm == 0} {
828 set rate [format %20s "many"] 955 set rate [format %20s "many"]
829 } else { 956 } else {
830 set rate [format %20.5f [expr {1000000.0*$numstmt/$tm}]] 957 set rate [format %20.5f [expr {1000000.0*$numstmt/$tm}]]
831 } 958 }
832 set u2 $units/s 959 set u2 $units/s
833 puts [format {%12d uS %s %s} $tm $rate $u2] 960 output2 [format {%12d uS %s %s} $tm $rate $u2]
834 global total_time 961 global total_time
835 set total_time [expr {$total_time+$tm}] 962 set total_time [expr {$total_time+$tm}]
836 lappend ::speed_trial_times $name $tm 963 lappend ::speed_trial_times $name $tm
837 } 964 }
838 proc speed_trial_init {name} { 965 proc speed_trial_init {name} {
839 global total_time 966 global total_time
840 set total_time 0 967 set total_time 0
841 set ::speed_trial_times [list] 968 set ::speed_trial_times [list]
842 sqlite3 versdb :memory: 969 sqlite3 versdb :memory:
843 set vers [versdb one {SELECT sqlite_source_id()}] 970 set vers [versdb one {SELECT sqlite_source_id()}]
844 versdb close 971 versdb close
845 puts "SQLite $vers" 972 output2 "SQLite $vers"
846 } 973 }
847 proc speed_trial_summary {name} { 974 proc speed_trial_summary {name} {
848 global total_time 975 global total_time
849 puts [format {%-21.21s %12d uS TOTAL} $name $total_time] 976 output2 [format {%-21.21s %12d uS TOTAL} $name $total_time]
850 977
851 if { 0 } { 978 if { 0 } {
852 sqlite3 versdb :memory: 979 sqlite3 versdb :memory:
853 set vers [lindex [versdb one {SELECT sqlite_source_id()}] 0] 980 set vers [lindex [versdb one {SELECT sqlite_source_id()}] 0]
854 versdb close 981 versdb close
855 puts "CREATE TABLE IF NOT EXISTS time(version, script, test, us);" 982 output2 "CREATE TABLE IF NOT EXISTS time(version, script, test, us);"
856 foreach {test us} $::speed_trial_times { 983 foreach {test us} $::speed_trial_times {
857 puts "INSERT INTO time VALUES('$vers', '$name', '$test', $us);" 984 output2 "INSERT INTO time VALUES('$vers', '$name', '$test', $us);"
858 } 985 }
859 } 986 }
860 } 987 }
861 988
862 # Run this routine last 989 # Run this routine last
863 # 990 #
864 proc finish_test {} { 991 proc finish_test {} {
865 catch {db close} 992 catch {db close}
866 catch {db1 close} 993 catch {db1 close}
867 catch {db2 close} 994 catch {db2 close}
(...skipping 23 matching lines...) Expand all
891 if {[file readable known-problems.txt]} { 1018 if {[file readable known-problems.txt]} {
892 set fd [open known-problems.txt] 1019 set fd [open known-problems.txt]
893 set content [read $fd] 1020 set content [read $fd]
894 close $fd 1021 close $fd
895 foreach x $content {set known_error($x) 1} 1022 foreach x $content {set known_error($x) 1}
896 foreach x [set_test_counter fail_list] { 1023 foreach x [set_test_counter fail_list] {
897 if {[info exists known_error($x)]} {incr nKnown} 1024 if {[info exists known_error($x)]} {incr nKnown}
898 } 1025 }
899 } 1026 }
900 if {$nKnown>0} { 1027 if {$nKnown>0} {
901 puts "[expr {$nErr-$nKnown}] new errors and $nKnown known errors\ 1028 output2 "[expr {$nErr-$nKnown}] new errors and $nKnown known errors\
902 out of $nTest tests" 1029 out of $nTest tests"
903 } else { 1030 } else {
904 puts "$nErr errors out of $nTest tests" 1031 output2 "$nErr errors out of $nTest tests"
905 } 1032 }
906 if {$nErr>$nKnown} { 1033 if {$nErr>$nKnown} {
907 puts -nonewline "Failures on these tests:" 1034 output2 -nonewline "!Failures on these tests:"
908 foreach x [set_test_counter fail_list] { 1035 foreach x [set_test_counter fail_list] {
909 if {![info exists known_error($x)]} {puts -nonewline " $x"} 1036 if {![info exists known_error($x)]} {output2 -nonewline " $x"}
910 } 1037 }
911 puts "" 1038 output2 ""
912 } 1039 }
913 foreach warning [set_test_counter warn_list] { 1040 foreach warning [set_test_counter warn_list] {
914 puts "Warning: $warning" 1041 output2 "Warning: $warning"
915 } 1042 }
916 run_thread_tests 1 1043 run_thread_tests 1
917 if {[llength $omitList]>0} { 1044 if {[llength $omitList]>0} {
918 puts "Omitted test cases:" 1045 output2 "Omitted test cases:"
919 set prec {} 1046 set prec {}
920 foreach {rec} [lsort $omitList] { 1047 foreach {rec} [lsort $omitList] {
921 if {$rec==$prec} continue 1048 if {$rec==$prec} continue
922 set prec $rec 1049 set prec $rec
923 puts [format { %-12s %s} [lindex $rec 0] [lindex $rec 1]] 1050 output2 [format {. %-12s %s} [lindex $rec 0] [lindex $rec 1]]
924 } 1051 }
925 } 1052 }
926 if {$nErr>0 && ![working_64bit_int]} { 1053 if {$nErr>0 && ![working_64bit_int]} {
927 puts "******************************************************************" 1054 output2 "******************************************************************"
928 puts "N.B.: The version of TCL that you used to build this test harness" 1055 output2 "N.B.: The version of TCL that you used to build this test harness"
929 puts "is defective in that it does not support 64-bit integers. Some or" 1056 output2 "is defective in that it does not support 64-bit integers. Some or"
930 puts "all of the test failures above might be a result from this defect" 1057 output2 "all of the test failures above might be a result from this defect"
931 puts "in your TCL build." 1058 output2 "in your TCL build."
932 puts "******************************************************************" 1059 output2 "******************************************************************"
933 } 1060 }
934 if {$::cmdlinearg(binarylog)} { 1061 if {$::cmdlinearg(binarylog)} {
935 vfslog finalize binarylog 1062 vfslog finalize binarylog
936 } 1063 }
937 if {$sqlite_open_file_count} { 1064 if {$sqlite_open_file_count} {
938 puts "$sqlite_open_file_count files were left open" 1065 output2 "$sqlite_open_file_count files were left open"
939 incr nErr 1066 incr nErr
940 } 1067 }
941 if {[lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1]>0 || 1068 if {[lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1]>0 ||
942 [sqlite3_memory_used]>0} { 1069 [sqlite3_memory_used]>0} {
943 puts "Unfreed memory: [sqlite3_memory_used] bytes in\ 1070 output2 "Unfreed memory: [sqlite3_memory_used] bytes in\
944 [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1] allocations" 1071 [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1] allocations"
945 incr nErr 1072 incr nErr
946 ifcapable memdebug||mem5||(mem3&&debug) { 1073 ifcapable memdebug||mem5||(mem3&&debug) {
947 puts "Writing unfreed memory log to \"./memleak.txt\"" 1074 output2 "Writing unfreed memory log to \"./memleak.txt\""
948 sqlite3_memdebug_dump ./memleak.txt 1075 sqlite3_memdebug_dump ./memleak.txt
949 } 1076 }
950 } else { 1077 } else {
951 puts "All memory allocations freed - no leaks" 1078 output2 "All memory allocations freed - no leaks"
952 ifcapable memdebug||mem5 { 1079 ifcapable memdebug||mem5 {
953 sqlite3_memdebug_dump ./memusage.txt 1080 sqlite3_memdebug_dump ./memusage.txt
954 } 1081 }
955 } 1082 }
956 show_memstats 1083 show_memstats
957 puts "Maximum memory usage: [sqlite3_memory_highwater 1] bytes" 1084 output2 "Maximum memory usage: [sqlite3_memory_highwater 1] bytes"
958 puts "Current memory usage: [sqlite3_memory_highwater] bytes" 1085 output2 "Current memory usage: [sqlite3_memory_highwater] bytes"
959 if {[info commands sqlite3_memdebug_malloc_count] ne ""} { 1086 if {[info commands sqlite3_memdebug_malloc_count] ne ""} {
960 puts "Number of malloc() : [sqlite3_memdebug_malloc_count] calls" 1087 output2 "Number of malloc() : [sqlite3_memdebug_malloc_count] calls"
961 } 1088 }
962 if {$::cmdlinearg(malloctrace)} { 1089 if {$::cmdlinearg(malloctrace)} {
963 puts "Writing mallocs.sql..." 1090 output2 "Writing mallocs.sql..."
964 memdebug_log_sql 1091 memdebug_log_sql
965 sqlite3_memdebug_log stop 1092 sqlite3_memdebug_log stop
966 sqlite3_memdebug_log clear 1093 sqlite3_memdebug_log clear
967 1094
968 if {[sqlite3_memory_used]>0} { 1095 if {[sqlite3_memory_used]>0} {
969 puts "Writing leaks.sql..." 1096 output2 "Writing leaks.sql..."
970 sqlite3_memdebug_log sync 1097 sqlite3_memdebug_log sync
971 memdebug_log_sql leaks.sql 1098 memdebug_log_sql leaks.sql
972 } 1099 }
973 } 1100 }
974 foreach f [glob -nocomplain test.db-*-journal] { 1101 foreach f [glob -nocomplain test.db-*-journal] {
975 forcedelete $f 1102 forcedelete $f
976 } 1103 }
977 foreach f [glob -nocomplain test.db-mj*] { 1104 foreach f [glob -nocomplain test.db-mj*] {
978 forcedelete $f 1105 forcedelete $f
979 } 1106 }
980 exit [expr {$nErr>0}] 1107 exit [expr {$nErr>0}]
981 } 1108 }
982 1109
983 # Display memory statistics for analysis and debugging purposes. 1110 # Display memory statistics for analysis and debugging purposes.
984 # 1111 #
985 proc show_memstats {} { 1112 proc show_memstats {} {
986 set x [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1113 set x [sqlite3_status SQLITE_STATUS_MEMORY_USED 0]
987 set y [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 1114 set y [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0]
988 set val [format {now %10d max %10d max-size %10d} \ 1115 set val [format {now %10d max %10d max-size %10d} \
989 [lindex $x 1] [lindex $x 2] [lindex $y 2]] 1116 [lindex $x 1] [lindex $x 2] [lindex $y 2]]
990 puts "Memory used: $val" 1117 output1 "Memory used: $val"
991 set x [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1118 set x [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0]
992 set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]] 1119 set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]]
993 puts "Allocation count: $val" 1120 output1 "Allocation count: $val"
994 set x [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1121 set x [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0]
995 set y [sqlite3_status SQLITE_STATUS_PAGECACHE_SIZE 0] 1122 set y [sqlite3_status SQLITE_STATUS_PAGECACHE_SIZE 0]
996 set val [format {now %10d max %10d max-size %10d} \ 1123 set val [format {now %10d max %10d max-size %10d} \
997 [lindex $x 1] [lindex $x 2] [lindex $y 2]] 1124 [lindex $x 1] [lindex $x 2] [lindex $y 2]]
998 puts "Page-cache used: $val" 1125 output1 "Page-cache used: $val"
999 set x [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 1126 set x [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0]
1000 set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]] 1127 set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]]
1001 puts "Page-cache overflow: $val" 1128 output1 "Page-cache overflow: $val"
1002 set x [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 1129 set x [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0]
1003 set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]] 1130 set val [format {now %10d max %10d} [lindex $x 1] [lindex $x 2]]
1004 puts "Scratch memory used: $val" 1131 output1 "Scratch memory used: $val"
1005 set x [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 1132 set x [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0]
1006 set y [sqlite3_status SQLITE_STATUS_SCRATCH_SIZE 0] 1133 set y [sqlite3_status SQLITE_STATUS_SCRATCH_SIZE 0]
1007 set val [format {now %10d max %10d max-size %10d} \ 1134 set val [format {now %10d max %10d max-size %10d} \
1008 [lindex $x 1] [lindex $x 2] [lindex $y 2]] 1135 [lindex $x 1] [lindex $x 2] [lindex $y 2]]
1009 puts "Scratch overflow: $val" 1136 output1 "Scratch overflow: $val"
1010 ifcapable yytrackmaxstackdepth { 1137 ifcapable yytrackmaxstackdepth {
1011 set x [sqlite3_status SQLITE_STATUS_PARSER_STACK 0] 1138 set x [sqlite3_status SQLITE_STATUS_PARSER_STACK 0]
1012 set val [format { max %10d} [lindex $x 2]] 1139 set val [format { max %10d} [lindex $x 2]]
1013 puts "Parser stack depth: $val" 1140 output2 "Parser stack depth: $val"
1014 } 1141 }
1015 } 1142 }
1016 1143
1017 # A procedure to execute SQL 1144 # A procedure to execute SQL
1018 # 1145 #
1019 proc execsql {sql {db db}} { 1146 proc execsql {sql {db db}} {
1020 # puts "SQL = $sql" 1147 # puts "SQL = $sql"
1021 uplevel [list $db eval $sql] 1148 uplevel [list $db eval $sql]
1022 } 1149 }
1023 proc execsql_timed {sql {db db}} { 1150 proc execsql_timed {sql {db db}} {
1024 set tm [time { 1151 set tm [time {
1025 set x [uplevel [list $db eval $sql]] 1152 set x [uplevel [list $db eval $sql]]
1026 } 1] 1153 } 1]
1027 set tm [lindex $tm 0] 1154 set tm [lindex $tm 0]
1028 puts -nonewline " ([expr {$tm*0.001}]ms) " 1155 output1 -nonewline " ([expr {$tm*0.001}]ms) "
1029 set x 1156 set x
1030 } 1157 }
1031 1158
1032 # Execute SQL and catch exceptions. 1159 # Execute SQL and catch exceptions.
1033 # 1160 #
1034 proc catchsql {sql {db db}} { 1161 proc catchsql {sql {db db}} {
1035 # puts "SQL = $sql" 1162 # puts "SQL = $sql"
1036 set r [catch [list uplevel [list $db eval $sql]] msg] 1163 set r [catch [list uplevel [list $db eval $sql]] msg]
1037 lappend r $msg 1164 lappend r $msg
1038 return $r 1165 return $r
1039 } 1166 }
1040 1167
1041 # Do an VDBE code dump on the SQL given 1168 # Do an VDBE code dump on the SQL given
1042 # 1169 #
1043 proc explain {sql {db db}} { 1170 proc explain {sql {db db}} {
1044 puts "" 1171 output2 ""
1045 puts "addr opcode p1 p2 p3 p4 p5 #" 1172 output2 "addr opcode p1 p2 p3 p4 p5 #"
1046 puts "---- ------------ ------ ------ ------ --------------- -- -" 1173 output2 "---- ------------ ------ ------ ------ --------------- -- -"
1047 $db eval "explain $sql" {} { 1174 $db eval "explain $sql" {} {
1048 puts [format {%-4d %-12.12s %-6d %-6d %-6d % -17s %s %s} \ 1175 output2 [format {%-4d %-12.12s %-6d %-6d %-6d % -17s %s %s} \
1049 $addr $opcode $p1 $p2 $p3 $p4 $p5 $comment 1176 $addr $opcode $p1 $p2 $p3 $p4 $p5 $comment
1050 ] 1177 ]
1051 } 1178 }
1052 } 1179 }
1053 1180
1054 proc explain_i {sql {db db}} { 1181 proc explain_i {sql {db db}} {
1055 puts "" 1182 output2 ""
1056 puts "addr opcode p1 p2 p3 p4 p5 #" 1183 output2 "addr opcode p1 p2 p3 p4 p5 #"
1057 puts "---- ------------ ------ ------ ------ ---------------- -- -" 1184 output2 "---- ------------ ------ ------ ------ ---------------- -- -"
1058 1185
1059 1186
1060 # Set up colors for the different opcodes. Scheme is as follows: 1187 # Set up colors for the different opcodes. Scheme is as follows:
1061 # 1188 #
1062 # Red: Opcodes that write to a b-tree. 1189 # Red: Opcodes that write to a b-tree.
1063 # Blue: Opcodes that reposition or seek a cursor. 1190 # Blue: Opcodes that reposition or seek a cursor.
1064 # Green: The ResultRow opcode. 1191 # Green: The ResultRow opcode.
1065 # 1192 #
1066 if { [catch {fconfigure stdout -mode}]==0 } { 1193 if { [catch {fconfigure stdout -mode}]==0 } {
1067 set R "\033\[31;1m" ;# Red fg 1194 set R "\033\[31;1m" ;# Red fg
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 } 1240 }
1114 } 1241 }
1115 1242
1116 if {$opcode == "Halt" && $comment == "End of coroutine"} { 1243 if {$opcode == "Halt" && $comment == "End of coroutine"} {
1117 set linebreak([expr $addr+1]) 1 1244 set linebreak([expr $addr+1]) 1
1118 } 1245 }
1119 } 1246 }
1120 1247
1121 $db eval "explain $sql" {} { 1248 $db eval "explain $sql" {} {
1122 if {[info exists linebreak($addr)]} { 1249 if {[info exists linebreak($addr)]} {
1123 puts "" 1250 output2 ""
1124 } 1251 }
1125 set I [string repeat " " $x($addr)] 1252 set I [string repeat " " $x($addr)]
1126 1253
1127 set col "" 1254 set col ""
1128 catch { set col $color($opcode) } 1255 catch { set col $color($opcode) }
1129 1256
1130 puts [format {%-4d %s%s%-12.12s%s %-6d %-6d %-6d % -17s %s %s} \ 1257 output2 [format {%-4d %s%s%-12.12s%s %-6d %-6d %-6d % -17s %s %s} \
1131 $addr $I $col $opcode $D $p1 $p2 $p3 $p4 $p5 $comment 1258 $addr $I $col $opcode $D $p1 $p2 $p3 $p4 $p5 $comment
1132 ] 1259 ]
1133 } 1260 }
1134 puts "---- ------------ ------ ------ ------ ---------------- -- -" 1261 output2 "---- ------------ ------ ------ ------ ---------------- -- -"
1135 } 1262 }
1136 1263
1137 # Show the VDBE program for an SQL statement but omit the Trace 1264 # Show the VDBE program for an SQL statement but omit the Trace
1138 # opcode at the beginning. This procedure can be used to prove 1265 # opcode at the beginning. This procedure can be used to prove
1139 # that different SQL statements generate exactly the same VDBE code. 1266 # that different SQL statements generate exactly the same VDBE code.
1140 # 1267 #
1141 proc explain_no_trace {sql} { 1268 proc explain_no_trace {sql} {
1142 set tr [db eval "EXPLAIN $sql"] 1269 set tr [db eval "EXPLAIN $sql"]
1143 return [lrange $tr 7 end] 1270 return [lrange $tr 7 end]
1144 } 1271 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 1429
1303 # $crashfile gets compared to the native filename in 1430 # $crashfile gets compared to the native filename in
1304 # cfSync(), which can be different then what TCL uses by 1431 # cfSync(), which can be different then what TCL uses by
1305 # default, so here we force it to the "nativename" format. 1432 # default, so here we force it to the "nativename" format.
1306 set cfile [string map {\\ \\\\} [file nativename [file join [get_pwd] $crashfi le]]] 1433 set cfile [string map {\\ \\\\} [file nativename [file join [get_pwd] $crashfi le]]]
1307 1434
1308 set f [open crash.tcl w] 1435 set f [open crash.tcl w]
1309 puts $f "sqlite3_crash_enable 1" 1436 puts $f "sqlite3_crash_enable 1"
1310 puts $f "sqlite3_crashparams $blocksize $dc $crashdelay $cfile" 1437 puts $f "sqlite3_crashparams $blocksize $dc $crashdelay $cfile"
1311 puts $f "sqlite3_test_control_pending_byte $::sqlite_pending_byte" 1438 puts $f "sqlite3_test_control_pending_byte $::sqlite_pending_byte"
1312 puts $f $opendb
1313 1439
1314 # This block sets the cache size of the main database to 10 1440 # This block sets the cache size of the main database to 10
1315 # pages. This is done in case the build is configured to omit 1441 # pages. This is done in case the build is configured to omit
1316 # "PRAGMA cache_size". 1442 # "PRAGMA cache_size".
1317 puts $f {db eval {SELECT * FROM sqlite_master;}} 1443 if {$opendb!=""} {
1318 puts $f {set bt [btree_from_db db]} 1444 puts $f $opendb
1319 puts $f {btree_set_cache_size $bt 10} 1445 puts $f {db eval {SELECT * FROM sqlite_master;}}
1446 puts $f {set bt [btree_from_db db]}
1447 puts $f {btree_set_cache_size $bt 10}
1448 }
1320 1449
1321 if {$prngseed} { 1450 if {$prngseed} {
1322 set seed [expr {$prngseed%10007+1}] 1451 set seed [expr {$prngseed%10007+1}]
1323 # puts seed=$seed 1452 # puts seed=$seed
1324 puts $f "db eval {SELECT randomblob($seed)}" 1453 puts $f "db eval {SELECT randomblob($seed)}"
1325 } 1454 }
1326 1455
1327 if {[string length $tclbody]>0} { 1456 if {[string length $tclbody]>0} {
1328 puts $f $tclbody 1457 puts $f $tclbody
1329 } 1458 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 # be the same as before the script that caused the IO error was run. 1682 # be the same as before the script that caused the IO error was run.
1554 # 1683 #
1555 if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-cksum)} { 1684 if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-cksum)} {
1556 do_test $testname.$n.6 { 1685 do_test $testname.$n.6 {
1557 catch {db close} 1686 catch {db close}
1558 catch {db2 close} 1687 catch {db2 close}
1559 set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db] 1688 set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
1560 set nowcksum [cksum] 1689 set nowcksum [cksum]
1561 set res [expr {$nowcksum==$::checksum || $nowcksum==$::goodcksum}] 1690 set res [expr {$nowcksum==$::checksum || $nowcksum==$::goodcksum}]
1562 if {$res==0} { 1691 if {$res==0} {
1563 puts "now=$nowcksum" 1692 output2 "now=$nowcksum"
1564 puts "the=$::checksum" 1693 output2 "the=$::checksum"
1565 puts "fwd=$::goodcksum" 1694 output2 "fwd=$::goodcksum"
1566 } 1695 }
1567 set res 1696 set res
1568 } 1 1697 } 1
1569 } 1698 }
1570 1699
1571 set ::sqlite_io_error_hardhit 0 1700 set ::sqlite_io_error_hardhit 0
1572 set ::sqlite_io_error_pending 0 1701 set ::sqlite_io_error_pending 0
1573 if {[info exists ::ioerropts(-cleanup)]} { 1702 if {[info exists ::ioerropts(-cleanup)]} {
1574 catch $::ioerropts(-cleanup) 1703 catch $::ioerropts(-cleanup)
1575 } 1704 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 1908
1780 # Populate some global variables that tester.tcl expects to see. 1909 # Populate some global variables that tester.tcl expects to see.
1781 foreach {var value} [list \ 1910 foreach {var value} [list \
1782 ::argv0 $::argv0 \ 1911 ::argv0 $::argv0 \
1783 ::argv {} \ 1912 ::argv {} \
1784 ::SLAVE 1 \ 1913 ::SLAVE 1 \
1785 ] { 1914 ] {
1786 interp eval tinterp [list set $var $value] 1915 interp eval tinterp [list set $var $value]
1787 } 1916 }
1788 1917
1918 # If output is being copied into a file, share the file-descriptor with
1919 # the interpreter.
1920 if {[info exists ::G(output_fd)]} {
1921 interp share {} $::G(output_fd) tinterp
1922 }
1923
1789 # The alias used to access the global test counters. 1924 # The alias used to access the global test counters.
1790 tinterp alias set_test_counter set_test_counter 1925 tinterp alias set_test_counter set_test_counter
1791 1926
1792 # Set up the ::cmdlinearg array in the slave. 1927 # Set up the ::cmdlinearg array in the slave.
1793 interp eval tinterp [list array set ::cmdlinearg [array get ::cmdlinearg]] 1928 interp eval tinterp [list array set ::cmdlinearg [array get ::cmdlinearg]]
1794 1929
1795 # Set up the ::G array in the slave. 1930 # Set up the ::G array in the slave.
1796 interp eval tinterp [list array set ::G [array get ::G]] 1931 interp eval tinterp [list array set ::G [array get ::G]]
1797 1932
1798 # Load the various test interfaces implemented in C. 1933 # Load the various test interfaces implemented in C.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 # Test that the global "shared-cache" setting was not altered by 1982 # Test that the global "shared-cache" setting was not altered by
1848 # the test script. 1983 # the test script.
1849 # 1984 #
1850 ifcapable shared_cache { 1985 ifcapable shared_cache {
1851 set res [expr {[sqlite3_enable_shared_cache] == $scs}] 1986 set res [expr {[sqlite3_enable_shared_cache] == $scs}]
1852 do_test ${tail}-sharedcachesetting [list set {} $res] 1 1987 do_test ${tail}-sharedcachesetting [list set {} $res] 1
1853 } 1988 }
1854 1989
1855 # Add some info to the output. 1990 # Add some info to the output.
1856 # 1991 #
1857 puts "Time: $tail $ms ms" 1992 output2 "Time: $tail $ms ms"
1858 show_memstats 1993 show_memstats
1859 } 1994 }
1860 1995
1861 # Open a new connection on database test.db and execute the SQL script 1996 # Open a new connection on database test.db and execute the SQL script
1862 # supplied as an argument. Before returning, close the new conection and 1997 # supplied as an argument. Before returning, close the new conection and
1863 # restore the 4 byte fields starting at header offsets 28, 92 and 96 1998 # restore the 4 byte fields starting at header offsets 28, 92 and 96
1864 # to the values they held before the SQL was executed. This simulates 1999 # to the values they held before the SQL was executed. This simulates
1865 # a write by a pre-3.7.0 client. 2000 # a write by a pre-3.7.0 client.
1866 # 2001 #
1867 proc sql36231 {sql} { 2002 proc sql36231 {sql} {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 catch { db close } 2034 catch { db close }
1900 db_restore 2035 db_restore
1901 sqlite3 db $dbfile 2036 sqlite3 db $dbfile
1902 } 2037 }
1903 proc db_delete_and_reopen {{file test.db}} { 2038 proc db_delete_and_reopen {{file test.db}} {
1904 catch { db close } 2039 catch { db close }
1905 foreach f [glob -nocomplain test.db*] { forcedelete $f } 2040 foreach f [glob -nocomplain test.db*] { forcedelete $f }
1906 sqlite3 db $file 2041 sqlite3 db $file
1907 } 2042 }
1908 2043
2044 # Close any connections named [db], [db2] or [db3]. Then use sqlite3_config
2045 # to configure the size of the PAGECACHE allocation using the parameters
2046 # provided to this command. Save the old PAGECACHE parameters in a global
2047 # variable so that [test_restore_config_pagecache] can restore the previous
2048 # configuration.
2049 #
2050 # Before returning, reopen connection [db] on file test.db.
2051 #
2052 proc test_set_config_pagecache {sz nPg} {
2053 catch {db close}
2054 catch {db2 close}
2055 catch {db3 close}
2056
2057 sqlite3_shutdown
2058 set ::old_pagecache_config [sqlite3_config_pagecache $sz $nPg]
2059 sqlite3_initialize
2060 autoinstall_test_functions
2061 reset_db
2062 }
2063
2064 # Close any connections named [db], [db2] or [db3]. Then use sqlite3_config
2065 # to configure the size of the PAGECACHE allocation to the size saved in
2066 # the global variable by an earlier call to [test_set_config_pagecache].
2067 #
2068 # Before returning, reopen connection [db] on file test.db.
2069 #
2070 proc test_restore_config_pagecache {} {
2071 catch {db close}
2072 catch {db2 close}
2073 catch {db3 close}
2074
2075 sqlite3_shutdown
2076 eval sqlite3_config_pagecache $::old_pagecache_config
2077 unset ::old_pagecache_config
2078 sqlite3_initialize
2079 autoinstall_test_functions
2080 sqlite3 db test.db
2081 }
2082
1909 # If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set 2083 # If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
1910 # to non-zero, then set the global variable $AUTOVACUUM to 1. 2084 # to non-zero, then set the global variable $AUTOVACUUM to 1.
1911 set AUTOVACUUM $sqlite_options(default_autovacuum) 2085 set AUTOVACUUM $sqlite_options(default_autovacuum)
1912 2086
1913 # Make sure the FTS enhanced query syntax is disabled. 2087 # Make sure the FTS enhanced query syntax is disabled.
1914 set sqlite_fts3_enable_parentheses 0 2088 set sqlite_fts3_enable_parentheses 0
1915 2089
1916 # During testing, assume that all database files are well-formed. The 2090 # During testing, assume that all database files are well-formed. The
1917 # few test cases that deliberately corrupt database files should rescind 2091 # few test cases that deliberately corrupt database files should rescind
1918 # this setting by invoking "database_can_be_corrupt" 2092 # this setting by invoking "database_can_be_corrupt"
1919 # 2093 #
1920 database_never_corrupt 2094 database_never_corrupt
1921 2095
1922 source $testdir/thread_common.tcl 2096 source $testdir/thread_common.tcl
1923 source $testdir/malloc_common.tcl 2097 source $testdir/malloc_common.tcl
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/tclsqlite.test ('k') | third_party/sqlite/src/test/threadtest2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698