summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite.py41
1 files changed, 33 insertions, 8 deletions
diff --git a/testsuite.py b/testsuite.py
index 3301ed5..175d278 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -35,14 +35,6 @@
# All tests should pass. Report regressions to ulfalizer a.t Google's email
# service.
-from kconfiglib import Kconfig, Symbol, Choice, COMMENT, MENU, MenuNode, \
- BOOL, TRISTATE, HEX, STRING, \
- TRI_TO_STR, \
- escape, unescape, \
- expr_str, expr_value, expr_items, split_expr, \
- _ordered_unique, \
- OR, AND, \
- KconfigError
import difflib
import errno
import os
@@ -54,26 +46,41 @@ import sys
import tempfile
import textwrap
+from kconfiglib import Kconfig, Symbol, Choice, COMMENT, MENU, MenuNode, \
+ BOOL, TRISTATE, HEX, STRING, \
+ TRI_TO_STR, \
+ escape, unescape, \
+ expr_str, expr_value, expr_items, split_expr, \
+ _ordered_unique, \
+ OR, AND, \
+ KconfigError
+
+
def shell(cmd):
with open(os.devnull, "w") as devnull:
subprocess.call(cmd, shell=True, stdout=devnull, stderr=devnull)
+
all_passed = True
+
def fail(msg=None):
global all_passed
all_passed = False
if msg is not None:
print("fail: " + msg)
+
def verify(cond, msg):
if not cond:
fail(msg)
+
def verify_equal(x, y):
if x != y:
fail("'{}' does not equal '{}'".format(x, y))
+
# Prevent accidental loading of configuration files by removing
# KCONFIG_ALLCONFIG from the environment
os.environ.pop("KCONFIG_ALLCONFIG", None)
@@ -82,6 +89,7 @@ obsessive = False
obsessive_min_config = False
log = False
+
def run_tests():
global obsessive, log
for s in sys.argv[1:]:
@@ -101,6 +109,7 @@ def run_tests():
run_selftests()
run_compatibility_tests()
+
def run_selftests():
#
# Common helper functions. These all expect 'c' to hold the current
@@ -2593,6 +2602,7 @@ menu "menu"
print("\nAll selftests passed\n" if all_passed else
"\nSome selftests failed\n")
+
def run_compatibility_tests():
"""
Runs tests on configurations from the kernel. Tests compability with the
@@ -2657,6 +2667,7 @@ def run_compatibility_tests():
else:
sys.exit("Some tests failed")
+
def all_arch_srcarch():
for srcarch in os.listdir("arch"):
# arc and h8300 are currently broken with the C tools on linux-next as
@@ -2681,6 +2692,7 @@ def all_arch_srcarch():
yield ("sh64", "sh")
+
def test_allnoconfig(arch, srcarch):
"""
Verify that allnoconfig.py generates the same .config as
@@ -2694,6 +2706,7 @@ def test_allnoconfig(arch, srcarch):
compare_configs(arch)
+
def test_allnoconfig_walk(arch, srcarch):
"""
Verify that examples/allnoconfig_walk.py generates the same .config as
@@ -2707,6 +2720,7 @@ def test_allnoconfig_walk(arch, srcarch):
compare_configs(arch)
+
def test_allmodconfig(arch, srcarch):
"""
Verify that allmodconfig.py generates the same .config as
@@ -2720,6 +2734,7 @@ def test_allmodconfig(arch, srcarch):
compare_configs(arch)
+
def test_allyesconfig(arch, srcarch):
"""
Verify that allyesconfig.py generates the same .config as
@@ -2733,6 +2748,7 @@ def test_allyesconfig(arch, srcarch):
compare_configs(arch)
+
def test_sanity(arch, srcarch):
"""
Do sanity checks on each configuration and call all public methods on all
@@ -2882,6 +2898,7 @@ def test_sanity(arch, srcarch):
else:
break
+
def test_alldefconfig(arch, srcarch):
"""
Verify that alldefconfig.py generates the same .config as
@@ -2895,6 +2912,7 @@ def test_alldefconfig(arch, srcarch):
compare_configs(arch)
+
def test_defconfig(arch, srcarch):
"""
Verify that Kconfiglib generates the same .config as scripts/kconfig/conf,
@@ -2940,6 +2958,7 @@ def test_defconfig(arch, srcarch):
fail_log.write("{} with {} did not match\n"
.format(arch, defconfig))
+
def test_min_config(arch, srcarch):
"""
Verify that Kconfiglib generates the same .config as 'make savedefconfig'
@@ -2971,10 +2990,12 @@ def test_min_config(arch, srcarch):
else:
print(arch_defconfig_str + "FAIL")
+
#
# Helper functions
#
+
def defconfig_files(srcarch):
# Yields a list of defconfig file filenames for a particular srcarch
# subdirectory (arch/<srcarch>/)
@@ -2997,6 +3018,7 @@ def defconfig_files(srcarch):
for filename in filenames:
yield os.path.join(dirpath, filename)
+
def rm_configs():
"""
Delete any old ".config" (generated by the C implementation) and
@@ -3009,6 +3031,7 @@ def rm_configs():
rm_if_exists(".config")
rm_if_exists("._config")
+
def compare_configs(arch):
if equal_configs():
print("{:14}OK".format(arch))
@@ -3016,6 +3039,7 @@ def compare_configs(arch):
print("{:14}FAIL".format(arch))
fail()
+
def equal_configs():
with open(".config") as f:
their = f.readlines()
@@ -3051,5 +3075,6 @@ def equal_configs():
return False
+
if __name__ == "__main__":
run_tests()