Skip to content

Commit

Permalink
Dmalloc variant in build_example.py tests target (#22171)
Browse files Browse the repository at this point in the history
* Add dmalloc support to build examples test run

* Remove extra target for now - no need for both dmalloc and asan

* Move things a bit to be easier to follow

* Restyle
  • Loading branch information
andy31415 authored Aug 29, 2022
1 parent c60a0aa commit d4bea71
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 50 deletions.
2 changes: 2 additions & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ def HostTargets():
yield target_native.Extend('tests-boringssl', app=HostApp.TESTS, crypto_library=HostCryptoLibrary.BORINGSSL).GlobBlacklist("Non-default test")
yield target_native.Extend('tests-coverage', app=HostApp.TESTS, use_coverage=True).GlobBlacklist("Non-default test")
yield target_native.Extend('tests-clang', app=HostApp.TESTS, use_clang=True).GlobBlacklist("Non-default test")
yield target_native.Extend('tests-clang-asan', app=HostApp.TESTS, use_clang=True, use_asan=True).GlobBlacklist("Non-default test")
yield target_native.Extend('tests-dmalloc', app=HostApp.TESTS, use_dmalloc=True).GlobBlacklist("Non-default test")

test_target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder)
yield test_target.Extend(HostBoard.FAKE.BoardName() + '-tests', board=HostBoard.FAKE, app=HostApp.TESTS)
Expand Down
11 changes: 11 additions & 0 deletions scripts/build/builders/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ def _build(self):
if self.build_command:
cmd.append(self.build_command)

extra_env = self.GnBuildEnv()
if extra_env:
# convert the command into a bash command that includes
# setting environment variables
cmd = [
'bash', '-c', '\n' + ' '.join(
['%s="%s" \\\n' % (key, value) for key, value in extra_env.items()] +
[shlex.join(cmd)]
)
]

self._Execute(cmd, title='Building ' + self.identifier)

self.PostBuildCommand()
30 changes: 17 additions & 13 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,19 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
separate_event_loop=True, use_libfuzzer=False, use_clang=False,
interactive_mode=True, extra_tests=False,
use_platform_mdns=False, enable_rpcs=False,
use_coverage=False, crypto_library: HostCryptoLibrary = None):
use_coverage=False, use_dmalloc=False,
crypto_library: HostCryptoLibrary = None):
super(HostBuilder, self).__init__(
root=os.path.join(root, 'examples', app.ExamplePath()),
runner=runner)

self.app = app
self.board = board
self.extra_gn_options = []
self.build_env = {}

if board == HostBoard.ARM64:
self.build_env['PKG_CONFIG_PATH'] = os.path.join(self.SysRootPath('SYSROOT_AARCH64'), 'lib/aarch64-linux-gnu/pkgconfig')

if enable_rpcs:
self.extra_gn_options.append('import("//with_pw_rpc.gni")')
Expand All @@ -244,6 +249,16 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
if use_asan:
self.extra_gn_options.append('is_asan=true')

if use_dmalloc:
self.extra_gn_options.append('chip_config_memory_debug_checks=true')
self.extra_gn_options.append('chip_config_memory_debug_dmalloc=true')

# this is from `dmalloc -b -l DMALLOC_LOG -i 1 high`
self.build_env['DMALLOC_OPTIONS'] = 'debug=0x4f4ed03,inter=1,log=DMALLOC_LOG'

# glib interop with dmalloc
self.build_env['G_SLICE'] = 'always-malloc'

if not separate_event_loop:
self.extra_gn_options.append('config_use_separate_eventloop=false')

Expand Down Expand Up @@ -327,18 +342,7 @@ def GnBuildArgs(self):
raise Exception('Unknown host board type: %r' % self)

def GnBuildEnv(self):
if self.board == HostBoard.NATIVE:
return None
elif self.board == HostBoard.FAKE:
return None
elif self.board == HostBoard.ARM64:
return {
'PKG_CONFIG_PATH': os.path.join(
self.SysRootPath('SYSROOT_AARCH64'),
'lib/aarch64-linux-gnu/pkgconfig'),
}
else:
raise Exception('Unknown host board type: %r' % self)
return self.build_env

def SysRootPath(self, name):
if name not in os.environ:
Expand Down
148 changes: 111 additions & 37 deletions scripts/build/testdata/build_linux_on_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,115 +322,189 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/tv-casting-app/linux --args=chip_inet_config_enable_ipv4=false {out}/linux-x64-tv-casting-app-ipv6only

# Building linux-arm64-clang-all-clusters
ninja -C {out}/linux-arm64-clang-all-clusters
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-all-clusters'

# Building linux-arm64-clang-all-clusters-app-nodeps
ninja -C {out}/linux-arm64-clang-all-clusters-app-nodeps
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-all-clusters-app-nodeps'

# Building linux-arm64-clang-all-clusters-app-nodeps-ipv6only
ninja -C {out}/linux-arm64-clang-all-clusters-app-nodeps-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-all-clusters-app-nodeps-ipv6only'

# Building linux-arm64-clang-all-clusters-ipv6only
ninja -C {out}/linux-arm64-clang-all-clusters-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-all-clusters-ipv6only'

