-
Notifications
You must be signed in to change notification settings - Fork 10
/
test_examples.py
79 lines (68 loc) · 2.51 KB
/
test_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#
# Compilation tests
#
# Copyright (c) 2020, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
import pytest
import os
import subprocess
EXAMPLES_PATH = os.path.normpath(
os.path.join(
os.path.dirname(__file__),
'../examples'))
EXAMPLES = []
for name in os.listdir(EXAMPLES_PATH):
path = os.path.join(EXAMPLES_PATH, name)
if (not name.startswith('_') and not name.startswith('.')
and os.path.isdir(path)):
EXAMPLES.append((name, path))
EXAMPLES = sorted(EXAMPLES)
EXAMPLES_IDS = list(zip(*EXAMPLES))[0]
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_boxes_scan(name, path):
os.chdir(path)
subprocess.check_call(['bento', 'boxes', '-B', '-L'])
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_boxes_box(name, path):
os.chdir(path)
subprocess.check_call(['bento', 'boxes', '-L'])
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_boxes(name, path):
os.chdir(path)
subprocess.check_call(['bento', 'boxes'])
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_hooks(name, path):
os.chdir(path)
subprocess.check_call(['bento', 'hooks'])
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_links(name, path):
os.chdir(path)
subprocess.check_call(['bento', 'links'])
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_build(name, path):
os.chdir(path)
# build artifacts
subprocess.check_call(['bento', 'build'])
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_build_make_debug(name, path):
os.chdir(path)
# build artifacts
subprocess.check_call(['bento', 'build', '--all.output.mk.debug=true'])
# try to compile
subprocess.check_call(['make', 'clean', 'build', 'CFLAGS+=-Werror'])
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_build_make_nolto(name, path):
os.chdir(path)
# build artifacts
subprocess.check_call(['bento', 'build', '--all.output.mk.lto=false'])
# try to compile
subprocess.check_call(['make', 'clean', 'build', 'CFLAGS+=-Werror'])
# in this order so we end up with a clean build
@pytest.mark.parametrize('name, path', EXAMPLES, ids=EXAMPLES_IDS)
def test_build_make(name, path):
os.chdir(path)
# build artifacts
subprocess.check_call(['bento', 'build'])
# try to compile
subprocess.check_call(['make', 'clean', 'build', 'CFLAGS+=-Werror'])