forked from flang-compiler/f18-llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lit] Add support for attach arbitrary metrics to test results.
- This is a work-in-progress and all details are subject to change, but I am trying to build up support for allowing lit to be used as a driver for performance tests (or other tests which might want to record information beyond simple PASS/FAIL). llvm-svn: 190535
- Loading branch information
Showing
5 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
try: | ||
import ConfigParser | ||
except ImportError: | ||
import configparser as ConfigParser | ||
|
||
import lit.formats | ||
import lit.Test | ||
|
||
class DummyFormat(lit.formats.FileBasedTest): | ||
def execute(self, test, lit_config): | ||
# In this dummy format, expect that each test file is actually just a | ||
# .ini format dump of the results to report. | ||
|
||
source_path = test.getSourcePath() | ||
|
||
cfg = ConfigParser.ConfigParser() | ||
cfg.read(source_path) | ||
|
||
# Create the basic test result. | ||
result_code = cfg.get('global', 'result_code') | ||
result_output = cfg.get('global', 'result_output') | ||
result = lit.Test.Result(getattr(lit.Test, result_code), | ||
result_output) | ||
|
||
# Load additional metrics. | ||
for key,value_str in cfg.items('results'): | ||
value = eval(value_str) | ||
if isinstance(value, int): | ||
metric = lit.Test.IntMetricValue(value) | ||
elif isinstance(value, float): | ||
metric = lit.Test.RealMetricValue(value) | ||
else: | ||
raise RuntimeError("unsupported result type") | ||
result.addMetric(key, metric) | ||
|
||
return result | ||
|
||
config.name = 'test-data' | ||
config.suffixes = ['.ini'] | ||
config.test_format = DummyFormat() | ||
config.test_source_root = None | ||
config.test_exec_root = None | ||
config.target_triple = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[global] | ||
result_code = PASS | ||
result_output = 'Test passed.' | ||
|
||
[results] | ||
value0 = 1 | ||
value1 = 2.3456 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Test features related to formats which support reporting additional test data. | ||
|
||
# RUN: %{lit} -j 1 -v %{inputs}/test-data > %t.out | ||
# RUN: FileCheck < %t.out %s | ||
|
||
# CHECK: -- Testing: | ||
|
||
# CHECK: PASS: test-data :: metrics.ini | ||
# CHECK-NEXT: *** TEST 'test-data :: metrics.ini' RESULTS *** | ||
# CHECK-NEXT: value0: 1 | ||
# CHECK-NEXT: value1: 2.3456 | ||
# CHECK-NEXT: *** |