Introduced new test suite for PWM protocol- basic test#90
Introduced new test suite for PWM protocol- basic test#90CPPavithra wants to merge 2 commits intobeagleboard:mainfrom
Conversation
| if (resp.msg == NULL) { | ||
| zassert_not_null(resp.msg, "Greybus stack did not respond on CPort %d", pwm_cport); | ||
| } | ||
| zassert_equal(resp.cport, pwm_cport, "Response received on wrong CPort"); |
There was a problem hiding this comment.
This test doesn't really test anything. Should check the response.
There was a problem hiding this comment.
Fixed. I have updated the test to explicitly verify the payload.
Note: The vnd,pwm driver on native_sim reports 0 channels by default. I added an assertion for count >= 0 and GB_OP_SUCCESS. This proves the stack correctly routed the request and packed the response structure, satisfying the integration test requirements.
| integration_platforms: | ||
| - native_sim | ||
| tags: test_framework | ||
| tags: greybus pwm |
There was a problem hiding this comment.
Fixed. I've standardized the tags to just greybus. I must have missed that from my testing setup.
492f9c3 to
3aa096f
Compare
|
|
||
| zassert_equal(resp.cport, pwm_cport, "Response received on wrong CPort"); | ||
|
|
||
| zassert_equal(resp.msg->header.type, GB_PWM_TYPE_PWM_COUNT | GB_TYPE_RESPONSE_FLAG, |
There was a problem hiding this comment.
There is a helper macro GB_RESPONSE. Use that.
|
|
||
| /*The vnd,pwm driver on native_sim might report 0 channels depending on the overlay | ||
| * configuration. We verify that the value is readable (>=0).*/ | ||
| printk("PWM Driver reported %d channels\n", pwm_resp->count); |
There was a problem hiding this comment.
Better to use Logs rather than normal print
a904c73 to
0b16d94
Compare
| #include <zephyr/sys/byteorder.h> | ||
| #include <zephyr/logging/log.h> | ||
|
|
||
| LOG_MODULE_REGISTER(greybus_pwm_test, LOG_LEVEL_INF); |
There was a problem hiding this comment.
I would just use the CONFIG_GREYBUS_LOG_LEVEL instead of hardcoding to info.
| resp = gb_transport_get_message(); | ||
| zassert_not_null(resp.msg, "No version response received"); | ||
|
|
||
| zassert_equal(resp.msg->header.result, GB_OP_SUCCESS, "Version handshake failed"); |
There was a problem hiding this comment.
Use gb_message_is_success helper function that already exists.
| zassert_equal(resp.msg->header.result, GB_OP_SUCCESS, "Operation failed with error: %d", | ||
| resp.msg->header.result); | ||
|
|
||
| struct gb_pwm_count_response *pwm_resp = (struct gb_pwm_count_response *)resp.msg->payload; |
There was a problem hiding this comment.
Probably make this a const. Also, I prefer forward declaration.
| zassert_not_null(resp.msg, "No enable response received"); | ||
| zassert_equal(resp.msg->header.type, GB_RESPONSE(GB_PWM_TYPE_ENABLE), "Wrong Type"); | ||
|
|
||
| if (resp.msg->header.result != GB_OP_SUCCESS) { |
There was a problem hiding this comment.
No need. Just make anything you want to print part of zassert.
There was a problem hiding this comment.
I have updated the assertions as requested (removed the conditional logic).
CI Status- The enable and disable tests are now showing as Failed (Red) in the CI.
This is as per expected. The test is correctly catching that the driver returns error 254 because ofIssue #55(Driver reports 0 channels).
This confirms the test suite is working and successfully reproducing the driver issue.
The rest of the feedback has also been implemented.
There was a problem hiding this comment.
No, the curret issue is that driver will report 1 channel, not 0 (
). This might be some other bug.There was a problem hiding this comment.
No, the curret issue is that driver will report 1 channel, not 0 (
). This might be some other bug.
Oh, I see, so i think this definitely points to a functional bug in the simulation backend or binding.
Since this test is correctly catching that bug, CI is now failing (red), which prevents merging.
So how would you prefer I handle this?
-> Should I mark the enable/disable tests as ZTEST_SKIP() for now (with a comment linking to the bug) so we can merge the test infrastructure?
-> Or should I leave this PR open and try to debug/fix the native_sim driver issue as part of this PR?
There was a problem hiding this comment.
You fix the issue as part of this PR, just a separate commit
There was a problem hiding this comment.
I just tried using debug logs in the pwm-protocols, and running the test again for much better clarity. It returns -95 (EOPNOTSUPP) (when i cross-referenced it with the docs)
I think this confirms that the existing native_sim driver I used (vnd,pwm) does not fully support enable/disable operations requested.
Since vnd,pwm is part of the core Zephyr tree (not this repo), fixing the driver would require an upstream PR to Zephyr, which is outside the scope of this PR. I can probably dive deeper into the issue and I can open a follow-up PR later to add a custom Mock PWM driver if we really need full coverage.
There was a problem hiding this comment.
Doing a bit of grepping, I think you want to use zephyr,fake-pwm instead of vnd,pwm.
There was a problem hiding this comment.
Doing a bit of grepping, I think you want to use
zephyr,fake-pwminstead ofvnd,pwm.
The zephyr,fake-pwm edit worked :) I have implemented the fix in a separate commit as requested.
Changes:
-> Replaced vnd,pwm with the upstream zephyr,fake-pwm driver in the overlay.
-> Enabled CONFIG_PWM_FAKE and FFF to correctly mock the hardware response on native_sim.
Signed-off-by: CPPavithra <cppavithra05@gmail.com>
0b16d94 to
8d826c4
Compare
Signed-off-by: CPPavithra <cppavithra05@gmail.com>
This PR adds the initial integration test infrastructure for the PWM protocol.
-> Uses native_sim board target.
-> Uses the
vnd,pwm(Vendor PWM) driver instead of pwm_fake to avoid linker dependency issues with the FFF library on Zephyr 4.2.0.-> Validates the control protocol version handshake.
-> Validates that the Greybus stack correctly routes
GB_PWM_TYPE_PWM_COUNTto the driver and returns a response on the correct CPort.-> Target: native_sim
-> Command:
west build -p always -b native_sim tests/greybus/integration/pwm -t run-> Result: PROJECT EXECUTION SUCCESSFUL