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

[YAML] Add a mechanism to specify the test timeout for a given YAML file #11861

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion examples/chip-tool/commands/tests/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <type_traits>
#include <zap-generated/tests/CHIPClustersTest.h>

constexpr uint16_t kTimeoutInSeconds = 30;

class TestCommand : public CHIPCommand
{
public:
Expand All @@ -38,20 +40,26 @@ class TestCommand : public CHIPCommand
{
AddArgument("node-id", 0, UINT64_MAX, &mNodeId);
AddArgument("delayInMs", 0, UINT64_MAX, &mDelayInMs);
AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
AddArgument("endpoint-id", CHIP_ZCL_ENDPOINT_MIN, CHIP_ZCL_ENDPOINT_MAX, &mEndpointId);
AddArgument("PICS", &mPICSFilePath);
}

/////////// CHIPCommand Interface /////////
CHIP_ERROR RunCommand() override;
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(30); }
chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mTimeout.HasValue() ? mTimeout.Value() : kTimeoutInSeconds);
}

virtual void NextTest() = 0;

/////////// GlobalCommands Interface /////////
CHIP_ERROR Wait(chip::System::Clock::Timeout ms);
CHIP_ERROR WaitForMs(uint16_t ms) { return Wait(chip::System::Clock::Milliseconds32(ms)); }
CHIP_ERROR WaitForCommissionee();
CHIP_ERROR Log(const char * message);
CHIP_ERROR Prompt(const char * message);

protected:
ChipDevice * mDevice;
Expand Down Expand Up @@ -230,5 +238,6 @@ class TestCommand : public CHIPCommand
chip::Optional<uint64_t> mDelayInMs;
chip::Optional<char *> mPICSFilePath;
chip::Optional<chip::EndpointId> mEndpointId;
chip::Optional<uint16_t> mTimeout;
chip::Optional<std::map<std::string, bool>> PICS;
};
3 changes: 3 additions & 0 deletions examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class {{filename}}: public TestCommand
}
}

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

private:
std::atomic_uint16_t mTestIndex;
Expand Down
1 change: 1 addition & 0 deletions src/app/zap-templates/common/ClusterTestGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ function parse(filename)
});

yaml.filename = filename;
yaml.timeout = yaml.config.timeout;
yaml.totalTests = yaml.tests.length;

return yaml;
Expand Down