Patchwork [1,of,4] tests: tests for revlog version and flags loading

login
register
mail settings
Submitter Gregory Szorc
Date May 20, 2017, 3:58 a.m.
Message ID <40748da9c7c56836f815.1495252737@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20754/
State Accepted
Headers show

Comments

Gregory Szorc - May 20, 2017, 3:58 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1495249295 25200
#      Fri May 19 20:01:35 2017 -0700
# Node ID 40748da9c7c56836f815582cf9a367097755859d
# Parent  a438f5a3bc092f54e14f45e2115a36312c2ed302
tests: tests for revlog version and flags loading

We didn't have explicit test coverage of these branches.
Better late than never.
Yuya Nishihara - May 21, 2017, 12:21 p.m.
On Fri, 19 May 2017 20:58:57 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1495249295 25200
> #      Fri May 19 20:01:35 2017 -0700
> # Node ID 40748da9c7c56836f815582cf9a367097755859d
> # Parent  a438f5a3bc092f54e14f45e2115a36312c2ed302
> tests: tests for revlog version and flags loading

The first three look good, but I'm not sure about the last revlog2 patch.
So I left these not queued.

Patch

diff --git a/tests/test-revlog.t b/tests/test-revlog.t
--- a/tests/test-revlog.t
+++ b/tests/test-revlog.t
@@ -1,3 +1,35 @@ 
+  $ hg init empty-repo
+  $ cd empty-repo
+
+Flags on revlog version 0 are rejected
+
+  >>> with open('.hg/store/00changelog.i', 'wb') as fh:
+  ...     fh.write('\x00\x01\x00\x00')
+
+  $ hg log
+  abort: index 00changelog.i unknown flags 0x01 for format v0!
+  [255]
+
+Unknown flags on revlog version 1 are rejected
+
+  >>> with open('.hg/store/00changelog.i', 'wb') as fh:
+  ...     fh.write('\x00\x04\x00\x01')
+
+  $ hg log
+  abort: index 00changelog.i unknown flags 0x04 for revlogng!
+  [255]
+
+Unknown version is rejected
+
+  >>> with open('.hg/store/00changelog.i', 'wb') as fh:
+  ...     fh.write('\x00\x00\x00\x02')
+
+  $ hg log
+  abort: index 00changelog.i unknown format 2!
+  [255]
+
+  $ cd ..
+
 Test for CVE-2016-3630
 
   $ hg init