public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Simon Ser <simon.ser@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t v3 1/9] tests/kms_chamelium: skip if GetAudioFormat is not supported
Date: Tue, 14 May 2019 15:06:38 +0300	[thread overview]
Message-ID: <20190514120646.19889-2-simon.ser@intel.com> (raw)
In-Reply-To: <20190514120646.19889-1-simon.ser@intel.com>

Skip audio tests in case GetAudioFormat is not supported by the Chamelium
device (because it is outdated).

A new __chamelium_rpc function has been introduced. The difference with
chamelium_rpc is that it doesn't asserts that the XML-RPC succeeds.

A new chamelium_supports_get_audio_format function has been introduced. It
tries to call GetAudioFormats with abritrary parameters, and checks whether the
call fails because the method doesn't exist. It is not possible to generalize
it into chamelium_supports_method because some methods might have side-effects
(and the only way to check whether a method exists is to try to call it).

Signed-off-by: Simon Ser <simon.ser@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Arek <arkadiusz.hiler@intel.com>
---
 lib/igt_chamelium.c   | 65 +++++++++++++++++++++++++++++++++++++------
 lib/igt_chamelium.h   |  1 +
 tests/kms_chamelium.c |  5 ++--
 3 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 94825002cab3..d3ab1ffcc5d6 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -265,14 +265,13 @@ static void *chamelium_fsm_mon(void *data)
 	return NULL;
 }
 
-static xmlrpc_value *chamelium_rpc(struct chamelium *chamelium,
-				   struct chamelium_port *fsm_port,
-				   const char *method_name,
-				   const char *format_str,
-				   ...)
+static xmlrpc_value *__chamelium_rpc_va(struct chamelium *chamelium,
+					struct chamelium_port *fsm_port,
+					const char *method_name,
+					const char *format_str,
+					va_list va_args)
 {
-	xmlrpc_value *res;
-	va_list va_args;
+	xmlrpc_value *res = NULL;
 	struct fsm_monitor_args monitor_args;
 	pthread_t fsm_thread_id;
 
@@ -296,17 +295,49 @@ static xmlrpc_value *chamelium_rpc(struct chamelium *chamelium,
 			       &monitor_args);
 	}
 
-	va_start(va_args, format_str);
 	xmlrpc_client_call2f_va(&chamelium->env, chamelium->client,
 				chamelium->url, method_name, format_str, &res,
 				va_args);
-	va_end(va_args);
 
 	if (fsm_port) {
 		pthread_cancel(fsm_thread_id);
 		igt_cleanup_hotplug(monitor_args.mon);
 	}
 
+	return res;
+}
+
+static xmlrpc_value *__chamelium_rpc(struct chamelium *chamelium,
+				     struct chamelium_port *fsm_port,
+				     const char *method_name,
+				     const char *format_str,
+				     ...)
+{
+	xmlrpc_value *res;
+	va_list va_args;
+
+	va_start(va_args, format_str);
+	res = __chamelium_rpc_va(chamelium, fsm_port, method_name,
+				 format_str, va_args);
+	va_end(va_args);
+
+	return res;
+}
+
+static xmlrpc_value *chamelium_rpc(struct chamelium *chamelium,
+				   struct chamelium_port *fsm_port,
+				   const char *method_name,
+				   const char *format_str,
+				   ...)
+{
+	xmlrpc_value *res;
+	va_list va_args;
+
+	va_start(va_args, format_str);
+	res = __chamelium_rpc_va(chamelium, fsm_port, method_name,
+				 format_str, va_args);
+	va_end(va_args);
+
 	igt_assert_f(!chamelium->env.fault_occurred,
 		     "Chamelium RPC call failed: %s\n",
 		     chamelium->env.fault_string);
@@ -1031,6 +1062,22 @@ void chamelium_get_audio_format(struct chamelium *chamelium,
 	xmlrpc_DECREF(res);
 }
 
+/**
+ * chamelium_supports_get_audio_format: check the Chamelium device supports
+ * retrieving the capture audio format.
+ */
+bool chamelium_supports_get_audio_format(struct chamelium *chamelium)
+{
+	xmlrpc_value *res;
+
+	res = __chamelium_rpc(chamelium, NULL, "GetAudioFormat", "(i)", 3);
+	if (res)
+		xmlrpc_DECREF(res);
+
+	return (!chamelium->env.fault_occurred ||
+		chamelium->env.fault_code != XMLRPC_NO_SUCH_METHOD_ERROR);
+}
+
 /**
  * chamelium_start_capturing_audio:
  * @chamelium: the Chamelium instance
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index a067c888c0ff..ba44a44d6d8f 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -114,6 +114,7 @@ void chamelium_get_audio_channel_mapping(struct chamelium *chamelium,
 void chamelium_get_audio_format(struct chamelium *chamelium,
 				struct chamelium_port *port,
 				int *rate, int *channels);
+bool chamelium_supports_get_audio_format(struct chamelium *chamelium);
 void chamelium_start_capturing_audio(struct chamelium *chamelium,
 				    struct chamelium_port *port, bool save_to_file);
 struct chamelium_audio_file *chamelium_stop_capturing_audio(struct chamelium *chamelium,
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 7c3006982abd..c2d5793a41c5 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -1033,9 +1033,10 @@ test_display_audio(data_t *data, struct chamelium_port *port,
 
 	igt_require(alsa_has_exclusive_access());
 
-	/* Old Chamelium devices need an update for DisplayPort audio
-	 * support. */
+	/* Old Chamelium devices need an update for DisplayPort audio and
+	 * chamelium_get_audio_format support. */
 	igt_require(chamelium_has_audio_support(data->chamelium, port));
+	igt_require(chamelium_supports_get_audio_format(data->chamelium));
 
 	alsa = alsa_init();
 	igt_assert(alsa);
-- 
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-05-14 12:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14 12:06 [igt-dev] [PATCH i-g-t v3 0/9] tests/kms_chamelium: add HDMI audio test Simon Ser
2019-05-14 12:06 ` Simon Ser [this message]
2019-05-14 12:06 ` [igt-dev] [PATCH i-g-t v3 2/9] lib/igt_edid: add support for Short Audio Descriptors Simon Ser
2019-05-14 12:06 ` [igt-dev] [PATCH i-g-t v3 3/9] lib/igt_edid: add support for Vendor Specific Data blocks Simon Ser
2019-05-14 12:06 ` [igt-dev] [PATCH i-g-t v3 4/9] lib/igt_chamelium: add CHAMELIUM_DEFAULT_EDID Simon Ser
2019-05-14 12:06 ` [igt-dev] [PATCH i-g-t v3 5/9] tests/kms_chamelium: generate an EDID with audio support Simon Ser
2019-05-14 12:06 ` [igt-dev] [PATCH i-g-t v3 6/9] tests/kms_chamelium: disable >48KHz audio tests Simon Ser
2019-05-14 12:06 ` [igt-dev] [PATCH i-g-t v3 7/9] tests/kms_chamelium: enable audio test on HDMI ports Simon Ser
2019-05-14 12:06 ` [igt-dev] [PATCH i-g-t v3 8/9] tests/kms_chamelium: don't abort audio test on first fail Simon Ser
2019-05-14 12:06 ` [igt-dev] [PATCH i-g-t v3 9/9] HAX: add {dp, hdmi}-audio test to fast-feedback Simon Ser
2019-05-14 13:48 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_chamelium: add HDMI audio test Patchwork
2019-05-15  7:24   ` Ser, Simon
2019-05-14 18:59 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=20190514120646.19889-2-simon.ser@intel.com \
    --to=simon.ser@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox