From 350f5beb053ea735a5aaab5671c9c6d78ca4a125 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sun, 14 Nov 2021 06:45:52 +0000 Subject: [PATCH] Generate a minimum of 2 files in the GC test case --- testsuite/helpers/__init__.py | 5 +++-- testsuite/yamatests/test_check_and_gc.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/testsuite/helpers/__init__.py b/testsuite/helpers/__init__.py index c26332f..cdac15f 100644 --- a/testsuite/helpers/__init__.py +++ b/testsuite/helpers/__init__.py @@ -94,7 +94,7 @@ def generate_random_file(rng: Random, path: Path) -> FileDescriptor: def generate_random_dir( - rng: Random, path: Path, max_remaining_files: int + rng: Random, path: Path, max_remaining_files: int, min_files: int = 0 ) -> Tuple[DirectoryDescriptor, int]: """ Generates a random directory at the given path, and returns its descriptor @@ -102,12 +102,13 @@ def generate_random_dir( :param rng: PRNG to use :param path: path to use :param max_remaining_files: The maximum number of files allowed. + :param min_files: The minimum number of files in this directory directly. :return: (descriptor, number of files allowed remaining) """ os.mkdir(path) - num_files = rng.randint(0, max_remaining_files) + num_files = rng.randint(min_files, max_remaining_files) max_remaining_files -= num_files contents = dict() diff --git a/testsuite/yamatests/test_check_and_gc.py b/testsuite/yamatests/test_check_and_gc.py index 77333a4..31bdedb 100644 --- a/testsuite/yamatests/test_check_and_gc.py +++ b/testsuite/yamatests/test_check_and_gc.py @@ -181,9 +181,12 @@ class TestYamaCheck(TestCase): rng = Random() seed = rng.randint(0, 9001) + seed = 3674 # todo print(f"seed: {seed}") rng.seed(seed) - later_expected_descriptor, _ = generate_random_dir(rng, src_path, 32) + later_expected_descriptor, _ = generate_random_dir( + rng, src_path, 32, min_files=2 + ) subprocess.check_call(("datman", "backup-one", "srca", "main"), cwd=datman_path)