Commit Graph

5 Commits

Author SHA1 Message Date
Aseda Aboagye
6e96a91f24 config_option_check.py: Ignore hidden files.
When this script is searching through CONFIG_* options used in the repo,
it should ignore hidden files.  I uncovered this by accidentally having
modified a file and the presubmit hook failed.  This is because emacs
auto-saves files with the format ".#filename.ext".  Now, the script will
ignore hidden files.

BUG=None
BRANCH=None
TEST=Use emacs to modify a c file but not save it. Run the script and
verify that no errors occur.
TEST=make -j buildall tests

Change-Id: Ie09cfcf66f2e416aeed99847945cb5168b457d1a
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/300954
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-18 16:34:20 -07:00
Aseda Aboagye
9fc5ae515e util: More enhancements to config_option_check.py.
This commit enhances the config_option_check.py script a little bit
more.

Firstly, I fixed a bug where lines beginning with an '*' were treated as a
comment where it was not so.

  ex: *status = (CONFIG_BAR_PORT & 0x23);

Additionally, I added support for considering deletions.  This allows
the script to check to see if a CONFIG_* option being removed is being
used anywhere else in the repo.  If the option isn't used elsewhere,
then it appears to be the removal of the last use.  An error is flagged
informing the user to remove that option from the main config file.
This helps to keep the config file up to date without leaving stale
CONFIG_* options where one might not know if they still work or not.
Debug config options are always assumed to be used as those are
typically enabled locally.

BUG=chromium:510672
BRANCH=None
TEST=Used a new config option without adding it to the main config file
and watched the error be flagged.
TEST=Removed the last use of a CONFIG_* option while leaving the option
in the main config file. Observed that it was flagged.
TEST=cros lint --debug util/config_option_check.py
TEST=make -j buildall tests

Change-Id: I8702ad06d9856c14f7bcd4592e917a5d3fcb6b57
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/294620
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
2015-08-27 01:49:38 +00:00
Aseda Aboagye
96888b2f9b util: Enhanced config_option_check.py.
This commit enhances the config option check python script to
significantly reduce the number of false positives.

 - Now only checks committed changes.
 - Only checks additions, not the whole file.
 - Only checks uses of CONFIG_* not in a comment for both C-style and
   Make-style files.
 - Suports a whitelist.

BUG=chromium:510672
BRANCH=None
TEST=Detected missing configs in Makefiles and C source files.
TEST=/* CONFIG_FOO */ was not detected.
TEST=' board-$(CONFIG_OPT)=board.o # CONFIG_OPT2' only CONFIG_OPT was
detected.
TEST=Changes in working dir were not detected.
TEST=Changes to config_option_check.py were not detected.
TEST=cros lint --debug util/config_option_check.py
TEST=CONFIG_FOO in a multi-line C comment was not detected.

Change-Id: I5fc2ccc77bb4f319a3c85b7d81c83027959dc96b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/287519
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
2015-07-24 21:54:27 +00:00
Vadim Bendebury
53a2bbace3 util: small config_option_check.py improvements
As of now this check results in false positives, for instance
'CONFIG_' found in the comments results in an error report.

This patch makes the script a bit more robust:
  - consider only those options mentioned in include/config.h as
    explicitly defined or undefined.
  - do not scan include/config.h for new added CONFIG_ options
  - ignore comments in .mk files

Ideally the script should be scanning only added lines of code and
much smarter about what should be considered a comment and what files
should be examined.

BRANCH=none
BUG=chromium:510672
TEST=the false positives triggered by comments in various build.mk
     files are gone now. Adding an undescribed CONFIG_xxx text still
     triggers the error.

Change-Id: Ib9858775bcd9899dec629682a1c7965e7c2fec96
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/285926
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-07-17 00:07:38 +00:00
Aseda Aboagye
0ec956ea9d util: Add config option checker.
There are several cases in the EC code base where a CONFIG_* option is
used somewhere, but not defined within the include/config.h file.  This
script aims to fix that.  Eventually, it will become a presubmit hook to
actively prevent future offenses.

BUG=chrome-os-partner:26304
BRANCH=none
TEST=cros lint --debug util/config_option_check.py
TEST=Ran script and found offending config options.
TEST=make -j buildall tests

Change-Id: I999d32ebacc636b3fff9e857f3cc46feee475e80
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/281626
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
2015-06-27 19:29:29 +00:00