Skip to content

Commit

Permalink
Make mobile device test also be able to trace. Mobile device test see…
Browse files Browse the repository at this point in the history
…ms super slow
  • Loading branch information
andreilitvin committed Jul 21, 2023
1 parent 5eb3b93 commit 5fab229
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ jobs:
- name: Run Tests
run: |
mkdir -p out/trace_data
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--log-level INFO -t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"'
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script-args "--log-level INFO -t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RR_1_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DeviceBasicComposition.py" --script-args "--storage-path admin_storage.json --manual-code 10054912339 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_SC_3_6.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
Expand Down
8 changes: 6 additions & 2 deletions src/controller/python/chip/native/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,9 @@ def Init(bluetoothAdapter: int = None):
_GetLibraryHandle(False).pychip_CommonStackInit(ctypes.c_char_p(params))


def GetLibraryHandle():
return _GetLibraryHandle(True)
class HandleFlags(enum.Flag):
REQUIRE_INITIALIZATION = enum.auto()


def GetLibraryHandle(flags = HandleFlags.REQUIRE_INITIALIZATION):
return _GetLibraryHandle(HandleFlags.REQUIRE_INITIALIZATION in flags)
4 changes: 3 additions & 1 deletion src/controller/python/chip/tracing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def _GetTracingLibraryHandle() -> ctypes.CDLL:
native methods.
"""

handle = chip.native.GetLibraryHandle()
# Getting a handle without requiring init, as tracing methods
# do not require chip stack startup
handle = chip.native.GetLibraryHandle(chip.native.HandleFlags(0))

# Uses one of the type decorators as an indicator for everything being
# initialized.
Expand Down
15 changes: 12 additions & 3 deletions src/controller/python/test/test_scripts/mobile-device-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from base import BaseTestHelper, FailIfNot, SetTestSet, TestFail, TestTimeout, logger
from cluster_objects import ClusterObjectTests
from network_commissioning import NetworkCommissioningTests
from chip.tracing import TracingContext

# The thread network dataset tlv for testing, splitted into T-L-V.

Expand Down Expand Up @@ -246,8 +247,12 @@ def do_tests(controller_nodeid, device_nodeid, address, timeout, discriminator,
default='',
type=str,
help="Path that contains valid and trusted PAA Root Certificates.")
@click.option('--trace-to',
multiple=True,
default=[],
help="Trace location")
def run(controller_nodeid, device_nodeid, address, timeout, discriminator, setup_pin, enable_test, disable_test, log_level,
log_format, print_test_list, paa_trust_store_path):
log_format, print_test_list, paa_trust_store_path, trace_to):
coloredlogs.install(level=log_level, fmt=log_format, logger=logger)

if print_test_list:
Expand All @@ -267,8 +272,12 @@ def run(controller_nodeid, device_nodeid, address, timeout, discriminator, setup
logger.info(f"\tEnabled Tests: {enable_test}")
logger.info(f"\tDisabled Tests: {disable_test}")
SetTestSet(enable_test, disable_test)
do_tests(controller_nodeid, device_nodeid, address, timeout,
discriminator, setup_pin, paa_trust_store_path)
with TracingContext() as tracing_ctx:
for destination in trace_to:
tracing_ctx.StartFromString(destination)

do_tests(controller_nodeid, device_nodeid, address, timeout,
discriminator, setup_pin, paa_trust_store_path)


if __name__ == "__main__":
Expand Down

0 comments on commit 5fab229

Please sign in to comment.