From 23779068709a98f99f739b06dc315f52594cc2f9 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 1 Dec 2021 21:55:31 -0500 Subject: [PATCH] Use a random discriminator for test runs. (#12449) If we're getting cross-talk, maybe this will help. --- .github/workflows/tests.yaml | 4 ++-- examples/platform/linux/Options.cpp | 15 +++++++++++++-- scripts/tests/chiptest/test_definition.py | 9 ++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e0ba2a9a6aebb1..0c8d4ecf3f5b76 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -90,7 +90,7 @@ jobs: "./scripts/tests/run_test_suite.py \ --chip-tool ./out/debug/standalone/chip-tool \ run \ - --iterations 2 \ + --iterations 1 \ --all-clusters-app ./out/debug/standalone/chip-all-clusters-app \ --tv-app ./out/debug/standalone/chip-tv-app \ " @@ -180,7 +180,7 @@ jobs: --chip-tool ./out/debug/standalone/chip-tool \ --target-skip-glob 'TV_*' \ run \ - --iterations 2 \ + --iterations 1 \ --all-clusters-app ./out/debug/standalone/chip-all-clusters-app \ --tv-app ./out/debug/standalone/chip-tv-app \ " diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index b68e34dd28a1d5..b637a264253662 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -174,9 +174,20 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, LinuxDeviceOptions::GetInstance().payload.rendezvousInformation.SetRaw(static_cast(atoi(aValue))); break; - case kDeviceOption_Discriminator: - LinuxDeviceOptions::GetInstance().payload.discriminator = static_cast(atoi(aValue)); + case kDeviceOption_Discriminator: { + uint16_t value = static_cast(atoi(aValue)); + if (value >= 4096) + { + PrintArgError("%s: invalid value specified for discriminator: %s\n", aProgram, aValue); + retval = false; + } + else + { + LinuxDeviceOptions::GetInstance().payload.discriminator = value; + DeviceLayer::ConfigurationMgr().StoreSetupDiscriminator(value); + } break; + } case kDeviceOption_Passcode: LinuxDeviceOptions::GetInstance().payload.setUpPINCode = static_cast(atoi(aValue)); diff --git a/scripts/tests/chiptest/test_definition.py b/scripts/tests/chiptest/test_definition.py index 9eea86966a6e01..c5c80d171e09e7 100644 --- a/scripts/tests/chiptest/test_definition.py +++ b/scripts/tests/chiptest/test_definition.py @@ -22,6 +22,7 @@ from enum import Enum, auto from dataclasses import dataclass +from random import randrange TEST_NODE_ID = '0x12344321' @@ -101,9 +102,11 @@ def Run(self, runner, paths: ApplicationPaths): if os.path.exists('/tmp/chip_tool_config.ini'): os.unlink('/tmp/chip_tool_config.ini') - logging.debug('Executing application under test.') + discriminator = str(randrange(1, 4096)) + logging.debug( + 'Executing application under test with discriminator %s.' % discriminator) app_process, outpipe, errpipe = runner.RunSubprocess( - app_cmd, name='APP ', wait=False) + app_cmd + ['--discriminator', discriminator], name='APP ', wait=False) logging.debug('Waiting for server to listen.') start_time = time.time() @@ -117,7 +120,7 @@ def Run(self, runner, paths: ApplicationPaths): "Server Listening") logging.debug('Server is listening. Can proceed.') - runner.RunSubprocess(tool_cmd + ['pairing', 'qrcode', TEST_NODE_ID, 'MT:D8XA0CQM00KA0648G00'], + runner.RunSubprocess(tool_cmd + ['pairing', 'onnetwork-long', TEST_NODE_ID, '20202021', discriminator], name='PAIR', dependencies=[app_process]) runner.RunSubprocess(tool_cmd + ['tests', self.run_name, TEST_NODE_ID],