Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tizen] CI workflow for running QEMU-based tests #24871

Merged
merged 19 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions .github/workflows/qemu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ env:
CHIP_NO_LOG_TIMESTAMPS: true

jobs:
qemu:

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

Expand All @@ -37,7 +38,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

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

Expand Down Expand Up @@ -83,3 +84,47 @@ 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
run: scripts/build/gn_bootstrap.sh

- name: Build Tizen examples used by QEMU test runner
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--enable-flashbundle \
--target tizen-arm-chip-tool-no-ble \
--target tizen-arm-light-no-ble \
build
"

- name: Run tests
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target tizen-qemu-tests-no-ble \
build
"
12 changes: 11 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,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 @@ -736,6 +745,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")
}
9 changes: 4 additions & 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
from builders.bouffalolab import BouffalolabApp, BouffalolabBoard, BouffalolabBuilder
Expand Down Expand Up @@ -448,6 +443,8 @@ def BuildTizenTarget():
# board
target.AppendFixedTargets([
TargetPart('arm', board=TizenBoard.ARM),
# QEMU does not support Bluetooth, so build all apps without BLE
TargetPart('qemu', board=TizenBoard.QEMU, enable_ble=False),
])

# apps
Expand All @@ -456,6 +453,8 @@ def BuildTizenTarget():
TargetPart('all-clusters-minimal', app=TizenApp.ALL_CLUSTERS_MINIMAL),
TargetPart('chip-tool', app=TizenApp.CHIP_TOOL),
TargetPart('light', app=TizenApp.LIGHT),
# test driver app
arkq marked this conversation as resolved.
Show resolved Hide resolved
TargetPart('tests', app=TizenApp.TESTS).OnlyIfRe("-qemu"),
arkq marked this conversation as resolved.
Show resolved Hide resolved
])

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

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')
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
QEMU = Board('arm')


class TizenApp(Enum):
Expand All @@ -49,11 +56,20 @@ 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 is_test(self):
arkq marked this conversation as resolved.
Show resolved Hide resolved
"""If True, this app is a test driver."""
return isinstance(self.value, TestDriver)

@property
def package_name(self):
return self.manifest.get('package')
Expand All @@ -66,11 +82,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
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 @@ -17,6 +17,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,qemu}-{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,ota-requestor,thermostat}
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" ]
}
61 changes: 61 additions & 0 deletions src/test_driver/tizen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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
```

### Build application variants that you would like to test

```sh
# Build chip-tool without BLE support (BLE is not supported on QEMU)
./scripts/build/build_examples.py --target tizen-arm-chip-tool-no-ble build
# Build lighting-app without BLE and WiFi support
./scripts/build/build_examples.py --target tizen-arm-light-no-ble-no-wifi \
--enable-flashbundle build
```

### Generate and run test target

```sh
# Generate test target
gn gen --check --fail-on-unused-args -root="$PWD/src/test_driver/tizen" --args="
target_os=\"tizen\" target_cpu=\"arm\"
tizen_chip_tool=\"$PWD/out/tizen-arm-chip-tool-no-ble/chip-tool\"
tizen_lighting_app_tpk=\"$PWD/out/tizen-arm-light-no-ble-no-wifi/package/out/org.tizen.matter.example.lighting-1.0.0.tpk\"
" out/tizen-check
# Run Time QEMU-based tests
ninja -C out/tizen-check check
arkq marked this conversation as resolved.
Show resolved Hide resolved
```
54 changes: 54 additions & 0 deletions src/test_driver/tizen/assets.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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")
import("//build_overrides/chip.gni")

import("${build_root}/config/compiler/compiler.gni")
import("${chip_root}/src/ble/ble.gni")

# Declare arguments used in the build_example.py script (but not declared by
# any of the imported files above), so we can reuse them for generaing default
# values for the tests assets.
declare_args() {
chip_enable_wifi = true
arkq marked this conversation as resolved.
Show resolved Hide resolved
is_ubsan = false
}

# Create variant suffix string, as used by the build_examples.py script, based
# on the build configuration.
declare_args() {
variant = ""
arkq marked this conversation as resolved.
Show resolved Hide resolved
if (!chip_config_network_layer_ble) {
variant += "-no-ble"
}
if (!chip_enable_wifi) {
variant += "-no-wifi"
}
if (is_asan) {
variant += "-asan"
}
if (is_ubsan) {
variant += "-ubsan"
}
}

# Define default values for the test assets, which are used by the tests. These
# values mirrors the ones used by the build_examples.py script.
declare_args() {
tizen_chip_tool =
rebase_path("${chip_root}/out/tizen-arm-chip-tool${variant}/chip-tool")
tizen_lighting_app_tpk = rebase_path(
"${chip_root}/out/tizen-arm-light${variant}/package/out/org.tizen.matter.example.lighting-1.0.0.tpk")
}
1 change: 1 addition & 0 deletions src/test_driver/tizen/build_overrides
Loading