mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 12:06:08 +00:00
tests: add unit test for includes
This commit is contained in:
parent
e4a856ad03
commit
8464c32808
7
tests/data/includes/agenda.yaml
Normal file
7
tests/data/includes/agenda.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
config:
|
||||
augmentations: [~execution_time]
|
||||
include#: configs/test.yaml
|
||||
sections:
|
||||
- include#: sections/section1.yaml
|
||||
- include#: sections/section2.yaml
|
||||
include#: workloads.yaml
|
1
tests/data/includes/configs/test.yaml
Normal file
1
tests/data/includes/configs/test.yaml
Normal file
@ -0,0 +1 @@
|
||||
augmentations: [cpufreq, trace-cmd]
|
2
tests/data/includes/section-include.yaml
Normal file
2
tests/data/includes/section-include.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
classifiers:
|
||||
included: true
|
1
tests/data/includes/sections/section1.yaml
Normal file
1
tests/data/includes/sections/section1.yaml
Normal file
@ -0,0 +1 @@
|
||||
classifiers: {'section': 'one'}
|
2
tests/data/includes/sections/section2.yaml
Normal file
2
tests/data/includes/sections/section2.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
classifiers: {'section': 'two'}
|
||||
include#: ../section-include.yaml
|
2
tests/data/includes/user/config.yaml
Normal file
2
tests/data/includes/user/config.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
augmentations: [execution_time]
|
||||
|
5
tests/data/includes/workloads.yaml
Normal file
5
tests/data/includes/workloads.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
workloads:
|
||||
- dhrystone
|
||||
- name: memcpy
|
||||
classifiers:
|
||||
memcpy: True
|
@ -17,19 +17,26 @@
|
||||
# pylint: disable=E0611
|
||||
# pylint: disable=R0201
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
from collections import defaultdict
|
||||
from unittest import TestCase
|
||||
|
||||
from nose.tools import assert_equal, assert_in, raises, assert_true
|
||||
|
||||
|
||||
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
|
||||
os.environ['WA_USER_DIRECTORY'] = os.path.join(DATA_DIR, 'includes')
|
||||
|
||||
from wa.framework.configuration.execution import ConfigManager
|
||||
from wa.framework.configuration.parsers import AgendaParser
|
||||
from wa.framework.exception import ConfigError
|
||||
from wa.utils.types import reset_all_counters
|
||||
|
||||
YAML_TEST_FILE = os.path.join(os.path.dirname(__file__), 'data', 'test-agenda.yaml')
|
||||
YAML_BAD_SYNTAX_FILE = os.path.join(os.path.dirname(__file__), 'data', 'bad-syntax-agenda.yaml')
|
||||
|
||||
YAML_TEST_FILE = os.path.join(DATA_DIR, 'test-agenda.yaml')
|
||||
YAML_BAD_SYNTAX_FILE = os.path.join(DATA_DIR, 'bad-syntax-agenda.yaml')
|
||||
INCLUDES_TEST_FILE = os.path.join(DATA_DIR, 'includes', 'agenda.yaml')
|
||||
|
||||
invalid_agenda_text = """
|
||||
workloads:
|
||||
@ -171,3 +178,37 @@ class AgendaTest(TestCase):
|
||||
@raises(ConfigError)
|
||||
def test_bad_syntax(self):
|
||||
self.parser.load_from_path(self.config, YAML_BAD_SYNTAX_FILE)
|
||||
|
||||
|
||||
class FakeTargetManager:
|
||||
|
||||
def merge_runtime_parameters(self, params):
|
||||
return params
|
||||
|
||||
def validate_runtime_parameters(self, params):
|
||||
pass
|
||||
|
||||
|
||||
class IncludesTest(TestCase):
|
||||
|
||||
def test_includes(self):
|
||||
from pprint import pprint
|
||||
parser = AgendaParser()
|
||||
cm = ConfigManager()
|
||||
tm = FakeTargetManager()
|
||||
|
||||
includes = parser.load_from_path(cm, INCLUDES_TEST_FILE)
|
||||
include_set = set([os.path.basename(i) for i in includes])
|
||||
assert_equal(include_set,
|
||||
set(['test.yaml', 'section1.yaml', 'section2.yaml',
|
||||
'section-include.yaml', 'workloads.yaml']))
|
||||
|
||||
job_classifiers = {j.id: j.classifiers
|
||||
for j in cm.jobs_config.generate_job_specs(tm)}
|
||||
assert_equal(job_classifiers,
|
||||
{
|
||||
's1-wk1': {'section': 'one'},
|
||||
's2-wk1': {'section': 'two', 'included': True},
|
||||
's1-wk2': {'section': 'one', 'memcpy': True},
|
||||
's2-wk2': {'section': 'two', 'included': True, 'memcpy': True},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user