diff options
author | lmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4> | 2010-11-27 18:06:24 +0000 |
---|---|---|
committer | lmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4> | 2010-11-27 18:06:24 +0000 |
commit | f405633d35e73800bf9405ef3a6363bd6d6c434b (patch) | |
tree | 2ce738a8089c9a06ee0c0b0de997597bb793fdf4 | |
parent | 609dbcb84a29609772da7f6edbab83f28e6c05ff (diff) |
Perf metrics with negative values never get into tko database
Perf metrics with negative values never get into tko database.
Generalize syntax of perf value to allow any float literal.
Signed-off-by: Duane Sand <duanes@google.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@4963 592f7852-d20e-0410-864c-8624ca9c26a4
-rw-r--r-- | tko/parsers/version_1.py | 13 | ||||
-rwxr-xr-x | tko/parsers/version_1_unittest.py | 12 |
2 files changed, 14 insertions, 11 deletions
diff --git a/tko/parsers/version_1.py b/tko/parsers/version_1.py index 111f7efa..7448c4fd 100644 --- a/tko/parsers/version_1.py +++ b/tko/parsers/version_1.py @@ -70,11 +70,14 @@ class iteration(models.iteration): val_type = "perf" # parse the actual value into a dict - if val_type == "attr": - attr_dict[key] = value - elif val_type == "perf" and re.search("^\d+(\.\d+)?$", value): - perf_dict[key] = float(value) - else: + try: + if val_type == "attr": + attr_dict[key] = value + elif val_type == "perf": + perf_dict[key] = float(value) + else: + raise ValueError + except ValueError: msg = ("WARNING: line '%s' found in test " "iteration keyval could not be parsed") msg %= line diff --git a/tko/parsers/version_1_unittest.py b/tko/parsers/version_1_unittest.py index 72444c5e..4114c59c 100755 --- a/tko/parsers/version_1_unittest.py +++ b/tko/parsers/version_1_unittest.py @@ -220,8 +220,8 @@ class iteration_parse_line_into_dicts(unittest.TestCase): def test_perf_entry(self): - result = self.parse_line("perf-val{perf}=173") - self.assertEqual(({}, {"perf-val": 173}), result) + result = self.parse_line("perf-val{perf}=-173") + self.assertEqual(({}, {"perf-val": -173}), result) def test_attr_entry(self): @@ -230,8 +230,8 @@ class iteration_parse_line_into_dicts(unittest.TestCase): def test_untagged_is_perf(self): - result = self.parse_line("untagged=678.5") - self.assertEqual(({}, {"untagged": 678.5}), result) + result = self.parse_line("untagged=-678.5e5") + self.assertEqual(({}, {"untagged": -678.5e5}), result) def test_invalid_tag_ignored(self): @@ -240,12 +240,12 @@ class iteration_parse_line_into_dicts(unittest.TestCase): def test_non_numeric_perf_ignored(self): - result = self.parse_line("perf-val{perf}=NaN") + result = self.parse_line("perf-val{perf}=FooBar") self.assertEqual(({}, {}), result) def test_non_numeric_untagged_ignored(self): - result = self.parse_line("untagged=NaN") + result = self.parse_line("untagged=FooBar") self.assertEqual(({}, {}), result) |