-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for Zephyr builder snippets support
This patch adds integration tests for Zephyr builder snippets support. The tests are checking the following cases: - Zephyr builder with one snippet - Zephyr builder with two snippets - Zephyr builder with snippet and shield - Zephyr builder with no snippets Signed-off-by: Mykyta Poturai <[email protected]>
- Loading branch information
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...ephyr_builder/test_zephyr_snippets_support/resources/zephyr_builder_with_no_snippets.yaml
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,21 @@ | ||
desc: "Integration test Zephyr snippets" | ||
min_ver: "0.22" | ||
|
||
|
||
components: | ||
dom0: | ||
default: true | ||
build-dir: "ZEPHYR_BUILD_DIR" | ||
sources: | ||
- type: west | ||
url: "https://github.com/xen-troops/aos_core_zephyr.git" | ||
rev: "zephyr-v3.6.0" | ||
|
||
builder: | ||
type: zephyr | ||
board: "rcar_spider" | ||
target: aos_core_zephyr | ||
work_dir: build | ||
|
||
target_images: | ||
- "build/zephyr/zephyr.bin" |
28 changes: 28 additions & 0 deletions
28
...ephyr_builder/test_zephyr_snippets_support/resources/zephyr_builder_with_one_snippet.yaml
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,28 @@ | ||
desc: "Integration test Zephyr snippets" | ||
min_ver: "0.22" | ||
|
||
|
||
components: | ||
dom0: | ||
default: true | ||
build-dir: "ZEPHYR_BUILD_DIR" | ||
sources: | ||
- type: west | ||
url: "https://github.com/xen-troops/aos_core_zephyr.git" | ||
rev: "zephyr-v3.6.0" | ||
|
||
builder: | ||
type: zephyr | ||
board: "rcar_spider" | ||
target: aos_core_zephyr | ||
work_dir: build | ||
|
||
snippets: | ||
- "xen_dom0" | ||
|
||
additional_deps: | ||
- "dep_1" | ||
- "dep_2" | ||
|
||
target_images: | ||
- "build/zephyr/zephyr.bin" |
31 changes: 31 additions & 0 deletions
31
...uilder/test_zephyr_snippets_support/resources/zephyr_builder_with_snippet_and_shield.yaml
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,31 @@ | ||
desc: "Integration test Zephyr snippets" | ||
min_ver: "0.22" | ||
|
||
|
||
components: | ||
dom0: | ||
default: true | ||
build-dir: "ZEPHYR_BUILD_DIR" | ||
sources: | ||
- type: west | ||
url: "https://github.com/xen-troops/aos_core_zephyr.git" | ||
rev: "zephyr-v3.6.0" | ||
|
||
builder: | ||
type: zephyr | ||
board: "rcar_spider" | ||
target: aos_core_zephyr | ||
work_dir: build | ||
|
||
shields: | ||
- "xen_dom0" | ||
|
||
snippets: | ||
- "xen_dom0" | ||
|
||
additional_deps: | ||
- "dep_1" | ||
- "dep_2" | ||
|
||
target_images: | ||
- "build/zephyr/zephyr.bin" |
29 changes: 29 additions & 0 deletions
29
...phyr_builder/test_zephyr_snippets_support/resources/zephyr_builder_with_two_snippets.yaml
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,29 @@ | ||
desc: "Integration test Zephyr snippets" | ||
min_ver: "0.22" | ||
|
||
|
||
components: | ||
dom0: | ||
default: true | ||
build-dir: "ZEPHYR_BUILD_DIR" | ||
sources: | ||
- type: west | ||
url: "https://github.com/xen-troops/aos_core_zephyr.git" | ||
rev: "zephyr-v3.6.0" | ||
|
||
builder: | ||
type: zephyr | ||
board: "rcar_spider" | ||
target: aos_core_zephyr | ||
work_dir: build | ||
|
||
snippets: | ||
- "xen_dom0" | ||
- "xen_dom1" | ||
|
||
additional_deps: | ||
- "dep_1" | ||
- "dep_2" | ||
|
||
target_images: | ||
- "build/zephyr/zephyr.bin" |
85 changes: 85 additions & 0 deletions
85
...gration_tests/zephyr_builder/test_zephyr_snippets_support/test_zephyr_snippets_support.py
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,85 @@ | ||
import subprocess | ||
import pytest | ||
import os | ||
import tempfile | ||
import re | ||
@pytest.mark.integration | ||
def test_zephyr_one_snippet(): | ||
script_path = os.path.abspath(__file__) | ||
script_dir_path = os.path.dirname(script_path) | ||
yaml_file = os.path.join(script_dir_path, "resources/zephyr_builder_with_one_snippet.yaml") | ||
|
||
with tempfile.TemporaryDirectory(dir=script_dir_path) as tmp_dir: | ||
|
||
result = subprocess.run(["python", "../../../../../moulin.py", yaml_file], | ||
cwd=tmp_dir, | ||
stderr=subprocess.PIPE, | ||
text=True) | ||
|
||
assert result.returncode == 0, ("The return code is equal to '0'") | ||
|
||
with open(tmp_dir + "/build.ninja") as f: | ||
ninja_file = f.read() | ||
assert re.search(r"west build .*(\$\n)?.* \$snippets .*", ninja_file) is not None, "Snippets paremeter present" | ||
assert "snippets = -S xen_dom0" in ninja_file | ||
|
||
@pytest.mark.integration | ||
def test_zephyr_two_snippets(): | ||
script_path = os.path.abspath(__file__) | ||
script_dir_path = os.path.dirname(script_path) | ||
yaml_file = os.path.join(script_dir_path, "resources/zephyr_builder_with_two_snippets.yaml") | ||
|
||
with tempfile.TemporaryDirectory(dir=script_dir_path) as tmp_dir: | ||
|
||
result = subprocess.run(["python", "../../../../../moulin.py", yaml_file], | ||
cwd=tmp_dir, | ||
stderr=subprocess.PIPE, | ||
text=True) | ||
|
||
assert result.returncode == 0, ("The return code is equal to '0'") | ||
|
||
with open(tmp_dir + "/build.ninja") as f: | ||
ninja_file = f.read() | ||
assert re.search(r"west build .*(\$\n)?.* \$snippets .*", ninja_file) is not None, "Snippets paremeter present" | ||
assert "snippets = -S xen_dom0 -S xen_dom1" in ninja_file | ||
|
||
@pytest.mark.integration | ||
def test_zephyr_snippet_and_shield(): | ||
script_path = os.path.abspath(__file__) | ||
script_dir_path = os.path.dirname(script_path) | ||
yaml_file = os.path.join(script_dir_path, "resources/zephyr_builder_with_snippet_and_shield.yaml") | ||
|
||
with tempfile.TemporaryDirectory(dir=script_dir_path) as tmp_dir: | ||
|
||
result = subprocess.run(["python", "../../../../../moulin.py", yaml_file], | ||
cwd=tmp_dir, | ||
stderr=subprocess.PIPE, | ||
text=True) | ||
|
||
assert result.returncode != 0, ("The return code is not equal to '0'") | ||
assert "Both shields and snippets are specified, only one of them is allowed" in result.stderr, \ | ||
("The expected error message") | ||
|
||
@pytest.mark.integration | ||
def test_zephyr_no_snippets(): | ||
script_path = os.path.abspath(__file__) | ||
script_dir_path = os.path.dirname(script_path) | ||
yaml_file = os.path.join(script_dir_path, "resources/zephyr_builder_with_no_snippets.yaml") | ||
|
||
with tempfile.TemporaryDirectory(dir=script_dir_path) as tmp_dir: | ||
|
||
result = subprocess.run(["python", "../../../../../moulin.py", yaml_file], | ||
cwd=tmp_dir, | ||
stderr=subprocess.PIPE, | ||
text=True) | ||
|
||
assert result.returncode == 0, ("The return code is equal to '0'") | ||
|
||
with open(tmp_dir + "/build.ninja") as f: | ||
ninja_file = f.read() | ||
print(ninja_file) | ||
print(re.search(r"snippets = $", ninja_file, re.M)) | ||
assert re.search(r"snippets = $", ninja_file, re.M) is not None, "Snippets paremeter not present" | ||
|
||
if __name__ == "__main__": | ||
pytest.main([__file__]) |