Fossil SCM
Change delta1.test so it generates its own input rather than using whatever is under test/. Runs thousands fewer tests with same gcov coverage. Fix 1/2 of speeding up test suite 3x.
Commit
6aa0ed0f3f078649f3c0c6832acc28e9e80abf1290e40ff7445088d66608bb21
Parent
af4f568b3b35832…
2 files changed
+27
-7
+42
+27
-7
| --- test/delta1.test | ||
| +++ test/delta1.test | ||
| @@ -18,22 +18,42 @@ | ||
| 18 | 18 | # Tests of the delta mechanism. |
| 19 | 19 | # |
| 20 | 20 | |
| 21 | 21 | test_setup "" |
| 22 | 22 | |
| 23 | -# Use test script files as the basis for this test. | |
| 23 | +# Use generated text of several kinds as the basis for this test: | |
| 24 | +# ASCII text, a large file, long lines, CR/LF line endings, UTF-8 text | |
| 25 | +# in Greek, in Chinese and in four-byte characters, UTF-16 text in both | |
| 26 | +# byte orders, a file of four lines and a line that has no newline. | |
| 24 | 27 | # |
| 25 | -# For each test, copy the file intact to "./t1". Make | |
| 28 | +# For each text, write the text intact to "./t1". Make | |
| 26 | 29 | # some random changes in "./t2". Then call test-delta on the |
| 27 | 30 | # two files to make sure that deltas between these two files |
| 28 | 31 | # work properly. |
| 29 | 32 | # |
| 30 | -set filelist [lsort [glob $testdir/*]] | |
| 31 | -foreach f $filelist { | |
| 32 | - if {[file isdir $f]} continue | |
| 33 | - set base [file root [file tail $f]] | |
| 34 | - set f1 [read_file $f] | |
| 33 | +set fourbyte {} | |
| 34 | +for {set i 0} {$i<40} {incr i} { | |
| 35 | + set char [binary format H6c f0a080 [expr {0x80+$i}]] | |
| 36 | + append fourbyte [string repeat $char [expr {$i%7+3}]]\n | |
| 37 | +} | |
| 38 | +set greek [fixed_word_lines 200 0x3b1] | |
| 39 | +set utf16 [lmap c [split \ufeff$greek ""] {scan $c %c}] | |
| 40 | +set inputs [list \ | |
| 41 | + ascii [fixed_word_lines 400] \ | |
| 42 | + large [fixed_word_lines 5000] \ | |
| 43 | + longlines [fixed_word_lines 60 97 150] \ | |
| 44 | + crlf [string map [list \n \r\n] [fixed_word_lines 100]] \ | |
| 45 | + repeats [fixed_word_lines 4000 97 1 1] \ | |
| 46 | + utf8 [encoding convertto utf-8 $greek] \ | |
| 47 | + cjk [encoding convertto utf-8 [fixed_word_lines 200 0x4e00]] \ | |
| 48 | + fourbyte $fourbyte \ | |
| 49 | + utf16le [binary format s* $utf16] \ | |
| 50 | + utf16be [binary format S* $utf16] \ | |
| 51 | + short [fixed_word_lines 4] \ | |
| 52 | + oneline "one line that has no newline" \ | |
| 53 | +] | |
| 54 | +foreach {base f1} $inputs { | |
| 35 | 55 | write_file t1 $f1 |
| 36 | 56 | for {set i 0} {$i<100} {incr i} { |
| 37 | 57 | write_file t2 [random_changes $f1 1 1 0 0.1] |
| 38 | 58 | fossil test-delta t1 t2 |
| 39 | 59 | test delta-$base-$i-1 {[normalize_result]=="ok"} |
| 40 | 60 |
| --- test/delta1.test | |
| +++ test/delta1.test | |
| @@ -18,22 +18,42 @@ | |
| 18 | # Tests of the delta mechanism. |
| 19 | # |
| 20 | |
| 21 | test_setup "" |
| 22 | |
| 23 | # Use test script files as the basis for this test. |
| 24 | # |
| 25 | # For each test, copy the file intact to "./t1". Make |
| 26 | # some random changes in "./t2". Then call test-delta on the |
| 27 | # two files to make sure that deltas between these two files |
| 28 | # work properly. |
| 29 | # |
| 30 | set filelist [lsort [glob $testdir/*]] |
| 31 | foreach f $filelist { |
| 32 | if {[file isdir $f]} continue |
| 33 | set base [file root [file tail $f]] |
| 34 | set f1 [read_file $f] |
| 35 | write_file t1 $f1 |
| 36 | for {set i 0} {$i<100} {incr i} { |
| 37 | write_file t2 [random_changes $f1 1 1 0 0.1] |
| 38 | fossil test-delta t1 t2 |
| 39 | test delta-$base-$i-1 {[normalize_result]=="ok"} |
| 40 |
| --- test/delta1.test | |
| +++ test/delta1.test | |
| @@ -18,22 +18,42 @@ | |
| 18 | # Tests of the delta mechanism. |
| 19 | # |
| 20 | |
| 21 | test_setup "" |
| 22 | |
| 23 | # Use generated text of several kinds as the basis for this test: |
| 24 | # ASCII text, a large file, long lines, CR/LF line endings, UTF-8 text |
| 25 | # in Greek, in Chinese and in four-byte characters, UTF-16 text in both |
| 26 | # byte orders, a file of four lines and a line that has no newline. |
| 27 | # |
| 28 | # For each text, write the text intact to "./t1". Make |
| 29 | # some random changes in "./t2". Then call test-delta on the |
| 30 | # two files to make sure that deltas between these two files |
| 31 | # work properly. |
| 32 | # |
| 33 | set fourbyte {} |
| 34 | for {set i 0} {$i<40} {incr i} { |
| 35 | set char [binary format H6c f0a080 [expr {0x80+$i}]] |
| 36 | append fourbyte [string repeat $char [expr {$i%7+3}]]\n |
| 37 | } |
| 38 | set greek [fixed_word_lines 200 0x3b1] |
| 39 | set utf16 [lmap c [split \ufeff$greek ""] {scan $c %c}] |
| 40 | set inputs [list \ |
| 41 | ascii [fixed_word_lines 400] \ |
| 42 | large [fixed_word_lines 5000] \ |
| 43 | longlines [fixed_word_lines 60 97 150] \ |
| 44 | crlf [string map [list \n \r\n] [fixed_word_lines 100]] \ |
| 45 | repeats [fixed_word_lines 4000 97 1 1] \ |
| 46 | utf8 [encoding convertto utf-8 $greek] \ |
| 47 | cjk [encoding convertto utf-8 [fixed_word_lines 200 0x4e00]] \ |
| 48 | fourbyte $fourbyte \ |
| 49 | utf16le [binary format s* $utf16] \ |
| 50 | utf16be [binary format S* $utf16] \ |
| 51 | short [fixed_word_lines 4] \ |
| 52 | oneline "one line that has no newline" \ |
| 53 | ] |
| 54 | foreach {base f1} $inputs { |
| 55 | write_file t1 $f1 |
| 56 | for {set i 0} {$i<100} {incr i} { |
| 57 | write_file t2 [random_changes $f1 1 1 0 0.1] |
| 58 | fossil test-delta t1 t2 |
| 59 | test delta-$base-$i-1 {[normalize_result]=="ok"} |
| 60 |
+42
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -850,10 +850,52 @@ | ||
| 850 | 850 | } |
| 851 | 851 | append out \n$line |
| 852 | 852 | } |
| 853 | 853 | return [string range $out 1 end] |
| 854 | 854 | } |
| 855 | + | |
| 856 | +# Return $nline lines of text for use as test input. Each line is | |
| 857 | +# indented words of one to nine letters, and the letters are the | |
| 858 | +# $nletter characters that start at $base. A line has at most | |
| 859 | +# $maxwords words. | |
| 860 | +# About one line in eight is empty and about one in eight repeats one | |
| 861 | +# of the three lines before it. The same arguments always give the same text. | |
| 862 | +# The procedure does not call rand(), so it does not change the | |
| 863 | +# caller's sequence of random numbers. | |
| 864 | +# | |
| 865 | +proc fixed_word_lines {nline {base 97} {maxwords 12} {nletter 24}} { | |
| 866 | + set seed $nline | |
| 867 | + set lines {} | |
| 868 | + for {set i 0} {$i<$nline} {incr i} { | |
| 869 | + set kind [next_fixed_int seed 8] | |
| 870 | + if {$kind==0} { | |
| 871 | + lappend lines {} | |
| 872 | + } elseif {$kind==1 && $i>=3} { | |
| 873 | + lappend lines [lindex $lines end-[next_fixed_int seed 3]] | |
| 874 | + } else { | |
| 875 | + set words {} | |
| 876 | + for {set w [next_fixed_int seed $maxwords]} {$w>=0} {incr w -1} { | |
| 877 | + set word {} | |
| 878 | + for {set c [next_fixed_int seed 9]} {$c>=0} {incr c -1} { | |
| 879 | + append word [format %c [expr {$base+[next_fixed_int seed $nletter]}]] | |
| 880 | + } | |
| 881 | + lappend words $word | |
| 882 | + } | |
| 883 | + lappend lines [string repeat " " [next_fixed_int seed 4]][join $words] | |
| 884 | + } | |
| 885 | + } | |
| 886 | + return [join $lines \n]\n | |
| 887 | +} | |
| 888 | + | |
| 889 | +# Return the next integer from 0 to $n-1 in the sequence whose state is | |
| 890 | +# in the variable $seedVar. | |
| 891 | +# | |
| 892 | +proc next_fixed_int {seedVar n} { | |
| 893 | + upvar 1 $seedVar seed | |
| 894 | + set seed [expr {($seed*1103515245+12345) & 0x7fffffff}] | |
| 895 | + return [expr {($seed>>16) % $n}] | |
| 896 | +} | |
| 855 | 897 | |
| 856 | 898 | # Return true if a TCP connection can be made over the loopback interface, |
| 857 | 899 | # as the tests that run "fossil server" need. Listening succeeds even when |
| 858 | 900 | # the interface is down, so this procedure also connects. |
| 859 | 901 | proc loopback_available {} { |
| 860 | 902 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -850,10 +850,52 @@ | |
| 850 | } |
| 851 | append out \n$line |
| 852 | } |
| 853 | return [string range $out 1 end] |
| 854 | } |
| 855 | |
| 856 | # Return true if a TCP connection can be made over the loopback interface, |
| 857 | # as the tests that run "fossil server" need. Listening succeeds even when |
| 858 | # the interface is down, so this procedure also connects. |
| 859 | proc loopback_available {} { |
| 860 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -850,10 +850,52 @@ | |
| 850 | } |
| 851 | append out \n$line |
| 852 | } |
| 853 | return [string range $out 1 end] |
| 854 | } |
| 855 | |
| 856 | # Return $nline lines of text for use as test input. Each line is |
| 857 | # indented words of one to nine letters, and the letters are the |
| 858 | # $nletter characters that start at $base. A line has at most |
| 859 | # $maxwords words. |
| 860 | # About one line in eight is empty and about one in eight repeats one |
| 861 | # of the three lines before it. The same arguments always give the same text. |
| 862 | # The procedure does not call rand(), so it does not change the |
| 863 | # caller's sequence of random numbers. |
| 864 | # |
| 865 | proc fixed_word_lines {nline {base 97} {maxwords 12} {nletter 24}} { |
| 866 | set seed $nline |
| 867 | set lines {} |
| 868 | for {set i 0} {$i<$nline} {incr i} { |
| 869 | set kind [next_fixed_int seed 8] |
| 870 | if {$kind==0} { |
| 871 | lappend lines {} |
| 872 | } elseif {$kind==1 && $i>=3} { |
| 873 | lappend lines [lindex $lines end-[next_fixed_int seed 3]] |
| 874 | } else { |
| 875 | set words {} |
| 876 | for {set w [next_fixed_int seed $maxwords]} {$w>=0} {incr w -1} { |
| 877 | set word {} |
| 878 | for {set c [next_fixed_int seed 9]} {$c>=0} {incr c -1} { |
| 879 | append word [format %c [expr {$base+[next_fixed_int seed $nletter]}]] |
| 880 | } |
| 881 | lappend words $word |
| 882 | } |
| 883 | lappend lines [string repeat " " [next_fixed_int seed 4]][join $words] |
| 884 | } |
| 885 | } |
| 886 | return [join $lines \n]\n |
| 887 | } |
| 888 | |
| 889 | # Return the next integer from 0 to $n-1 in the sequence whose state is |
| 890 | # in the variable $seedVar. |
| 891 | # |
| 892 | proc next_fixed_int {seedVar n} { |
| 893 | upvar 1 $seedVar seed |
| 894 | set seed [expr {($seed*1103515245+12345) & 0x7fffffff}] |
| 895 | return [expr {($seed>>16) % $n}] |
| 896 | } |
| 897 | |
| 898 | # Return true if a TCP connection can be made over the loopback interface, |
| 899 | # as the tests that run "fossil server" need. Listening succeeds even when |
| 900 | # the interface is down, so this procedure also connects. |
| 901 | proc loopback_available {} { |
| 902 |