Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 01 / 316ad41c5f139cd451eb724884830106815bbf
1 Return-Path: <aclements@csail.mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 15AAB431FBC\r
6         for <notmuch@notmuchmail.org>; Fri,  3 Oct 2014 09:58:36 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id QmaXSL60CxpO for <notmuch@notmuchmail.org>;\r
16         Fri,  3 Oct 2014 09:58:29 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu\r
18         [18.9.25.13])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 59798431FB6\r
22         for <notmuch@notmuchmail.org>; Fri,  3 Oct 2014 09:58:29 -0700 (PDT)\r
23 X-AuditID: 1209190d-f79c06d000006f95-80-542ed5b40568\r
24 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id 7E.EA.28565.4B5DE245; Fri,  3 Oct 2014 12:58:28 -0400 (EDT)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s93GwQhN028669; \r
31         Fri, 3 Oct 2014 12:58:26 -0400\r
32 Received: from drake.dyndns.org\r
33         (static-155-212-141-65.mas.onecommunications.net [155.212.141.65])\r
34         (authenticated bits=0)\r
35         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
36         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s93GwEBP019243\r
37         (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);\r
38         Fri, 3 Oct 2014 12:58:24 -0400\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.84)\r
40         (envelope-from <aclements@csail.mit.edu>)\r
41         id 1Xa6BJ-00022m-AR; Fri, 03 Oct 2014 12:58:13 -0400\r
42 From: Austin Clements <aclements@csail.mit.edu>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH] test: Port atomicity test to Python\r
45 Date: Fri,  3 Oct 2014 12:58:03 -0400\r
46 Message-Id: <1412355483-7670-1-git-send-email-aclements@csail.mit.edu>\r
47 X-Mailer: git-send-email 2.1.0\r
48 X-Brightmail-Tracker:\r
49  H4sIAAAAAAAAA+NgFlrLIsWRmVeSWpSXmKPExsUixCmqrLvlql6IwYIlahZT1jxmtbh+cyaz\r
50         A5PHkdeb2TyerbrFHMAUxWWTkpqTWZZapG+XwJXRO1+3YK9JxcnWJawNjJs1uxg5OCQETCSm\r
51         H5TtYuQEMsUkLtxbzwZiCwnMZpK4cjSni5ELyN7AKNHzeB8bhHOdSWLm7EWMEM4SRonJ+zYw\r
52         g7SwCehLrFg7iRXEFhGQlth5dzaYzSzgLPHw80Y2kG3CQNv2vVcHCbMIqEpsutDJCBLmFXCT\r
53         uPsgD+IIOYkNu/8zTmDkXcDIsIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXSC83s0QvNaV0EyM4\r
54         JCR5dzC+O6h0iFGAg1GJh/fDDd0QIdbEsuLK3EOMkhxMSqK8sVf0QoT4kvJTKjMSizPii0pz\r
55         UosPMUpwMCuJ8C5YCZTjTUmsrEotyodJSXOwKInzbvrBFyIkkJ5YkpqdmlqQWgSTleHgUJLg\r
56         LQUZKliUmp5akZaZU4KQZuLgBBnOAzQ8HaSGt7ggMbc4Mx0if4pRl2PSxve9TEIsefl5qVLi\r
57         vIsuAxUJgBRllObBzYHF8itGcaC3hHnzQUbxANMA3KRXQEuYgJa8s9cFWVKSiJCSamDMuJsr\r
58         bRp+TGrdofwLgdka97edEE3YeulqjXbsrmei78z/tb35rTxPRu8Y0yqhyc9LcpLNv7P9YSvR\r
59         yqhYsl5TzHeHcdheDkmRRzONf969L7b7qmVPf43uv63h2yd5fJzz3PK7rz1bCWPCxwsdPtf0\r
60         E4t+cLrUVc15frXfac+FyBLubYfOz2VWYinOSDTUYi4qTgQAc5E+acACAAA=\r
61 Cc: Austin Clements <aclements@csail.mit.edu>\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66         <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Fri, 03 Oct 2014 16:58:36 -0000\r
75 \r
76 Previously, this was implemented using a horrible GDB script (because\r
77 there is no such thing as a non-horrible GDB script).  This GDB script\r
78 often broke with newer versions of GDB for mysterious reasons.  Port\r
79 the test script to GDB's Python API, which makes the code much cleaner\r
80 and, hopefully, more stable.\r
81 ---\r
82 \r
83 Hi Amadeusz.  Does this patch fix the problem for you?  I don't have\r
84 GDB 7.8, so I can't test against it, but the Python interface is less\r
85 fragile than the GDB scripting language.  (Even if this doesn't fix\r
86 your problem, I think we should switch to the Python interface.)\r
87 \r
88  test/T380-atomicity.sh |  2 +-\r
89  test/atomicity.gdb     | 54 --------------------------------------\r
90  test/atomicity.py      | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
91  3 files changed, 72 insertions(+), 55 deletions(-)\r
92  delete mode 100644 test/atomicity.gdb\r
93  create mode 100644 test/atomicity.py\r
94 \r
95 diff --git a/test/T380-atomicity.sh b/test/T380-atomicity.sh\r
96 index 2daef90..ee1e2f4 100755\r
97 --- a/test/T380-atomicity.sh\r
98 +++ b/test/T380-atomicity.sh\r
99 @@ -64,7 +64,7 @@ if test_require_external_prereq gdb; then\r
100      # -tty /dev/null works around a conflict between the 'timeout' wrapper\r
101      # and gdb's attempt to control the TTY.\r
102      export MAIL_DIR\r
103 -    gdb -tty /dev/null -batch -x $TEST_DIRECTORY/atomicity.gdb notmuch 1>gdb.out 2>&1\r
104 +    gdb -tty /dev/null -batch -x $TEST_DIRECTORY/atomicity.py notmuch 1>gdb.out 2>&1\r
105  \r
106      # Get the final, golden output\r
107      notmuch search '*' > expected\r
108 diff --git a/test/atomicity.gdb b/test/atomicity.gdb\r
109 deleted file mode 100644\r
110 index 15adb16..0000000\r
111 --- a/test/atomicity.gdb\r
112 +++ /dev/null\r
113 @@ -1,54 +0,0 @@\r
114 -# This gdb script runs notmuch new and simulates killing and\r
115 -# restarting notmuch new after every Xapian commit.  To simulate this\r
116 -# more efficiently, this script runs notmuch new and, immediately\r
117 -# after every Xapian commit, it *pauses* the running notmuch new,\r
118 -# copies the entire database and maildir to a snapshot directory, and\r
119 -# executes a full notmuch new on that snapshot, comparing the final\r
120 -# results with the expected output.  It can then resume the paused\r
121 -# notmuch new, which is still running on the original maildir, and\r
122 -# repeat this process.\r
123 -\r
124 -set args new\r
125 -\r
126 -# Make Xapian commit after every operation instead of batching\r
127 -set environment XAPIAN_FLUSH_THRESHOLD = 1\r
128 -\r
129 -# gdb can't keep track of a simple integer.  This is me weeping.\r
130 -shell echo 0 > outcount\r
131 -\r
132 -shell touch inodes\r
133 -\r
134 -# work around apparent issue with lazy library loading on some\r
135 -# platforms\r
136 -set breakpoint pending on\r
137 -\r
138 -break rename\r
139 -commands\r
140 -# As an optimization, only consider snapshots after a Xapian commit.\r
141 -# Xapian overwrites record.base? as the last step in the commit.\r
142 -shell echo > gdbcmd\r
143 -shell stat -c %i $MAIL_DIR/.notmuch/xapian/record.base* > inodes.new\r
144 -shell if cmp inodes inodes.new; then echo cont > gdbcmd; fi\r
145 -shell mv inodes.new inodes\r
146 -source gdbcmd\r
147 -\r
148 -# Save a backtrace in case the test does fail\r
149 -set logging file backtrace\r
150 -set logging on\r
151 -backtrace\r
152 -set logging off\r
153 -shell mv backtrace backtrace.`cat outcount`\r
154 -\r
155 -# Snapshot the database\r
156 -shell rm -r $MAIL_DIR.snap/.notmuch\r
157 -shell cp -r $MAIL_DIR/.notmuch $MAIL_DIR.snap/.notmuch\r
158 -# Restore the mtime of $MAIL_DIR.snap, which we just changed\r
159 -shell touch -r $MAIL_DIR $MAIL_DIR.snap\r
160 -# Run notmuch new to completion on the snapshot\r
161 -shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap XAPIAN_FLUSH_THRESHOLD=1000 notmuch new > /dev/null\r
162 -shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch search '*' > search.`cat outcount` 2>&1\r
163 -shell echo $(expr $(cat outcount) + 1) > outcount\r
164 -cont\r
165 -end\r
166 -\r
167 -run\r
168 diff --git a/test/atomicity.py b/test/atomicity.py\r
169 new file mode 100644\r
170 index 0000000..01a4205\r
171 --- /dev/null\r
172 +++ b/test/atomicity.py\r
173 @@ -0,0 +1,71 @@\r
174 +# This gdb Python script runs notmuch new and simulates killing and\r
175 +# restarting notmuch new after every Xapian commit.  To simulate this\r
176 +# more efficiently, this script runs notmuch new and, immediately\r
177 +# after every Xapian commit, it *pauses* the running notmuch new,\r
178 +# copies the entire database and maildir to a snapshot directory, and\r
179 +# executes a full notmuch new on that snapshot, comparing the final\r
180 +# results with the expected output.  It can then resume the paused\r
181 +# notmuch new, which is still running on the original maildir, and\r
182 +# repeat this process.\r
183 +\r
184 +import gdb\r
185 +import os\r
186 +import glob\r
187 +import shutil\r
188 +import subprocess\r
189 +\r
190 +gdb.execute('set args new')\r
191 +\r
192 +# Make Xapian commit after every operation instead of batching\r
193 +gdb.execute('set environment XAPIAN_FLUSH_THRESHOLD = 1')\r
194 +\r
195 +maildir = os.environ['MAIL_DIR']\r
196 +\r
197 +# Trap calls to rename, which happens just before Xapian commits\r
198 +class RenameBreakpoint(gdb.Breakpoint):\r
199 +    def __init__(self, *args, **kwargs):\r
200 +        super(RenameBreakpoint, self).__init__(*args, **kwargs)\r
201 +        self.last_inodes = {}\r
202 +        self.n = 0\r
203 +\r
204 +    def stop(self):\r
205 +        # As an optimization, only consider snapshots after a Xapian\r
206 +        # has really committed.  Xapian overwrites record.base? as the\r
207 +        # last step in the commit, so keep an eye on their inumbers.\r
208 +        inodes = {}\r
209 +        for path in glob.glob('%s/.notmuch/xapian/record.base*' % maildir):\r
210 +            inodes[path] = os.stat(path).st_ino\r
211 +        if inodes == self.last_inodes:\r
212 +            # Continue\r
213 +            return False\r
214 +        self.last_inodes = inodes\r
215 +\r
216 +        # Save a backtrace in case the test does fail\r
217 +        backtrace = gdb.execute('backtrace', to_string=True)\r
218 +        open('backtrace.%d' % self.n, 'w').write(backtrace)\r
219 +\r
220 +        # Snapshot the database\r
221 +        shutil.rmtree('%s.snap/.notmuch' % maildir)\r
222 +        shutil.copytree('%s/.notmuch' % maildir, '%s.snap/.notmuch' % maildir)\r
223 +        # Restore the mtime of $MAIL_DIR.snap/\r
224 +        shutil.copystat('%s/.notmuch' % maildir, '%s.snap/.notmuch' % maildir)\r
225 +\r
226 +        # Run notmuch new to completion on the snapshot\r
227 +        env = os.environ.copy()\r
228 +        env.update(NOTMUCH_CONFIG=os.environ['NOTMUCH_CONFIG'] + '.snap',\r
229 +                   XAPIAN_FLUSH_THRESHOLD='1000')\r
230 +        subprocess.check_call(\r
231 +            ['notmuch', 'new'], env=env, stdout=open('/dev/null', 'w'))\r
232 +        subprocess.check_call(\r
233 +            ['notmuch', 'search', '*'], env=env,\r
234 +            stdout=open('search.%d' % self.n, 'w'))\r
235 +\r
236 +        # Tell the shell how far we've gotten\r
237 +        open('outcount', 'w').write(str(self.n + 1))\r
238 +\r
239 +        # Continue\r
240 +        self.n += 1\r
241 +        return False\r
242 +RenameBreakpoint('rename')\r
243 +\r
244 +gdb.execute('run')\r
245 -- \r
246 2.1.0\r
247 \r