aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergei Trofimov <sergei.trofimov@arm.com>2018-07-19 08:24:22 +0100
committerMarc Bonnici <marc.bonnici@arm.com>2018-07-23 16:47:10 +0100
commit8464c328083eed2f64d156861a80044bf8418d39 (patch)
treec9b47496026feebbcf74543d1dced5851e84f4b1 /tests
parente4a856ad03caee9e22c85b0619ee952d36992877 (diff)
tests: add unit test for includes
Diffstat (limited to 'tests')
-rw-r--r--tests/data/includes/agenda.yaml7
-rw-r--r--tests/data/includes/configs/test.yaml1
-rw-r--r--tests/data/includes/section-include.yaml2
-rw-r--r--tests/data/includes/sections/section1.yaml1
-rw-r--r--tests/data/includes/sections/section2.yaml2
-rw-r--r--tests/data/includes/user/config.yaml2
-rw-r--r--tests/data/includes/workloads.yaml5
-rw-r--r--tests/test_agenda_parser.py45
8 files changed, 63 insertions, 2 deletions
diff --git a/tests/data/includes/agenda.yaml b/tests/data/includes/agenda.yaml
new file mode 100644
index 00000000..22ce932d
--- /dev/null
+++ b/tests/data/includes/agenda.yaml
@@ -0,0 +1,7 @@
+config:
+ augmentations: [~execution_time]
+ include#: configs/test.yaml
+sections:
+ - include#: sections/section1.yaml
+ - include#: sections/section2.yaml
+include#: workloads.yaml
diff --git a/tests/data/includes/configs/test.yaml b/tests/data/includes/configs/test.yaml
new file mode 100644
index 00000000..de6ddee5
--- /dev/null
+++ b/tests/data/includes/configs/test.yaml
@@ -0,0 +1 @@
+augmentations: [cpufreq, trace-cmd]
diff --git a/tests/data/includes/section-include.yaml b/tests/data/includes/section-include.yaml
new file mode 100644
index 00000000..834ae52f
--- /dev/null
+++ b/tests/data/includes/section-include.yaml
@@ -0,0 +1,2 @@
+classifiers:
+ included: true
diff --git a/tests/data/includes/sections/section1.yaml b/tests/data/includes/sections/section1.yaml
new file mode 100644
index 00000000..87be7470
--- /dev/null
+++ b/tests/data/includes/sections/section1.yaml
@@ -0,0 +1 @@
+classifiers: {'section': 'one'}
diff --git a/tests/data/includes/sections/section2.yaml b/tests/data/includes/sections/section2.yaml
new file mode 100644
index 00000000..f97fb9a4
--- /dev/null
+++ b/tests/data/includes/sections/section2.yaml
@@ -0,0 +1,2 @@
+classifiers: {'section': 'two'}
+include#: ../section-include.yaml
diff --git a/tests/data/includes/user/config.yaml b/tests/data/includes/user/config.yaml
new file mode 100644
index 00000000..95144a38
--- /dev/null
+++ b/tests/data/includes/user/config.yaml
@@ -0,0 +1,2 @@
+augmentations: [execution_time]
+
diff --git a/tests/data/includes/workloads.yaml b/tests/data/includes/workloads.yaml
new file mode 100644
index 00000000..2619d370
--- /dev/null
+++ b/tests/data/includes/workloads.yaml
@@ -0,0 +1,5 @@
+workloads:
+ - dhrystone
+ - name: memcpy
+ classifiers:
+ memcpy: True
diff --git a/tests/test_agenda_parser.py b/tests/test_agenda_parser.py
index c14d212f..75239fcc 100644
--- a/tests/test_agenda_parser.py
+++ b/tests/test_agenda_parser.py
@@ -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},
+ })