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

Add test for sending a command to an unsupported endpoint #8073

Conversation

bzbarsky-apple
Copy link
Contributor

Problem

We have no test coverage for sending a command to an unsupported endpoint.

Change overview

Add a test.

Testing

Ran Darwin tests and test_suites.sh manually, verified the test fails. And will keep failing until #8054 merges.

runner->NextTest();
}

static void OnTestSendClusterTestClusterCommandTest_101_SuccessResponse(void * context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this pattern repeats for other test cases as well. Could this callback functions be common for all of them? Is there a reason we can't have a common runner->mIsFailureExpected member?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. This is auto-generated code; I'd have to go look at the template to see whether we could do that and whether the resulting template would be more complicated or not as a result....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template has various conditions in it; depending on the exact way the test is configured in the yaml you get different signatures. So commoning up the functions is not really very simple.

Similarly, mIsFailureExpected is on a per-test basis, and the runner is a single runner across a suite of tests, so we can't just have one member on it to track the per-test state.


// Test Send Test Command to unsupported endpoint
typedef void (*SuccessCallback_101)(void * context);
chip::Callback::Callback<SuccessCallback_101> * mOnSuccessCallback_101 = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this not say:

chip::Callback::Callback<SuccessCallback_101> mOnSuccessCallback_101 { &OnTestSendClusterTestClusterCommandTest_101_FailureResponse, this };

And if it needs to be nullable for some reason (I'm not sure why..) we could use Optional<> or std::unique_ptr.

I think this is worse than all of 3 other possibilities.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this not say:

I'm happy to look into this, but this is auto-generated code (see the two separate commits which break out the manual changes and the generated changes) so the fix would be pretty orthogonal and would affect all of the test commands, presumably.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is no reason this has to be nullable. That said, right now we allocate the callback for a test right before we start that test, and deallocate it when the test finishes. If we just made them non-nullable members we'd have them all allocated all the time, effectively. That's probably not a problem for the sorts of devices that run chip-tool....

@@ -7829,6 +7832,75 @@ class TestCluster : public TestCommand

runner->NextTest();
}

// Test Send Test Command to unsupported endpoint
typedef void (*SuccessCallback_101)(void * context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Prefer usingas it is more readable than typedef

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this is generated code. Happy to look into this in a followup, but don't think we should be including changes to the generator templates in this PR.

…ist.

The test script change is to allow it to detect crashes in the server
app as failures (due to the server app not being there to be killed).
@bzbarsky-apple bzbarsky-apple force-pushed the add-test-for-unknown-endpoint branch from 4f4a5bf to 32b4002 Compare July 7, 2021 17:23
@bzbarsky-apple bzbarsky-apple merged commit 83a2dd0 into project-chip:master Jul 8, 2021
@bzbarsky-apple bzbarsky-apple deleted the add-test-for-unknown-endpoint branch July 8, 2021 17:14
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
…ip#8073)

* Add test for trying to send a command to an endpoint that does not exist.

The test script change is to allow it to detect crashes in the server
app as failures (due to the server app not being there to be killed).

* Regenerate generated files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants