diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 20a573e3235ffa..afc70e47048265 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -27,7 +27,8 @@ env: CHIP_NO_LOG_TIMESTAMPS: true jobs: - qemu: + + qemu-esp32: name: ESP32 timeout-minutes: 85 @@ -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 + " diff --git a/BUILD.gn b/BUILD.gn index 96ab7addb4a9ce..d9c68de527c0aa 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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)" ] @@ -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_" + diff --git a/build/config/tizen/config.gni b/build/config/tizen/config.gni index 585a889ccfbffd..06a03d59b86881 100644 --- a/build/config/tizen/config.gni +++ b/build/config/tizen/config.gni @@ -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") } diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 3b6e6b03805934..97dc96bf08fc5f 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -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 @@ -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) diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py index 71ae18e9f1cce6..a8f9b3d497b5fb 100644 --- a/scripts/build/builders/tizen.py +++ b/scripts/build/builders/tizen.py @@ -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): @@ -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') @@ -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, @@ -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), } diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index ae69c14420f112..e0d4909974106e 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -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} diff --git a/src/test_driver/tizen/.gn b/src/test_driver/tizen/.gn new file mode 100644 index 00000000000000..fa6b2fc9621e28 --- /dev/null +++ b/src/test_driver/tizen/.gn @@ -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" +} diff --git a/src/test_driver/tizen/BUILD.gn b/src/test_driver/tizen/BUILD.gn new file mode 100644 index 00000000000000..9d7c863d3ce7ca --- /dev/null +++ b/src/test_driver/tizen/BUILD.gn @@ -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" ] +} diff --git a/src/test_driver/tizen/README.md b/src/test_driver/tizen/README.md new file mode 100644 index 00000000000000..b4e8ed39ad5312 --- /dev/null +++ b/src/test_driver/tizen/README.md @@ -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 +``` diff --git a/src/test_driver/tizen/build_overrides b/src/test_driver/tizen/build_overrides new file mode 120000 index 00000000000000..f2758328a72777 --- /dev/null +++ b/src/test_driver/tizen/build_overrides @@ -0,0 +1 @@ +../../../examples/build_overrides \ No newline at end of file diff --git a/src/test_driver/tizen/integration_tests/lighting-app/BUILD.gn b/src/test_driver/tizen/integration_tests/lighting-app/BUILD.gn new file mode 100644 index 00000000000000..36fb2c340a23ec --- /dev/null +++ b/src/test_driver/tizen/integration_tests/lighting-app/BUILD.gn @@ -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]) +} diff --git a/src/test_driver/tizen/integration_tests/lighting-app/runner.sh b/src/test_driver/tizen/integration_tests/lighting-app/runner.sh new file mode 100755 index 00000000000000..c214123e5c8c92 --- /dev/null +++ b/src/test_driver/tizen/integration_tests/lighting-app/runner.sh @@ -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 diff --git a/src/test_driver/tizen/third_party/connectedhomeip b/src/test_driver/tizen/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/src/test_driver/tizen/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file diff --git a/third_party/tizen/tizen_sdk.gni b/third_party/tizen/tizen_sdk.gni index 0ac79b3fb5ba3a..32bb5539a483f6 100644 --- a/third_party/tizen/tizen_sdk.gni +++ b/third_party/tizen/tizen_sdk.gni @@ -110,20 +110,22 @@ template("tizen_sdk_package") { "It is required to specify a `sign_security_profile` which " + "should be used for signing TPK package.") - # Output directory where packaging will occur. We need a separate directory - # for this, because Tizen Studio CLI scans "res" (resources), "shared" and - # "lib" directories for items to pack. In our case it could include in the - # TPK package libraries available in ${root_out_dir}/lib directory. - tizen_package_dir = "${root_build_dir}/package" - tizen_package_out_dir = "${tizen_package_dir}/out" - # Extract data from Tizen XML manifest. manifest = exec_script(tizen_manifest_parser, [ rebase_path(invoker.manifest, root_build_dir) ], "json") manifest_package = manifest["package"] + manifest_package_name = manifest_package["name"] + manifest_package_version = manifest_package["version"] manifest_apps = manifest["apps"] + # Output directory where packaging will occur. We need a separate directory + # for this, because Tizen Studio CLI scans "res" (resources), "shared" and + # "lib" directories for items to pack. In our case it could include in the + # TPK package libraries available in ${root_out_dir}/lib directory. + tizen_package_dir = "${root_build_dir}/${manifest_package_name}" + tizen_package_out_dir = "${tizen_package_dir}/out" + # Copy Tizen manifest from the source directory. copy("${target_name}:manifest") { sources = [ invoker.manifest ] @@ -146,10 +148,10 @@ template("tizen_sdk_package") { } } - tpk = manifest_package["name"] + "-" + manifest_package["version"] + ".tpk" + tpk = "${manifest_package_name}-${manifest_package_version}.tpk" tizen_sdk(target_name) { deps = invoker.deps + dependencies - outputs = [ "${tizen_package_out_dir}/" + tpk ] + outputs = [ "${tizen_package_out_dir}/${tpk}" ] project_build_dir = tizen_package_dir args = [ "package", @@ -225,7 +227,7 @@ template("tizen_qemu_run") { "--image-iso=" + invoker.iso_image, "--output=" + rebase_path(output_log_file), ] - if (defined(invoker.virtio_net)) { + if (defined(invoker.virtio_net) && invoker.virtio_net) { args += [ "--virtio-net" ] }