Sort all os.listdir and os.walk to keep things more reproducible

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-03-10 00:00:04 +00:00
parent 2e3f4c1484
commit a9160d2217
6 changed files with 21 additions and 16 deletions

View File

@@ -84,7 +84,7 @@ usually extra Buildroot targets.
elif self.env['arch'] == 'aarch64': elif self.env['arch'] == 'aarch64':
defconfig = 'qemu_aarch64_virt_defconfig' defconfig = 'qemu_aarch64_virt_defconfig'
br2_external_dirs = [] br2_external_dirs = []
for package_dir in os.listdir(self.env['packages_dir']): for package_dir in sorted(os.listdir(self.env['packages_dir'])):
package_dir_abs = os.path.join(self.env['packages_dir'], package_dir) package_dir_abs = os.path.join(self.env['packages_dir'], package_dir)
if os.path.isdir(package_dir_abs): if os.path.isdir(package_dir_abs):
br2_external_dirs.append(self._path_relative_to_buildroot(package_dir_abs)) br2_external_dirs.append(self._path_relative_to_buildroot(package_dir_abs))

View File

@@ -866,7 +866,10 @@ lunch aosp_{}-eng
List checkpoint directory, oldest first. List checkpoint directory, oldest first.
''' '''
prefix_re = re.compile(self.env['gem5_cpt_prefix']) prefix_re = re.compile(self.env['gem5_cpt_prefix'])
files = list(filter(lambda x: os.path.isdir(os.path.join(self.env['m5out_dir'], x)) and prefix_re.search(x), os.listdir(self.env['m5out_dir']))) files = list(filter(
lambda x: os.path.isdir(os.path.join(self.env['m5out_dir'], x))
and prefix_re.search(x), os.listdir(self.env['m5out_dir'])
))
files.sort(key=lambda x: os.path.getmtime(os.path.join(self.env['m5out_dir'], x))) files.sort(key=lambda x: os.path.getmtime(os.path.join(self.env['m5out_dir'], x)))
return files return files

View File

@@ -20,9 +20,9 @@ https://github.com/cirosantilli/linux-kernel-module-cheat#release-zip
def timed_main(self): def timed_main(self):
self.zip_files.append(self.env['qcow2_file']) self.zip_files.append(self.env['qcow2_file'])
self.zip_files.append(self.env['linux_image']) self.zip_files.append(self.env['linux_image'])
for root, dirs, files in os.walk(self.env['baremetal_build_dir']): for root, dirnames, filenames in os.walk(self.env['baremetal_build_dir']):
for file in files: for filename in sorted(filenames):
path = os.path.join(root, file) path = os.path.join(root, filename)
if os.path.splitext(path)[1] == self.env['baremetal_build_ext']: if os.path.splitext(path)[1] == self.env['baremetal_build_ext']:
self.zip_files.append(path) self.zip_files.append(path)

View File

@@ -122,7 +122,7 @@ class ShellHelpers:
def copy_dir_if_update_non_recursive(self, srcdir, destdir, filter_ext=None): def copy_dir_if_update_non_recursive(self, srcdir, destdir, filter_ext=None):
# TODO print rsync equivalent. # TODO print rsync equivalent.
os.makedirs(destdir, exist_ok=True) os.makedirs(destdir, exist_ok=True)
for basename in os.listdir(srcdir): for basename in sorted(os.listdir(srcdir)):
src = os.path.join(srcdir, basename) src = os.path.join(srcdir, basename)
if os.path.isfile(src): if os.path.isfile(src):
noext, ext = os.path.splitext(basename) noext, ext = os.path.splitext(basename)
@@ -138,6 +138,7 @@ class ShellHelpers:
srcdir_abs = os.path.abspath(srcdir) srcdir_abs = os.path.abspath(srcdir)
srcdir_abs_len = len(srcdir_abs) srcdir_abs_len = len(srcdir_abs)
for path, dirnames, filenames in os.walk(srcdir_abs): for path, dirnames, filenames in os.walk(srcdir_abs):
dirnames.sort()
for dirname in dirnames: for dirname in dirnames:
dirpath = os.path.join(path, dirname) dirpath = os.path.join(path, dirname)
dirpath_relative_root = dirpath[srcdir_abs_len + 1:] dirpath_relative_root = dirpath[srcdir_abs_len + 1:]

View File

@@ -26,14 +26,15 @@ If given, run only the given tests. Otherwise, run all tests.
if self.env['tests'] == []: if self.env['tests'] == []:
baremetal_source_exts = (self.env['c_ext'], self.env['asm_ext']) baremetal_source_exts = (self.env['c_ext'], self.env['asm_ext'])
paths = [] paths = []
for f in os.listdir(self.env['baremetal_source_dir']): for f in sorted(os.listdir(self.env['baremetal_source_dir'])):
path = os.path.join(self.env['baremetal_source_dir'], f) path = os.path.join(self.env['baremetal_source_dir'], f)
if os.path.isfile(path) and os.path.splitext(path)[1] in baremetal_source_exts: if os.path.isfile(path) and os.path.splitext(path)[1] in baremetal_source_exts:
paths.append(path) paths.append(path)
for root, dirs, files in os.walk(self.env['baremetal_source_arch_dir'], topdown=True): for root, dirnames, filenames in os.walk(self.env['baremetal_source_arch_dir'], topdown=True):
dirs[:] = [d for d in dirs if d != 'interactive'] dirnames[:] = [d for d in dirnames if d != 'interactive']
for file in files: dirnames.sort()
path = os.path.join(root, file) for filename in filenames:
path = os.path.join(root, filename)
if os.path.splitext(path)[1] in baremetal_source_exts: if os.path.splitext(path)[1] in baremetal_source_exts:
paths.append(path) paths.append(path)
sources = [] sources = []

View File

@@ -27,13 +27,13 @@ found by searching for the Python test files.
if self.env['arch'] in self.env['crosstool_ng_supported_archs']: if self.env['arch'] in self.env['crosstool_ng_supported_archs']:
if self.env['tests'] == []: if self.env['tests'] == []:
test_scripts_noext = [] test_scripts_noext = []
for f in os.listdir(self.env['baremetal_source_dir']): for filename in sorted(os.listdir(self.env['baremetal_source_dir'])):
base, ext = os.path.splitext(f) base, ext = os.path.splitext(filename)
if ext == '.py': if ext == '.py':
test_scripts_noext.append(base) test_scripts_noext.append(base)
for root, dirs, files in os.walk(os.path.join(self.env['baremetal_source_dir'], 'arch', self.env['arch'])): for root, dirnames, filenames in os.walk(os.path.join(self.env['baremetal_source_dir'], 'arch', self.env['arch'])):
for f in files: for filename in filenames:
base, ext = os.path.splitext(f) base, ext = os.path.splitext(filename)
if ext == '.py': if ext == '.py':
full_path = os.path.join(root, base) full_path = os.path.join(root, base)
relpath = os.path.relpath(full_path, self.env['baremetal_source_dir']) relpath = os.path.relpath(full_path, self.env['baremetal_source_dir'])