Skip to content

Commit 1539523

Browse files
vivien-applepull[bot]
authored andcommitted
[YAML] Add a mechanism to specify the test timeout for a given YAML file (#11861)
1 parent c08be21 commit 1539523

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

examples/chip-tool/commands/tests/TestCommand.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <type_traits>
3131
#include <zap-generated/tests/CHIPClustersTest.h>
3232

33+
constexpr uint16_t kTimeoutInSeconds = 30;
34+
3335
class TestCommand : public CHIPCommand
3436
{
3537
public:
@@ -39,20 +41,26 @@ class TestCommand : public CHIPCommand
3941
{
4042
AddArgument("node-id", 0, UINT64_MAX, &mNodeId);
4143
AddArgument("delayInMs", 0, UINT64_MAX, &mDelayInMs);
44+
AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
4245
AddArgument("endpoint-id", CHIP_ZCL_ENDPOINT_MIN, CHIP_ZCL_ENDPOINT_MAX, &mEndpointId);
4346
AddArgument("PICS", &mPICSFilePath);
4447
}
4548

4649
/////////// CHIPCommand Interface /////////
4750
CHIP_ERROR RunCommand() override;
48-
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(30); }
51+
chip::System::Clock::Timeout GetWaitDuration() const override
52+
{
53+
return chip::System::Clock::Seconds16(mTimeout.HasValue() ? mTimeout.Value() : kTimeoutInSeconds);
54+
}
4955

5056
virtual void NextTest() = 0;
5157

5258
/////////// GlobalCommands Interface /////////
5359
CHIP_ERROR Wait(chip::System::Clock::Timeout ms);
5460
CHIP_ERROR WaitForMs(uint16_t ms) { return Wait(chip::System::Clock::Milliseconds32(ms)); }
61+
CHIP_ERROR WaitForCommissionee();
5562
CHIP_ERROR Log(const char * message);
63+
CHIP_ERROR Prompt(const char * message);
5664

5765
protected:
5866
ChipDevice * mDevice;
@@ -261,5 +269,6 @@ class TestCommand : public CHIPCommand
261269
chip::Optional<uint64_t> mDelayInMs;
262270
chip::Optional<char *> mPICSFilePath;
263271
chip::Optional<chip::EndpointId> mEndpointId;
272+
chip::Optional<uint16_t> mTimeout;
264273
chip::Optional<std::map<std::string, bool>> PICS;
265274
};

examples/chip-tool/templates/partials/test_cluster.zapt

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class {{filename}}: public TestCommand
4444
}
4545
}
4646

47+
{{#if timeout}}
48+
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.HasValue() : mTimeout.Value() : {{timeout}}); }
49+
{{/if}}
4750

4851
private:
4952
std::atomic_uint16_t mTestIndex;

src/app/zap-templates/common/ClusterTestGeneration.js

+1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ function parse(filename)
327327
});
328328

329329
yaml.filename = filename;
330+
yaml.timeout = yaml.config.timeout;
330331
yaml.totalTests = yaml.tests.length;
331332

332333
return yaml;

0 commit comments

Comments
 (0)