From 02d1131cf6ee76ce89e63121aa90512e153e15bf Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Fri, 9 Mar 2018 23:58:58 +0100 Subject: testsuite.py: Break out a defconfig_files() helper defconfig_files() yields all the defconfig files for a particular arch/ subdirectory. This will allow reuse when savedefconfig is tested. Also simplify the code a bit. --- testsuite.py | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index b77dd5c..176de91 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1980,39 +1980,15 @@ def test_defconfig(conf, arch, srcarch): With logging enabled, this test appends any failures to a file test_defconfig_fails in the root. """ - defconfigs = [] - - def add_configs_for_arch(srcarch): - srcarch_dir = os.path.join("arch", srcarch) - - # Some arches have a "defconfig" in the root of their arch// - # directory - root_defconfig = os.path.join(srcarch_dir, "defconfig") - if os.path.exists(root_defconfig): - defconfigs.append(root_defconfig) - - # Assume all files in the arch//configs directory (if it - # exists) are configurations - defconfigs_dir = os.path.join(srcarch_dir, "configs") - if not os.path.exists(defconfigs_dir): - return - - if not os.path.isdir(defconfigs_dir): - print("Warning: '{}' is not a directory - skipping" - .format(defconfigs_dir)) - return - - for dirpath, _, filenames in os.walk(defconfigs_dir): - for filename in filenames: - defconfigs.append(os.path.join(dirpath, filename)) - if obsessive: + defconfigs = [] + # Collect all defconfigs. This could be done once instead, but it's # a speedy operation comparatively. for srcarch_ in os.listdir("arch"): - add_configs_for_arch(srcarch_) + defconfigs.extend(defconfig_files(srcarch_)) else: - add_configs_for_arch(srcarch) + defconfigs = defconfig_files(srcarch) # Test architecture for each defconfig @@ -2050,6 +2026,28 @@ def test_defconfig(conf, arch, srcarch): # Helper functions # +def defconfig_files(srcarch): + # Yields a list of defconfig file filenames for a particular srcarch + # subdirectory (arch//) + + srcarch_dir = os.path.join("arch", srcarch) + + # Some arches have a defconfig in the root of their arch// directory + root_defconfig = os.path.join(srcarch_dir, "defconfig") + if os.path.exists(root_defconfig): + yield root_defconfig + + # Assume all files in the arch//configs/ directory (if it exists) are + # configurations + defconfigs_dir = os.path.join(srcarch_dir, "configs") + + if not os.path.isdir(defconfigs_dir): + return + + for dirpath, _, filenames in os.walk(defconfigs_dir): + for filename in filenames: + yield os.path.join(dirpath, filename) + def rm_configs(): """ Delete any old ".config" (generated by the C implementation) and -- cgit v1.2.3