Skip to content

Commit

Permalink
[Tizen] CI workflow for running QEMU-based tests (#24871)
Browse files Browse the repository at this point in the history
* Uniform way for testing targets

* Add README

* [Tizen] Add QEMU runner with lighting app tests

* Get default Tizen SDK location from env vars

* Revert "Uniform way for testing targets"

This reverts commit a04dabd.

* Add Tizen test driver app to the build_examples.py

* Tizen QEMU tests workflow

* Update Tizen QEMU-based tests documentation

* Enable external network support in QEMU

* Update testdata for build example targets

* Generate Tizen QEMU-base test target in a single step

* Restyled by prettier-markdown

* Fix flashbundle copy after changing tpk output dir

* Use chip-build-tizen-qemu:0.6.39 as 0.6.40 is not on dockerhub yet

* Drop concept of QEMU as a Tizen board and simply use ARM as a generic
name for all ARM-based boards.

---------

Co-authored-by: Damian Michalak-Szmaciński <d.michalak@samsung.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
3 people authored and pull[bot] committed Sep 22, 2023
1 parent 136af90 commit 1064764
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 30 deletions.
46 changes: 45 additions & 1 deletion .github/workflows/qemu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ env:
CHIP_NO_LOG_TIMESTAMPS: true

jobs:
qemu:

qemu-esp32:
name: ESP32
timeout-minutes: 85

Expand Down Expand Up @@ -94,3 +95,46 @@ jobs:
with:
name: qemu-esp32-logs
path: /tmp/log_output

qemu-tizen:
name: Tizen

runs-on: ubuntu-latest
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build-tizen-qemu:0.6.39
volumes:
- "/tmp/log_output:/tmp/test_logs"

steps:
- uses: Wandalen/wretry.action@v1.0.36
name: Checkout
with:
action: actions/checkout@v3
with: |
token: ${{ github.token }}
attempt_limit: 3
attempt_delay: 2000
- name: Checkout submodules
run: scripts/checkout_submodules.py --shallow --platform tizen

- name: Bootstrap cache
uses: actions/cache@v3
timeout-minutes: 10
with:
key: ${{ runner.os }}-env-${{ hashFiles('scripts/setup/*', 'third_party/pigweed/**') }}
path: |
.environment
build_overrides/pigweed_environment.gni
- name: Bootstrap
timeout-minutes: 25
run: scripts/build/gn_bootstrap.sh

- name: Build and run tests
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target tizen-arm-tests-no-ble \
build
"
12 changes: 11 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -668,12 +668,21 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {

if (enable_tizen_lighting_app) {
group("tizen_lighting_app") {
deps = [ "${chip_root}/examples/lighting-app/tizen/(${chip_root}/build/toolchain/tizen:tizen_arm)" ]
deps = [ "${chip_root}/examples/lighting-app/tizen(${chip_root}/build/toolchain/tizen:tizen_arm)" ]
}

extra_build_deps += [ ":tizen_lighting_app" ]
}

if (enable_tizen_builds) {
group("check:tizen") {
testonly = true
deps = [ "${chip_root}/src/test_driver/tizen/integration-tests:check" ]
}

extra_check_deps += [ ":check:tizen" ]
}

if (enable_mw320_shell_build) {
group("mw320_shell") {
deps = [ "${chip_root}/examples/shell/mw320(${chip_root}/config/mw320/toolchain:mw320_shell)" ]
Expand Down Expand Up @@ -703,6 +712,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
}

group("check") {
testonly = true
deps = extra_check_deps
foreach(_build, builds) {
deps += [ get_label_info(_build, "dir") + ":check_" +
Expand Down
8 changes: 4 additions & 4 deletions build/config/tizen/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

declare_args() {
# Location of The Tizen sysroot
tizen_sdk_sysroot = ""
# Location of Tizen SDK
tizen_sdk_root = getenv("TIZEN_SDK_ROOT")

# Location of the Tizen SDK.
tizen_sdk_root = ""
# Location of Tizen SDK sysroot
tizen_sdk_sysroot = getenv("TIZEN_SDK_SYSROOT")
}
6 changes: 1 addition & 5 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import re
from itertools import combinations
from typing import Any, List, Optional

from builders.ameba import AmebaApp, AmebaBoard, AmebaBuilder
from builders.android import AndroidApp, AndroidBoard, AndroidBuilder, AndroidProfile
from builders.bouffalolab import BouffalolabApp, BouffalolabBoard, BouffalolabBuilder
Expand Down Expand Up @@ -477,6 +472,7 @@ def BuildTizenTarget():
TargetPart('all-clusters-minimal', app=TizenApp.ALL_CLUSTERS_MINIMAL),
TargetPart('chip-tool', app=TizenApp.CHIP_TOOL),
TargetPart('light', app=TizenApp.LIGHT),
TargetPart('tests', app=TizenApp.TESTS),
])

target.AppendModifier(name="no-ble", enable_ble=False)
Expand Down
26 changes: 18 additions & 8 deletions scripts/build/builders/tizen.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@

from .gn import GnBuilder

Board = namedtuple('Board', ['target_cpu'])
App = namedtuple('App', ['name', 'source', 'outputs'])
Tool = namedtuple('Tool', ['name', 'source', 'outputs'])
Board = namedtuple('Board', ['target_cpu'])
TestDriver = namedtuple('TestDriver', ['name', 'source'])


class TizenBoard(Enum):

ARM = Board('arm')


class TizenApp(Enum):
Expand All @@ -49,11 +55,19 @@ class TizenApp(Enum):
('chip-tool',
'chip-tool.map'))

TESTS = TestDriver(
'tests',
'src/test_driver/tizen')

@property
def is_tpk(self):
"""If True, this app is a TPK."""
return isinstance(self.value, App)

@property
def package(self):
return f'{self.package_name}-{self.package_version}.tpk'

@property
def package_name(self):
return self.manifest.get('package')
Expand All @@ -66,11 +80,6 @@ def parse_manifest(self, manifest: str):
self.manifest = ET.parse(manifest).getroot()


class TizenBoard(Enum):

ARM = Board('arm')


class TizenBuilder(GnBuilder):

def __init__(self,
Expand Down Expand Up @@ -143,7 +152,8 @@ def build_outputs(self):
def flashbundle(self):
if not self.app.is_tpk:
return {}
tpk = f'{self.app.package_name}-{self.app.package_version}.tpk'
return {
tpk: os.path.join(self.output_dir, 'package', 'out', tpk),
self.app.package: os.path.join(self.output_dir,
self.app.package_name, 'out',
self.app.package),
}
2 changes: 1 addition & 1 deletion scripts/build/testdata/all_targets_linux_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ mw320-all-clusters-app
nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,lock,light,light-switch,shell,pump,pump-controller,window-covering}[-rpc]
nrf-native-posix-64-tests
qpg-qpg6105-{lock,light,shell,persistent-storage}
tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light}[-no-ble][-no-wifi][-asan][-ubsan]
tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-wifi][-asan][-ubsan]
telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,thermostat}[-rpc]
openiotsdk-{shell,lock}
25 changes: 25 additions & 0 deletions src/test_driver/tizen/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
target_os = "tizen"
}
18 changes: 18 additions & 0 deletions src/test_driver/tizen/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

