[autotest] Update suite_preprocessor.py to use only literals
When saving dependencies information, forcing all data to literal types
means that the resulting file can be read in with ast.literal_eval, which
is much safer than using eval().
BUG=chromium-os:22060
TEST=run suite_preprocessor.py and check the output to ensure all data is in literals.
Change-Id: I23ad701b0b44e7c6bed931f96836a87c5f70c488
Reviewed-on: https://gerrit.chromium.org/gerrit/24399
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Chris Masone <cmasone@chromium.org>
diff --git a/site_utils/suite_preprocessor.py b/site_utils/suite_preprocessor.py
index 6516752..b5fd40d 100755
--- a/site_utils/suite_preprocessor.py
+++ b/site_utils/suite_preprocessor.py
@@ -8,7 +8,8 @@
Given an autotest root directory, this tool will aggregate the DEPENDENCIES of
all tests into a single file ready for later consumption by the dynamic suite
-infrastructure.
+infrastructure. ALL DATA MUST BE STORED IN LITERAL TYPES! Dicts, lists,
+strings, etc.
Data will be written to stdout (or, optionally a file). Format will be:
@@ -53,7 +54,9 @@
if test.dependencies:
for suite in dynamic_suite.Suite.parse_tag(test.suite):
suite_deps = test_deps.setdefault(suite, {})
- suite_deps[test.path] = test.dependencies
+ # Force this to a list so that we can parse it later with
+ # ast.literal_eval() -- which is MUCH safer than eval()
+ suite_deps[test.path] = list(test.dependencies)
if options.output_file:
with open(options.output_file, 'w+') as fd: