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

Use CMake and separate runner for QEMU tests for esp32 #13095

Merged
merged 22 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
12fd15c
Start adding a tests target to qemu
andy31415 Dec 16, 2021
2efbcb5
Fix extra compatibility test
andy31415 Dec 16, 2021
b08f5a7
Prepare qemu builds for the test driver using cmake
andy31415 Dec 16, 2021
0bd82d9
Ensure sdkconfig can be ignored for esp32 test driver: this file is r…
andy31415 Dec 16, 2021
fc50e7c
In theory we compile and link at least one test
andy31415 Dec 16, 2021
2e85bbc
Tests now build for a few sub-items
andy31415 Dec 16, 2021
c3f506d
Tests now build for a few sub-items
andy31415 Dec 16, 2021
d6927f7
move the cmake logic for esp tests into a separate cmakefile
andy31415 Dec 16, 2021
5993243
bin is also built by the cmake system now
andy31415 Dec 16, 2021
c96c9af
Start being able to run test - for now remove the qemu sh scripts
andy31415 Dec 16, 2021
b831d13
Remove obsolete makefiles
andy31415 Dec 16, 2021
a752e5b
Switch unit test execution to a python script
andy31415 Dec 16, 2021
e70d8a4
Some comments and cleanup
andy31415 Dec 16, 2021
c7f36ef
Restyle files
andy31415 Dec 16, 2021
1cb85c1
Upate build rules and logic - we detect failing and passing tests now
andy31415 Dec 16, 2021
c616251
Add a verbose test argument
andy31415 Dec 16, 2021
557a55a
Restyle files
andy31415 Dec 16, 2021
928fb44
Fix flashbundle logic
andy31415 Dec 16, 2021
8d176aa
Correct placement of verbose argument
andy31415 Dec 16, 2021
8e05421
Correct placement of verbose argument
andy31415 Dec 16, 2021
3c9fc03
Run test runner with python3 since that is available (just python wil…
andy31415 Dec 16, 2021
5ec48c6
Update build example py unit tests
andy31415 Dec 16, 2021
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
20 changes: 14 additions & 6 deletions .github/workflows/qemu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,20 @@ jobs:
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log
- name: Build example All Clusters App
timeout-minutes: 25
run: scripts/examples/esp_example.sh all-clusters-app
- name: Build ESP32 QEMU and Run Tests
timeout-minutes: 35
run: scripts/tests/esp32_qemu_tests.sh /tmp/test_logs
- name: Build ESP32 QEMU test images
timeout-minutes: 20
run: |
scripts/run_in_build_env.sh " \
./scripts/build/build_examples.py \
--target esp32-qemu-tests \
build \
"
- name: Run all tests
timeout-minutes: 30
run: |
src/test_driver/esp32/run_qemu_image.py \
--verbose \
--file-image-list ./out/esp32-qemu-tests/test_images.txt
- name: Uploading Logs
uses: actions/upload-artifact@v2
if: ${{ !env.ACT }}
Expand Down
2 changes: 2 additions & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def Esp32Targets():
yield devkitc.Extend('bridge', app=Esp32App.BRIDGE)
yield devkitc.Extend('temperature-measurement', app=Esp32App.TEMPERATURE_MEASUREMENT)

yield esp32_target.Extend('qemu-tests', board=Esp32Board.QEMU, app=Esp32App.TESTS)


def Efr32Targets():
efr_target = Target('efr32', Efr32Builder)
Expand Down
57 changes: 48 additions & 9 deletions scripts/build/builders/esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Esp32Board(Enum):
DevKitC = auto()
M5Stack = auto()
C3DevKit = auto()
QEMU = auto()


class Esp32App(Enum):
Expand All @@ -33,19 +34,22 @@ class Esp32App(Enum):
SHELL = auto()
BRIDGE = auto()
TEMPERATURE_MEASUREMENT = auto()
TESTS = auto()

@property
def ExampleName(self):
def ExamplePath(self):
if self == Esp32App.ALL_CLUSTERS:
return 'all-clusters-app'
return 'examples/all-clusters-app'
elif self == Esp32App.LOCK:
return 'lock-app'
return 'examples/lock-app'
elif self == Esp32App.SHELL:
return 'shell'
return 'examples/shell'
elif self == Esp32App.BRIDGE:
return 'bridge-app'
return 'examples/bridge-app'
elif self == Esp32App.TEMPERATURE_MEASUREMENT:
return 'temperature-measurement-app'
return 'examples/temperature-measurement-app'
elif self == Esp32App.TESTS:
return 'src/test_driver'
else:
raise Exception('Unknown app type: %r' % self)

Expand All @@ -61,15 +65,33 @@ def AppNamePrefix(self):
return 'chip-bridge-app'
elif self == Esp32App.TEMPERATURE_MEASUREMENT:
return 'chip-temperature-measurement-app'
elif self == Esp32App.TESTS:
return None
else:
raise Exception('Unknown app type: %r' % self)

@property
def FlashBundleName(self):
if not self.AppNamePrefix:
return None

return self.AppNamePrefix + '.flashbundle.txt'

def IsCompatible(self, board: Esp32Board):
if board == Esp32Board.QEMU:
return self == Esp32App.TESTS
elif board == Esp32Board.M5Stack:
return self == Esp32App.ALL_CLUSTERS
elif board == Esp32Board.C3DevKit:
return self == Esp32App.ALL_CLUSTERS
else:
return (board == Esp32Board.DevKitC) and (self != Esp32App.TESTS)


def DefaultsFileName(board: Esp32Board, app: Esp32App, enable_rpcs: bool):
if app != Esp32App.ALL_CLUSTERS:
if app == Esp32App.TESTS:
return 'sdkconfig_qemu.defaults'
elif app != Esp32App.ALL_CLUSTERS:
return 'sdkconfig.defaults'

rpc = "_rpc" if enable_rpcs else ""
Expand Down Expand Up @@ -99,6 +121,10 @@ def __init__(self,
self.enable_rpcs = enable_rpcs
self.enable_ipv4 = enable_ipv4

if not app.IsCompatible(board):
raise Exception(
"Incompatible app/board combination: %r and %r", app, board)

def _IdfEnvExecute(self, cmd, title=None):
# Run activate.sh after export.sh to ensure using the chip environment.
self._Execute(
Expand All @@ -107,7 +133,7 @@ def _IdfEnvExecute(self, cmd, title=None):

@property
def ExamplePath(self):
return os.path.join('examples', self.app.ExampleName, 'esp32')
return os.path.join(self.app.ExamplePath, 'esp32')

def generate(self):
if os.path.exists(os.path.join(self.output_dir, 'build.ninja')):
Expand Down Expand Up @@ -162,6 +188,16 @@ def _build(self):
self._IdfEnvExecute(cmd, title='Building ' + self.identifier)

def build_outputs(self):
if self.app == Esp32App.TESTS:
# Include the runnable image names as artifacts
result = dict()
with open(os.path.join(self.output_dir, 'test_images.txt'), 'rt') as f:
for name in f.readlines():
name = name.strip()
result[name] = os.path.join(self.output_dir, name)

return result

return {
self.app.AppNamePrefix + '.elf':
os.path.join(self.output_dir, self.app.AppNamePrefix + '.elf'),
Expand All @@ -170,7 +206,10 @@ def build_outputs(self):
}

def flashbundle(self):
with open(os.path.join(self.output_dir, self.app.FlashBundleName()), 'r') as fp:
if not self.app.FlashBundleName:
return {}

with open(os.path.join(self.output_dir, self.app.FlashBundleName), 'r') as fp:
return {
l.strip(): os.path.join(self.output_dir, l.strip()) for l in fp.readlines() if l.strip()
}
1 change: 1 addition & 0 deletions scripts/build/testdata/all_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ esp32-m5stack-all-clusters
esp32-m5stack-all-clusters-ipv6only
esp32-m5stack-all-clusters-rpc
esp32-m5stack-all-clusters-rpc-ipv6only
esp32-qemu-tests
infineon-p6-all-clusters
infineon-p6-light
infineon-p6-lock
Expand Down
18 changes: 18 additions & 0 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,17 @@ bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh;
export SDKCONFIG_DEFAULTS={out}/esp32-m5stack-all-clusters-rpc-ipv6only/sdkconfig.defaults
idf.py -C examples/all-clusters-app/esp32 -B {out}/esp32-m5stack-all-clusters-rpc-ipv6only reconfigure'

# Generating esp32-qemu-tests
mkdir -p {out}/esp32-qemu-tests

cp src/test_driver/esp32/sdkconfig_qemu.defaults {out}/esp32-qemu-tests/sdkconfig.defaults

rm -f src/test_driver/esp32/sdkconfig

bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh;
export SDKCONFIG_DEFAULTS={out}/esp32-qemu-tests/sdkconfig.defaults
idf.py -C src/test_driver/esp32 -B {out}/esp32-qemu-tests reconfigure'

# Generating infineon-p6-all-clusters
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/p6 '--args=p6_board="CY8CKIT-062S2-43012"' {out}/infineon-p6-all-clusters

Expand Down Expand Up @@ -1002,6 +1013,13 @@ bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh;
export SDKCONFIG_DEFAULTS={out}/esp32-m5stack-all-clusters-rpc-ipv6only/sdkconfig.defaults
idf.py -C examples/all-clusters-app/esp32 -B {out}/esp32-m5stack-all-clusters-rpc-ipv6only build'

rm -f src/test_driver/esp32/sdkconfig

# Building esp32-qemu-tests
bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh;
export SDKCONFIG_DEFAULTS={out}/esp32-qemu-tests/sdkconfig.defaults
idf.py -C src/test_driver/esp32 -B {out}/esp32-qemu-tests build'

# Building infineon-p6-all-clusters
ninja -C {out}/infineon-p6-all-clusters

Expand Down
1 change: 1 addition & 0 deletions scripts/build/testdata/glob_star_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ esp32-m5stack-all-clusters
esp32-m5stack-all-clusters-ipv6only
esp32-m5stack-all-clusters-rpc
esp32-m5stack-all-clusters-rpc-ipv6only
esp32-qemu-tests
infineon-p6-all-clusters
infineon-p6-light
infineon-p6-lock
Expand Down
91 changes: 0 additions & 91 deletions scripts/tests/esp32_qemu_tests.sh

This file was deleted.

74 changes: 0 additions & 74 deletions scripts/tools/esp32_qemu_run.sh

This file was deleted.

Loading