Generate a minimum of 2 files in the GC test case
This commit is contained in:
parent
b90ce1abbd
commit
350f5beb05
|
@ -94,7 +94,7 @@ def generate_random_file(rng: Random, path: Path) -> FileDescriptor:
|
||||||
|
|
||||||
|
|
||||||
def generate_random_dir(
|
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]:
|
) -> Tuple[DirectoryDescriptor, int]:
|
||||||
"""
|
"""
|
||||||
Generates a random directory at the given path, and returns its descriptor
|
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 rng: PRNG to use
|
||||||
:param path: path to use
|
:param path: path to use
|
||||||
:param max_remaining_files: The maximum number of files allowed.
|
: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)
|
:return: (descriptor, number of files allowed remaining)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
os.mkdir(path)
|
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
|
max_remaining_files -= num_files
|
||||||
|
|
||||||
contents = dict()
|
contents = dict()
|
||||||
|
|
|
@ -181,9 +181,12 @@ class TestYamaCheck(TestCase):
|
||||||
|
|
||||||
rng = Random()
|
rng = Random()
|
||||||
seed = rng.randint(0, 9001)
|
seed = rng.randint(0, 9001)
|
||||||
|
seed = 3674 # todo
|
||||||
print(f"seed: {seed}")
|
print(f"seed: {seed}")
|
||||||
rng.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)
|
subprocess.check_call(("datman", "backup-one", "srca", "main"), cwd=datman_path)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue