Skip to content

Commit 32b9ada

Browse files
committed
Enforce device_name is valid in targets.json
Add a CI test ensure that device_name exists inside the pack index.
1 parent acdf1e3 commit 32b9ada

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ script:
55
- make -C events/equeue test clean
66
- PYTHONPATH=. python tools/test/config_test/config_test.py
77
- PYTHONPATH=. python tools/test/build_api/build_api_test.py
8+
- PYTHONPATH=. python tools/test/targets/target_test.py
89
- python tools/test/pylint.py
910
- py.test tools/test/toolchains/api.py
1011
- python tools/test/memap/memap_test.py

tools/test/targets/target_test.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
"""
3+
mbed
4+
Copyright (c) 2017-2017 ARM Limited
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
"""
18+
19+
import sys
20+
from os.path import join, abspath, dirname
21+
import unittest
22+
23+
# Be sure that the tools directory is in the search path
24+
ROOT = abspath(join(dirname(__file__), "..", "..", ".."))
25+
sys.path.insert(0, ROOT)
26+
27+
from tools.targets import TARGETS
28+
from tools.arm_pack_manager import Cache
29+
30+
class TestTargets(unittest.TestCase):
31+
32+
def test_device_name(self):
33+
"""Assert device name is in a pack"""
34+
cache = Cache(True, True)
35+
named_targets = (target for target in TARGETS if
36+
hasattr(target, "device_name"))
37+
for target in named_targets:
38+
self.assertTrue(target.device_name in cache.index,
39+
"Target %s contains invalid device_name %s" %
40+
(target.name, target.device_name))
41+
42+
if __name__ == '__main__':
43+
unittest.main()

0 commit comments

Comments
 (0)