Skip to content

Commit

Permalink
Forgot a file..
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjerryjohns committed Jun 11, 2021
1 parent 94bb4e3 commit e60afe4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class {{asCamelCased filename false}}: public TestCommand
{
public:
{{asCamelCased filename false}}(): TestCommand("{{filename}}") {}
{{asCamelCased filename false}}(): TestCommand("{{filename}}"), mTestIndex(0) {}

/////////// TestCommand Interface /////////
CHIP_ERROR NextTest() override
Expand All @@ -15,15 +15,18 @@ class {{asCamelCased filename false}}: public TestCommand
SetCommandExitStatus(true);
}

switch (mTestIndex)
// Ensure we increment mTestIndex before we start running the relevant
// command. That way if we lose the timeslice after we send the message
// but before our function call returns, we won't end up with an
// incorrect mTestIndex value observed when we get the response.
switch (mTestIndex++)
{
{{#chip_tests_items}}
case {{index}}:
err = TestSendCluster{{asCamelCased cluster false}}Command{{asCamelCased command false}}_{{index}}();
break;
{{/chip_tests_items}}
}
mTestIndex++;

if (CHIP_NO_ERROR != err)
{
Expand All @@ -36,8 +39,8 @@ class {{asCamelCased filename false}}: public TestCommand


private:
uint16_t mTestIndex = 0;
uint16_t mTestCount = {{totalTests}};
std::atomic_uint16_t mTestIndex;
const uint16_t mTestCount = {{totalTests}};

//
// Tests methods
Expand Down

0 comments on commit e60afe4

Please sign in to comment.