Fossil SCM

Add a test script that runs one thousand web page queries using valgrind, looking for memory issues. Fix one use-after-free issue found using this script.

drh 2012-11-08 14:42 trunk
Commit 9e0da27437da80b3b89ab798da693e5b67c9175a
+1 -1
--- src/info.c
+++ src/info.c
@@ -1723,14 +1723,14 @@
17231723
}
17241724
@ <tr><th>Ticket:</th>
17251725
@ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a></td></tr>
17261726
@ <tr><th>Date:</th><td>
17271727
hyperlink_to_date(zDate, "</td></tr>");
1728
- free(zDate);
17291728
@ <tr><th>User:</th><td>
17301729
hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>");
17311730
@ </table>
1731
+ free(zDate);
17321732
17331733
if( g.perm.ModTkt && modPending ){
17341734
@ <div class="section">Moderation</div>
17351735
@ <blockquote>
17361736
@ <form method="POST" action="%R/tinfo/%s(zUuid)">
17371737
17381738
ADDED test/valgrind-www.tcl
--- src/info.c
+++ src/info.c
@@ -1723,14 +1723,14 @@
1723 }
1724 @ <tr><th>Ticket:</th>
1725 @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a></td></tr>
1726 @ <tr><th>Date:</th><td>
1727 hyperlink_to_date(zDate, "</td></tr>");
1728 free(zDate);
1729 @ <tr><th>User:</th><td>
1730 hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>");
1731 @ </table>
 
1732
1733 if( g.perm.ModTkt && modPending ){
1734 @ <div class="section">Moderation</div>
1735 @ <blockquote>
1736 @ <form method="POST" action="%R/tinfo/%s(zUuid)">
1737
1738 DDED test/valgrind-www.tcl
--- src/info.c
+++ src/info.c
@@ -1723,14 +1723,14 @@
1723 }
1724 @ <tr><th>Ticket:</th>
1725 @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a></td></tr>
1726 @ <tr><th>Date:</th><td>
1727 hyperlink_to_date(zDate, "</td></tr>");
 
1728 @ <tr><th>User:</th><td>
1729 hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>");
1730 @ </table>
1731 free(zDate);
1732
1733 if( g.perm.ModTkt && modPending ){
1734 @ <div class="section">Moderation</div>
1735 @ <blockquote>
1736 @ <form method="POST" action="%R/tinfo/%s(zUuid)">
1737
1738 DDED test/valgrind-www.tcl
--- a/test/valgrind-www.tcl
+++ b/test/valgrind-www.tcl
@@ -0,0 +1,33 @@
1
+#!/usr/bin/tclsh
2
+#
3
+# Run this script in an open Fossil checkout at the top-level with a
4
+# fresh build of Fossil itself. This script will run fossil on hundreds
5
+# of different web-pages looking for memory allocation problems using y allocation problems using
6
+# valgrind. Valgrind output appears on stderr. Suggested test scenario:
7
+#
8
+# make
9
+# tclsh valgrind-www.tcl 2>&1 | tee valgrind-out.txt
10
+#
11
+# Then examine the valgrind-out.txt file for issues.
12
+#
13
+proc run_query {url} {
14
+ set fd [open q.txt w]
15
+ puts $fd "GET $url HTTreturn [url HTTP/1.0\r\n\r"
16
+ c]/fossil test-http <q.txt 2>@ stderr} msg
17
+ return $msg
18
+}
19
+set todo {}
20
+foreach url {
21
+ /home
22
+ /timeli/tclsh
23
+#
24
+# Run this scrip#!/usr/bin/tclsh
25
+#
26
+# Run this script in an open Fossil checkout at the top-lding>0 && $i<$limit} {incr i} {
27
+ set url [get_pending]
28
+ puts "====== ([expr {$i+1}]) $url ======"
29
+ set x [run_query $url]
30
+ while {[regexp {<[aA] .*?href="(/[a-z].*?)".*?>(.*)$} $x all url tail]} {
31
+ set u2 [string map {&lt; < &gt; > &quot; \" &amp; &} $url]
32
+ if {![info exists seen($u2)]} {
33
+ set pendlappend tod
--- a/test/valgrind-www.tcl
+++ b/test/valgrind-www.tcl
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/test/valgrind-www.tcl
+++ b/test/valgrind-www.tcl
@@ -0,0 +1,33 @@
1 #!/usr/bin/tclsh
2 #
3 # Run this script in an open Fossil checkout at the top-level with a
4 # fresh build of Fossil itself. This script will run fossil on hundreds
5 # of different web-pages looking for memory allocation problems using y allocation problems using
6 # valgrind. Valgrind output appears on stderr. Suggested test scenario:
7 #
8 # make
9 # tclsh valgrind-www.tcl 2>&1 | tee valgrind-out.txt
10 #
11 # Then examine the valgrind-out.txt file for issues.
12 #
13 proc run_query {url} {
14 set fd [open q.txt w]
15 puts $fd "GET $url HTTreturn [url HTTP/1.0\r\n\r"
16 c]/fossil test-http <q.txt 2>@ stderr} msg
17 return $msg
18 }
19 set todo {}
20 foreach url {
21 /home
22 /timeli/tclsh
23 #
24 # Run this scrip#!/usr/bin/tclsh
25 #
26 # Run this script in an open Fossil checkout at the top-lding>0 && $i<$limit} {incr i} {
27 set url [get_pending]
28 puts "====== ([expr {$i+1}]) $url ======"
29 set x [run_query $url]
30 while {[regexp {<[aA] .*?href="(/[a-z].*?)".*?>(.*)$} $x all url tail]} {
31 set u2 [string map {&lt; < &gt; > &quot; \" &amp; &} $url]
32 if {![info exists seen($u2)]} {
33 set pendlappend tod

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button