# Building linux-arm64-clang-all-clusters-minimal
ninja -C {out}/linux-arm64-clang-all-clusters-minimal
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-all-clusters-minimal'

# Building linux-arm64-clang-all-clusters-minimal-ipv6only
ninja -C {out}/linux-arm64-clang-all-clusters-minimal-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-all-clusters-minimal-ipv6only'

# Building linux-arm64-clang-bridge
ninja -C {out}/linux-arm64-clang-bridge
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-bridge'

# Building linux-arm64-clang-bridge-ipv6only
ninja -C {out}/linux-arm64-clang-bridge-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-bridge-ipv6only'

# Building linux-arm64-clang-chip-tool
ninja -C {out}/linux-arm64-clang-chip-tool
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-chip-tool'

# Building linux-arm64-clang-chip-tool-ipv6only
ninja -C {out}/linux-arm64-clang-chip-tool-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-chip-tool-ipv6only'

# Building linux-arm64-clang-chip-tool-nodeps
ninja -C {out}/linux-arm64-clang-chip-tool-nodeps
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-chip-tool-nodeps'

# Building linux-arm64-clang-chip-tool-nodeps-ipv6only
ninja -C {out}/linux-arm64-clang-chip-tool-nodeps-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-chip-tool-nodeps-ipv6only'

# Building linux-arm64-clang-light
ninja -C {out}/linux-arm64-clang-light
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-light'

# Building linux-arm64-clang-light-ipv6only
ninja -C {out}/linux-arm64-clang-light-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-light-ipv6only'

# Building linux-arm64-clang-light-rpc
ninja -C {out}/linux-arm64-clang-light-rpc
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-light-rpc'

# Building linux-arm64-clang-light-rpc-ipv6only
ninja -C {out}/linux-arm64-clang-light-rpc-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-light-rpc-ipv6only'

# Building linux-arm64-clang-lock
ninja -C {out}/linux-arm64-clang-lock
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-lock'

# Building linux-arm64-clang-lock-ipv6only
ninja -C {out}/linux-arm64-clang-lock-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-lock-ipv6only'

# Building linux-arm64-clang-minmdns
ninja -C {out}/linux-arm64-clang-minmdns
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-minmdns'

# Building linux-arm64-clang-minmdns-ipv6only
ninja -C {out}/linux-arm64-clang-minmdns-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-minmdns-ipv6only'

# Building linux-arm64-clang-ota-provider
ninja -C {out}/linux-arm64-clang-ota-provider
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-ota-provider'

# Building linux-arm64-clang-ota-provider-ipv6only
ninja -C {out}/linux-arm64-clang-ota-provider-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-ota-provider-ipv6only'

# Building linux-arm64-clang-ota-provider-nodeps
ninja -C {out}/linux-arm64-clang-ota-provider-nodeps
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-ota-provider-nodeps'

# Building linux-arm64-clang-ota-provider-nodeps-ipv6only
ninja -C {out}/linux-arm64-clang-ota-provider-nodeps-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-ota-provider-nodeps-ipv6only'

# Building linux-arm64-clang-ota-requestor
ninja -C {out}/linux-arm64-clang-ota-requestor
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-ota-requestor'

# Building linux-arm64-clang-ota-requestor-ipv6only
ninja -C {out}/linux-arm64-clang-ota-requestor-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-ota-requestor-ipv6only'

# Building linux-arm64-clang-ota-requestor-nodeps
ninja -C {out}/linux-arm64-clang-ota-requestor-nodeps
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-ota-requestor-nodeps'

# Building linux-arm64-clang-ota-requestor-nodeps-ipv6only
ninja -C {out}/linux-arm64-clang-ota-requestor-nodeps-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-ota-requestor-nodeps-ipv6only'

# Building linux-arm64-clang-python-bindings
ninja -C {out}/linux-arm64-clang-python-bindings chip-repl
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-python-bindings chip-repl'

# Building linux-arm64-clang-shell
ninja -C {out}/linux-arm64-clang-shell
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-shell'

# Building linux-arm64-clang-shell-ipv6only
ninja -C {out}/linux-arm64-clang-shell-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-shell-ipv6only'

# Building linux-arm64-clang-thermostat
ninja -C {out}/linux-arm64-clang-thermostat
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-thermostat'

# Building linux-arm64-clang-thermostat-ipv6only
ninja -C {out}/linux-arm64-clang-thermostat-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-thermostat-ipv6only'

# Building linux-arm64-clang-tv-app
ninja -C {out}/linux-arm64-clang-tv-app
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-tv-app'

# Building linux-arm64-clang-tv-app-ipv6only
ninja -C {out}/linux-arm64-clang-tv-app-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-tv-app-ipv6only'

# Building linux-arm64-clang-tv-casting-app
ninja -C {out}/linux-arm64-clang-tv-casting-app
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-tv-casting-app'

# Building linux-arm64-clang-tv-casting-app-ipv6only
ninja -C {out}/linux-arm64-clang-tv-casting-app-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
ninja -C {out}/linux-arm64-clang-tv-casting-app-ipv6only'

# Building linux-fake-tests
ninja -C {out}/linux-fake-tests check
Expand Down

0 comments on commit d4bea71

Please sign in to comment.