[Reproducible-commits] [reprotest] 03/03: Add filesystem variation

Ceridwen ceridwen-guest at moszumanska.debian.org
Thu Jun 9 14:18:37 UTC 2016


This is an automated email from the git hooks/post-receive script.

ceridwen-guest pushed a commit to branch master
in repository reprotest.

commit 200a6c38e9fcc14a7322f62ddcf737039efe200a
Author: Ceridwen <ceridwenv at gmail.com>
Date:   Thu Jun 9 10:18:30 2016 -0400

    Add filesystem variation
---
 reprotest/__init__.py | 30 +++++++++++++++++-------------
 tests/build.py        | 12 +++++++++++-
 tests/test.py         |  1 +
 3 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index e96d3d1..6d01f3d 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -42,11 +42,13 @@ def domain_host(command1, command2, env1, env2, tree1, tree2):
 # requires some context-manager silliness.
 @contextlib.contextmanager
 def filesystem(command1, command2, env1, env2, tree1, tree2):
-    # disorderfs = tree2.parent / 'disorderfs'
-    # disorderfs.mkdir()
-    # subprocess.check_call(['disorderfs', '--shuffle-dirents=yes',
-    #                        str(tree2), str(disorderfs)])
-    yield command1, command2, env1, env2, tree1, tree2
+    disorderfs = tree2.parent/'disorderfs'
+    disorderfs.mkdir()
+    subprocess.check_call(['disorderfs', '--shuffle-dirents=yes',
+                           # '--pad-blocks=10',
+                           str(tree2), str(disorderfs)])
+    yield command1, command2, env1, env2, tree1, disorderfs
+    subprocess.check_call(['fusermount', '-u', str(disorderfs)])
 
 @contextlib.contextmanager
 def home(command1, command2, env1, env2, tree1, tree2):
@@ -146,16 +148,18 @@ def check(build_command, artifact_name, source_root, variations=VARIATIONS):
         env2 = env1.copy()
         tree1 = pathlib.Path(shutil.copytree(str(source_root), temp + '/tree1'))
         tree2 = pathlib.Path(shutil.copytree(str(source_root), temp + '/tree2'))
-        try:
-            with contextlib.ExitStack() as stack:
+        with contextlib.ExitStack() as stack:
+            try:
                 for variation in variations:
                     command1, command2, env1, env2, tree1, tree2 = stack.enter_context(VARIATIONS[variation](command1, command2, env1, env2, tree1, tree2))
-                build(' '.join(command1), str(tree1), temp + '/tree1/' + artifact_name,
-                      open(temp + '/artifact1', 'wb'), env=env1, shell=True)
-                build(' '.join(command2), str(tree2), temp + '/tree2/' + artifact_name,
-                      open(temp + '/artifact2', 'wb'), env=env2, shell=True)
-        except Exception:
-            sys.exit(2)
+                    build(' '.join(command1), str(tree1),
+                          temp + '/tree1/' + artifact_name,
+                          open(temp + '/artifact1', 'wb'), env=env1, shell=True)
+                    build(' '.join(command2), str(tree2),
+                          temp + '/tree2/' + artifact_name,
+                          open(temp + '/artifact2', 'wb'), env=env2, shell=True)
+            except Exception:
+                sys.exit(2)
         sys.exit(subprocess.call(['diffoscope', temp + '/artifact1', temp + '/artifact2']))
 
 def main():
diff --git a/tests/build.py b/tests/build.py
index 59e8d6a..6937795 100755
--- a/tests/build.py
+++ b/tests/build.py
@@ -22,6 +22,16 @@ if __name__ == '__main__':
         # This test can theoretically fail by producing the same
         # random bits in both runs, but it is extremely unlikely.
         output.append(os.urandom(1024))
+    if 'filesystem' in args:
+        # Like the above test, this test can theoretically fail by
+        # producing the same file order, but this is unlikely, if not
+        # as unlikely as in the above test.
+        test_file_order = pathlib.Path.cwd()/'test_file_order'
+        if not test_file_order.exists():
+            test_file_order.mkdir()
+            for i in range(20):
+                (test_file_order/str(i)).touch()
+        output.extend(p.name.encode('ascii') for p in test_file_order.iterdir())
     if 'home' in args:
         output.append(os.path.expanduser('~').encode('ascii'))
     if 'kernel' in args:
@@ -35,7 +45,7 @@ if __name__ == '__main__':
     if 'timezone' in args:
         output.append(str(time.timezone).encode('ascii'))
     if 'umask' in args:
-        test_permissions = pathlib.Path.cwd() / 'test_permissions'
+        test_permissions = pathlib.Path.cwd()/'test_permissions'
         test_permissions.touch()
         with tempfile.TemporaryFile() as temp:
             archive = tarfile.open(name='temp', mode='w', fileobj=temp)
diff --git a/tests/test.py b/tests/test.py
index 4f1f936..8639948 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -15,6 +15,7 @@ if __name__ == '__main__':
     test_return_code(['python', 'build.py'], 0)
     test_return_code(['python', 'fails.py'], 2)
     test_return_code(['python', 'build.py', 'irreproducible'], 1)
+    test_return_code(['python', 'build.py', 'filesystem'], 1)
     test_return_code(['python', 'build.py', 'home'], 1)
     test_return_code(['python', 'build.py', 'kernel'], 1)
     test_return_code(['python', 'build.py', 'locales'], 1)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git



More information about the Reproducible-commits mailing list