import pytest
import shutil
import subprocess
+import utils
EROFS_SRC_DIR = 'erofs_src_dir'
EROFS_IMAGE_NAME = 'erofs.img'
-def generate_file(name, size):
- """
- Generates a file filled with 'x'.
- """
- content = 'x' * size
- file = open(name, 'w')
- file.write(content)
- file.close()
-
def make_erofs_image(build_dir):
"""
Makes the EROFS images used for the test.
os.makedirs(root)
# 4096: uncompressed file
- generate_file(os.path.join(root, 'f4096'), 4096)
+ utils.generate_file(os.path.join(root, 'f4096'), 4096)
# 7812: Compressed file
- generate_file(os.path.join(root, 'f7812'), 7812)
+ utils.generate_file(os.path.join(root, 'f7812'), 7812)
# sub-directory with a single file inside
subdir_path = os.path.join(root, 'subdir')
os.makedirs(subdir_path)
- generate_file(os.path.join(subdir_path, 'subdir-file'), 100)
+ utils.generate_file(os.path.join(subdir_path, 'subdir-file'), 100)
# symlink
os.symlink('subdir', os.path.join(root, 'symdir'))
import os
import shutil
import subprocess
+import utils
""" standard test images table: Each table item is a key:value pair
representing the output image name and its respective mksquashfs options.
for key, value in zip(STANDARD_TABLE.keys(), opts_list):
STANDARD_TABLE[key] = value
-def generate_file(file_name, file_size):
- """ Generates a file filled with 'x'.
-
- Args:
- file_name: the file's name.
- file_size: the content's length and therefore the file size.
- """
- content = 'x' * file_size
-
- file = open(file_name, 'w')
- file.write(content)
- file.close()
-
def generate_sqfs_src_dir(build_dir):
""" Generates the source directory used to make the SquashFS images.
# 4096: minimum block size
file_name = 'f4096'
- generate_file(os.path.join(root, file_name), 4096)
+ utils.generate_file(os.path.join(root, file_name), 4096)
# 5096: minimum block size + 1000 chars (fragment)
file_name = 'f5096'
- generate_file(os.path.join(root, file_name), 5096)
+ utils.generate_file(os.path.join(root, file_name), 5096)
# 1000: less than minimum block size (fragment only)
file_name = 'f1000'
- generate_file(os.path.join(root, file_name), 1000)
+ utils.generate_file(os.path.join(root, file_name), 1000)
# sub-directory with a single file inside
subdir_path = os.path.join(root, 'subdir')
os.makedirs(subdir_path)
- generate_file(os.path.join(subdir_path, 'subdir-file'), 100)
+ utils.generate_file(os.path.join(subdir_path, 'subdir-file'), 100)
# symlink (target: sub-directory)
os.symlink('subdir', os.path.join(root, 'sym'))
data = fh.read(*params)
return md5sum_data(data)
+def generate_file(file_name, file_size):
+ """ Generates a file filled with 'x'.
+
+ Args:
+ file_name: the file's name.
+ file_size: the content's length and therefore the file size.
+ """
+ content = 'x' * file_size
+
+ file = open(file_name, 'w')
+ file.write(content)
+ file.close()
+
class PersistentRandomFile:
"""Generate and store information about a persistent file containing
random data."""