All of lore.kernel.org
 help / color / mirror / Atom feed
From: Deborah Brouwer <deborahbrouwer3563@gmail.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, Deborah Brouwer <deborahbrouwer3563@gmail.com>
Subject: [PATCH v4 3/3] cec: add invalid operand test for Audio Rate Control messages
Date: Wed, 21 Apr 2021 20:27:54 -0700	[thread overview]
Message-ID: <b1a4ce191ad422e0f178101fe2e9ec73e4625048.1619060430.git.deborahbrouwer3563@gmail.com> (raw)
In-Reply-To: <cover.1619060430.git.deborahbrouwer3563@gmail.com>
In-Reply-To: <cover.1619060430.git.deborahbrouwer3563@gmail.com>

Add a test in cec-compliance that sends an Audio Rate Control message
with an invalid operand. Check that it receives a Feature Abort reply
due to the invalid operand. Add a response in cec-follower to Feature
Abort due to an invalid operand.

Signed-off-by: Deborah Brouwer <deborahbrouwer3563@gmail.com>
---
 utils/cec-compliance/cec-test-audio.cpp | 25 +++++++++++++++++++++++++
 utils/cec-follower/cec-processing.cpp   |  4 ++++
 2 files changed, 29 insertions(+)

diff --git a/utils/cec-compliance/cec-test-audio.cpp b/utils/cec-compliance/cec-test-audio.cpp
index e1386dbb..bdbcd178 100644
--- a/utils/cec-compliance/cec-test-audio.cpp
+++ b/utils/cec-compliance/cec-test-audio.cpp
@@ -895,6 +895,25 @@ static int audio_rate_ctl_active_sensing(struct node *node, unsigned me, unsigne
 	return OK_PRESUMED;
 }
 
+static int audio_rate_ctl_invalid(struct node *node, unsigned me, unsigned la, bool interactive)
+{
+	if (!node->remote[la].has_aud_rate)
+		return NOTAPPLICABLE;
+
+	struct cec_msg msg = {};
+
+	cec_msg_init(&msg, me, la);
+	cec_msg_set_audio_rate(&msg, 0xa); /* Invalid Audio Rate Control message operand */
+	fail_on_test(!transmit_timeout(node, &msg));
+	fail_on_test(timed_out(&msg));
+	fail_on_test(!cec_msg_status_is_abort(&msg));
+	if (abort_reason(&msg) != CEC_OP_ABORT_INVALID_OP) {
+		warn("Expected Feature Abort [Invalid operand]\n");
+		return FAIL;
+	}
+	return OK;
+}
+
 const vec_remote_subtests audio_rate_ctl_subtests{
 	{
 		"Set Audio Rate",
@@ -908,4 +927,10 @@ const vec_remote_subtests audio_rate_ctl_subtests{
 		CEC_LOG_ADDR_MASK_TUNER | CEC_LOG_ADDR_MASK_AUDIOSYSTEM,
 		audio_rate_ctl_active_sensing,
 	},
+	{
+		"Audio Rate Invalid Operand",
+		CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD |
+		CEC_LOG_ADDR_MASK_TUNER | CEC_LOG_ADDR_MASK_AUDIOSYSTEM,
+		audio_rate_ctl_invalid,
+	},
 };
diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp
index fc0d5df0..93db4059 100644
--- a/utils/cec-follower/cec-processing.cpp
+++ b/utils/cec-follower/cec-processing.cpp
@@ -814,6 +814,10 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me)
 			aud_rate_msg_interval_check(msg.rx_ts, node->state.last_aud_rate_rx_ts);
 			node->state.last_aud_rate_rx_ts = msg.rx_ts;
 			return;
+		default:
+			cec_msg_reply_feature_abort(&msg, CEC_OP_ABORT_INVALID_OP);
+			transmit(node, &msg);
+			break;
 		}
 		break;
 
-- 
2.17.1


  parent reply	other threads:[~2021-04-22  3:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22  3:27 [PATCH v4 0/3] cec: add tests to Audio Rate Control Deborah Brouwer
2021-04-22  3:27 ` [PATCH v4 1/3] cec-compliance: add Audio System mask to Set Audio Rate Deborah Brouwer
2021-04-22  3:27 ` [PATCH v4 2/3] cec: add active sensing test for Audio Rate Control messages Deborah Brouwer
2021-04-22  7:06   ` Hans Verkuil
2021-04-22  3:27 ` Deborah Brouwer [this message]
2021-04-22  7:02 ` [PATCH v4 0/3] cec: add tests to Audio Rate Control Hans Verkuil
2021-04-22  7:27   ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1a4ce191ad422e0f178101fe2e9ec73e4625048.1619060430.git.deborahbrouwer3563@gmail.com \
    --to=deborahbrouwer3563@gmail.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.