diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-03 17:54:19 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-03 18:36:04 +0100 |
| commit | 25b68ab5a7beb3b49e41588f0451f1099e3e38e4 (patch) | |
| tree | 675363a81a2996eb057b9c4b9f4d564a4e7035c6 | |
| parent | b9409a7ca140f5f677b46293f0c8db52b14280d9 (diff) | |
Record locations for symbols defined with 'menuconfig'.
We previously only looked for T_CONFIG to determine if a location should
be recorded. We need to look for T_MENUCONFIG as well.
Also add some sanity checks for get_ref/def_location() to the test
suite.
| -rw-r--r-- | kconfiglib.py | 2 | ||||
| -rw-r--r-- | kconfigtest.py | 43 |
2 files changed, 41 insertions, 4 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index ee81c50..3d81265 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1054,7 +1054,7 @@ class Config(): # time we see it. sym = self._sym_lookup(name, not for_eval) - if previous == T_CONFIG: + if previous in (T_CONFIG, T_MENUCONFIG): # If the previous token is T_CONFIG ("config"), we're # tokenizing the first line of a symbol definition, and # should remember this as a location where the symbol diff --git a/kconfigtest.py b/kconfigtest.py index 32d6f33..a08c75b 100644 --- a/kconfigtest.py +++ b/kconfigtest.py @@ -197,7 +197,7 @@ def test_all_yes(conf): shell("make allyesconfig") def test_call_all(conf): - """Call all public methods on all symbols, menus, choices and comments (nearly all public methods: some are hard to test like this, but are exercised by other tests) for all architectures to make sure we never crash or hang""" + """Call all public methods on all symbols, menus, choices and comments (nearly all public methods: some are hard to test like this, but are exercised by other tests) for all architectures to make sure we never crash or hang. Also do misc. sanity checks.""" print " For {0}...".format(conf.get_arch()) conf.get_arch() @@ -241,11 +241,48 @@ def test_call_all(conf): s.get_selected_symbols() s.get_help() s.get_config() - s.get_def_locations() + + # Check get_ref/def_location() sanity + + if s.is_special(): + if s.is_from_environment(): + # Special symbols from the environment should have define + # locations + if s.get_def_locations() == []: + print "Fail: the symbol '{0}' is from the environment "\ + "but lacks define locations".format(s.get_name()) + fail() + else: + # Special symbols that are not from the environment should be + # defined and have no define locations + if not s.is_defined(): + print "Fail: the special symbol '{0}' is not defined".\ + format(s.get_name()) + fail() + if not s.get_def_locations() == []: + print "Fail: the special symbol '{0}' has recorded def. "\ + "locations".format(s.get_name()) + fail() + else: + # Non-special symbols should have define locations iff they are + # defined + if s.is_defined(): + if s.get_def_locations() == []: + print "Fail: '{0}' defined but lacks recorded locations".\ + format(s.get_name()) + fail() + else: + if s.get_def_locations() != []: + print "Fail: '{0}' undefined but has recorded locations".\ + format(s.get_name()) + fail() + if s.get_ref_locations() == []: + print "Fail: '{0}' both undefined and unreferenced".\ + format(s.get_name()) + s.get_ref_locations() s.is_modifiable() s.is_defined() - s.is_special() s.is_from_environment() s.has_ranges() s.is_choice_item() |
