cec: Deck Control tests
v7 cover cec: Deck Control tests
This is part of an Outreachy project to expand the testing of Deck Control messages as handled by CEC adapters.
Changes since v6:
cec-compliance:
- reorder handling of Feature Abort
- add short comments to explain wait for Skip Forward/Reverse
- change invalid Play operand from 8 to 0 cec-follower:
- do not store the initiator in deck_report_changes_to; instead pass "me" (initiator) as an argument to update_deck_state
- use cec_msg_init to initialize message in update_deck_state
- remove redundant reset of clear deck_report_changes_to
- refactor the No Media check in MSG_PLAY
Changes since v5:
cec-compliance:
- check for Feature Abort before getting deck status. cec-follower:
- send updates to the logical address of the device that requested ongoing status updates which may be different from the device that requests deck-status on a one-time basis.
Changes since v4:
cec-compliance:
- Change deck_status to a reference and initialize to 0.
- Revise test results after receiving Feature Abort with Incorrect Mode.
- Simplify for loop for Skip Forward and Reverse.
- Remove Play as a possible response to Eject.
- Rename "match" and its argument, add fail on abort.
- Rearrange play tests to see clearly all three options (MIN/MED/MAX).
cec-follower:
- Set deck_skip_start to 0 if a new command or standby occurs in the interval between Skip Forward/Reverse and Play.
- Move skip timer to the end of while loop in testProcessing.
- Add helper function update_deck_state.
Changes since v3:
cec-compliance:
- Stop using REQ_On for monitoring deck status changes; instead add a helper function to get and return deck status.
- Allow Stop or Eject to return Feature Abort, Incorrect Mode.
- Replace passive util_receive with an active deck query to see if the deck status changes to Play after Skip Forward/Reverse.
- Add helper function to match play mode and expected deck status.
- Remove the Deck Status test.
cec-follower:
- Track the elasped time since Skip Forward/Reverse and Play after 2s.
- Remove tray open/close toggle from Eject
Changes since v2:
cec-compliance:
- If a deck returns Feature Abort, Incorrect Mode, just provide info unless the deck actually has media, then issue a warning.
- If a deck reports Skip Forward/Reverse status, wait until the status changes again before resuming testing to avoid prematurely failing the test.
- Rearrange/change the tests to trigger deck status changes.
cec-follower:
- Only report actual status changes, not just every Deck Control message that is processed.
- Send Skip Forward/Reverse and then sleep 2 seconds before sending Play.
- Remove the toggle between Play Forward/Play Still.
Changes since v1:
- Remove unnecessary functions and node states.
- Assume that media is present and use the "No Media" deck state solely to indicate whether the tray is open.
- Change and add invalid operands so operands just outside of the valid range are tested.
- Remove restriction to playback/record device.
Deborah Brouwer (3):
cec: add tests for Deck Control message
cec: add tests for Deck Play message
cec-compliance: remove Deck Status test
utils/cec-compliance/cec-compliance.h | 5 + utils/cec-compliance/cec-test.cpp | 213 ++++++++++++++++++++++---- utils/cec-follower/cec-follower.cpp | 2 + utils/cec-follower/cec-follower.h | 2 + utils/cec-follower/cec-processing.cpp | 121 ++++++++++++++- 5 files changed, 308 insertions(+), 35 deletions(-)
Signature · 1 line
2.25.1
PATCH v7 2/3 cec: add tests for Deck Play message
Send all Deck Play commands and check that the follower implements them. Test that the follower returns Feature Abort for invalid Play operands.
--- utils/cec-compliance/cec-test.cpp | 99 ++++++++++++++++++++++++--- utils/cec-follower/cec-processing.cpp | 55 ++++++++++++++- 2 files changed, 140 insertions(+), 14 deletions(-)
utils/cec-compliance/cec-test.cpp +88 -11
@@ -33,6 +33,20 @@ static int deck_status_get(struct node *node, unsigned me, unsigned la, __u8 &de return OK; } +static int test_play_mode(struct node *node, unsigned me, unsigned la, __u8 play_mode, __u8 expected) +{ + struct cec_msg msg = {}; + __u8 deck_status; + + cec_msg_init(&msg, me, la); + cec_msg_play(&msg, play_mode); + fail_on_test(!transmit_timeout(node, &msg)); + fail_on_test(cec_msg_status_is_abort(&msg)); /* Assumes deck has media. */ + fail_on_test(deck_status_get(node, me, la, deck_status)); + fail_on_test(deck_status != expected); + + return OK; +} /* System Information */
@@ -794,24 +808,78 @@ static int deck_ctl_deck_ctl_invalid(struct node *node, unsigned me, unsigned la static int deck_ctl_play(struct node *node, unsigned me, unsigned la, bool interactive) { struct cec_msg msg = {}; + __u8 deck_status; cec_msg_init(&msg, me, la); - cec_msg_play(&msg, CEC_OP_PLAY_MODE_PLAY_STILL); + cec_msg_play(&msg, CEC_OP_PLAY_MODE_PLAY_FWD); fail_on_test(!transmit_timeout(node, &msg)); - if (is_playback_or_rec(la)) { - fail_on_test_v2(node->remote[la].cec_version, - node->remote[la].has_deck_ctl && unrecognized_op(&msg)); - fail_on_test_v2(node->remote[la].cec_version, - !node->remote[la].has_deck_ctl && !unrecognized_op(&msg)); - } + fail_on_test_v2(node->remote[la].cec_version, + node->remote[la].has_deck_ctl && unrecognized_op(&msg)); + fail_on_test_v2(node->remote[la].cec_version, + !node->remote[la].has_deck_ctl && !unrecognized_op(&msg)); if (unrecognized_op(&msg)) return OK_NOT_SUPPORTED; if (refused(&msg)) return OK_REFUSED; - if (cec_msg_status_is_abort(&msg)) - return OK_PRESUMED; + fail_on_test(deck_status_get(node, me, la, deck_status)); + if (cec_msg_status_is_abort(&msg)) { + if (!incorrect_mode(&msg)) + return FAIL; + if (deck_status == CEC_OP_DECK_INFO_NO_MEDIA) + info("Play Still: no media.\n"); + else + warn("Deck has media but returned Feature Abort with Incorrect Mode."); + return OK; + } + fail_on_test(deck_status != CEC_OP_DECK_INFO_PLAY); - return OK_PRESUMED; + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_STILL, CEC_OP_DECK_INFO_STILL)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_REV, CEC_OP_DECK_INFO_PLAY_REV)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MIN, CEC_OP_DECK_INFO_FAST_FWD)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_FAST_REV_MIN, CEC_OP_DECK_INFO_FAST_REV)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MED, CEC_OP_DECK_INFO_FAST_FWD)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_FAST_REV_MED, CEC_OP_DECK_INFO_FAST_REV)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MAX, CEC_OP_DECK_INFO_FAST_FWD)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_FAST_REV_MAX, CEC_OP_DECK_INFO_FAST_REV)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MIN, CEC_OP_DECK_INFO_SLOW)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MIN, CEC_OP_DECK_INFO_SLOW_REV)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MED, CEC_OP_DECK_INFO_SLOW)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MED, CEC_OP_DECK_INFO_SLOW_REV)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MAX, CEC_OP_DECK_INFO_SLOW)); + fail_on_test(test_play_mode(node, me, la, CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MAX, CEC_OP_DECK_INFO_SLOW_REV)); + + cec_msg_init(&msg, me, la); + cec_msg_deck_control(&msg, CEC_OP_DECK_CTL_MODE_STOP); + fail_on_test(!transmit_timeout(node, &msg)); + + return OK; +} + +static int deck_ctl_play_invalid(struct node *node, unsigned me, unsigned la, bool interactive) +{ + struct cec_msg msg = {}; + + cec_msg_init(&msg, me, la); + cec_msg_play(&msg, 0); /* Invalid Operand */ + fail_on_test(!transmit_timeout(node, &msg)); + if (unrecognized_op(&msg)) + return OK_NOT_SUPPORTED; + fail_on_test(!cec_msg_status_is_abort(&msg)); + fail_on_test(abort_reason(&msg) != CEC_OP_ABORT_INVALID_OP); + + cec_msg_init(&msg, me, la); + cec_msg_play(&msg, 4); /* Invalid Operand */ + fail_on_test(!transmit_timeout(node, &msg)); + fail_on_test(!cec_msg_status_is_abort(&msg)); + fail_on_test(abort_reason(&msg) != CEC_OP_ABORT_INVALID_OP); + + cec_msg_init(&msg, me, la); + cec_msg_play(&msg, 0x26); /* Invalid Operand */ + fail_on_test(!transmit_timeout(node, &msg)); + fail_on_test(!cec_msg_status_is_abort(&msg)); + fail_on_test(abort_reason(&msg) != CEC_OP_ABORT_INVALID_OP); + + return OK; } static const vec_remote_subtests deck_ctl_subtests{
@@ -826,7 +894,6 @@ static const vec_remote_subtests deck_ctl_subtests{ deck_ctl_give_status_invalid, }, { "Deck Status", CEC_LOG_ADDR_MASK_ALL, deck_ctl_deck_status }, - { "Play", CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD, deck_ctl_play }, { "Deck Control", CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD,
@@ -837,6 +904,16 @@ static const vec_remote_subtests deck_ctl_subtests{ CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD, deck_ctl_deck_ctl_invalid, }, + { + "Play", + CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD, + deck_ctl_play, + }, + { + "Play Invalid Operand", + CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD, + deck_ctl_play_invalid, + }, }; /* Tuner Control */
utils/cec-follower/cec-processing.cpp +52 -3
66 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v7 3/3 cec-compliance: remove Deck Status test
In reply to Deborah BrouwerRemove the Deck Status message test because invalid Deck Status messages are already captured by cec-compliance in other tests.
--- utils/cec-compliance/cec-test.cpp | 18 ------------------ 1 file changed, 18 deletions(-)
utils/cec-compliance/cec-test.cpp +0 -18
@@ -696,23 +696,6 @@ static int deck_ctl_give_status_invalid(struct node *node, unsigned me, unsigned return OK; } -static int deck_ctl_deck_status(struct node *node, unsigned me, unsigned la, bool interactive) -{ - struct cec_msg msg = {}; - - cec_msg_init(&msg, me, la); - cec_msg_deck_status(&msg, CEC_OP_DECK_INFO_STOP); - fail_on_test(!transmit_timeout(node, &msg)); - if (unrecognized_op(&msg)) - return OK_NOT_SUPPORTED; - if (refused(&msg)) - return OK_REFUSED; - if (cec_msg_status_is_abort(&msg)) - return OK_PRESUMED; - - return 0; -} - static int deck_ctl_deck_ctl(struct node *node, unsigned me, unsigned la, bool interactive) { struct cec_msg msg = {};
@@ -893,7 +876,6 @@ static const vec_remote_subtests deck_ctl_subtests{ CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD, deck_ctl_give_status_invalid, }, - { "Deck Status", CEC_LOG_ADDR_MASK_ALL, deck_ctl_deck_status }, { "Deck Control", CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD,
Signature · 1 line
2.25.1
PATCH v7 1/3 cec: add tests for Deck Control message
In reply to Deborah BrouwerSend all Deck Control commands Skip Forward, Skip Reverse, Stop and Eject and check the corresponding deck status. Test that the follower returns Feature Abort for invalid Deck Control operands.
--- utils/cec-compliance/cec-compliance.h | 5 ++ utils/cec-compliance/cec-test.cpp | 112 +++++++++++++++++++++++--- utils/cec-follower/cec-follower.cpp | 2 + utils/cec-follower/cec-follower.h | 2 + utils/cec-follower/cec-processing.cpp | 68 +++++++++++++++- 5 files changed, 177 insertions(+), 12 deletions(-)
utils/cec-compliance/cec-compliance.h +5 -0
@@ -359,6 +359,11 @@ static inline bool refused(const struct cec_msg *msg)return cec_msg_status_is_abort (msg) &&abort_reason (msg) ==CEC_OP_ABORT_REFUSED ; } +static inline bool incorrect_mode (const struct cec_msg *msg) +{ +return cec_msg_status_is_abort (msg) &&abort_reason (msg) ==CEC_OP_ABORT_INCORRECT_MODE ; +} +static inline bool timed_out (const struct cec_msg *msg) {return msg->rx_status &CEC_RX_STATUS_TIMEOUT ;
utils/cec-compliance/cec-test.cpp +102 -10
140 lines not on this page · raw message
utils/cec-follower/cec-follower.cpp +2 -0
@@ -314,7 +314,9 @@ void state_init(struct node &node) node.state.volume = 50; node.state.mute = false; node.state.deck_report_changes = false; + node.state.deck_report_changes_to = 0; node.state.deck_state = CEC_OP_DECK_INFO_STOP; + node.state.deck_skip_start = 0; tuner_dev_info_init(&node.state); node.state.last_aud_rate_rx_ts = 0; }
utils/cec-follower/cec-follower.h +2 -0
@@ -50,7 +50,9 @@ struct state {bool service_by_dig_id;bool tuner_report_changes;bool deck_report_changes; +__u8 deck_report_changes_to;__u8 deck_state; +__u64 deck_skip_start;unsigned toggle_power_status;__u64 last_aud_rate_rx_ts; };
utils/cec-follower/cec-processing.cpp +66 -2
105 lines not on this page · raw message
Signature · 1 line
2.25.1