group("check") {
testonly = true
deps = [ "integration_tests/lighting-app:check" ]
}
54 changes: 54 additions & 0 deletions src/test_driver/tizen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# CHIP Tests on QEMU

Tizen runs mostly on ARM architecture. In order to run tests on Tizen, we need
to use QEMU. This document describes how to build and run CHIP tests on QEMU.

## Obtaining Tizen QEMU Docker Image

All tools and dependencies required to build and run tests on Tizen on QEMU are
included in the `chip-build-tizen-qemu` docker image. One can pull the docker
image from hub.docker.com or build it locally using the provided Dockerfile in
`integrations/docker/images/chip-build-tizen-qemu` directory.

```sh
# Pull the image from hub.docker.com
docker pull connectedhomeip/chip-build-tizen-qemu:latest
```

## Building and Running Tests on QEMU

All steps described below should be done inside the docker container.

```sh
docker run -it --rm --name chip-tizen-qemu \
connectedhomeip/chip-build-tizen-qemu:latest /bin/bash
```

### Clone the connectedhomeip repository

```sh
git clone https://github.com/project-chip/connectedhomeip.git
```

### Activate the environment

```sh
cd connectedhomeip
source scripts/activate.sh
```

### Generate and run test target

As for now, Tizen QEMU-based test driver does not support BLE. In order to
disable BLE, one needs to pass `chip_config_network_layer_ble=false` to the args
argument of the `gn gen` command.

```sh
# Generate test target
gn gen --check --fail-on-unused-args \
--root="$PWD/src/test_driver/tizen" \
--args="target_os=\"tizen\" target_cpu=\"arm\" chip_config_network_layer_ble=false" \
out/tizen-check
# Run Tizen QEMU-based tests
ninja -C out/tizen-check check
```
1 change: 1 addition & 0 deletions src/test_driver/tizen/build_overrides
46 changes: 46 additions & 0 deletions src/test_driver/tizen/integration_tests/lighting-app/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/tizen.gni")

import("${tizen_sdk_build_root}/tizen_sdk.gni")

tizen_qemu_mkisofs("test-runner") {
runner = "runner.sh"

# Build applications used in the test.
deps = [
"${chip_root}/examples/chip-tool:chip-tool",
"${chip_root}/examples/lighting-app/tizen:chip-lighting-app:tpk",
]

# Use artifacts created by the dependencies.
assets = [
rebase_path("${root_build_dir}/chip-tool"),
rebase_path(
"${root_build_dir}/org.tizen.matter.example.lighting/out/org.tizen.matter.example.lighting-1.0.0.tpk"),
]
}

tizen_qemu_run("check") {
# Enable network support, so Tizen can obtain current date/time from the
# network. Correct date/time is required for the commissioning process -
# attestation will fail otherwise.
virtio_net = true

deps = [ ":test-runner" ]
mkisofs_outputs = get_target_outputs(":test-runner")
iso_image = rebase_path(mkisofs_outputs[0])
}
34 changes: 34 additions & 0 deletions src/test_driver/tizen/integration_tests/lighting-app/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

#
# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -e

# Print CHIP logs on stdout
dlogutil CHIP &

# Install lighting Matter app
pkgcmd -i -t tpk -p /mnt/chip/org.tizen.matter.*
# Launch lighting Matter app
app_launcher -s org.tizen.matter.example.lighting

# TEST: pair app using network commissioning
/mnt/chip/chip-tool pairing onnetwork 1 20202021
# TEST: turn on light
/mnt/chip/chip-tool onoff on 1 1
# TEST: turn off light
/mnt/chip/chip-tool onoff off 1 1
1 change: 1 addition & 0 deletions src/test_driver/tizen/third_party/connectedhomeip
Loading

0 comments on commit 1064764

Please sign in to comment.