[igt-dev] [PATCH i-g-t v5] tests/kms_chamelium: skip if GetAudioFormat is not supported

Simon Ser simon.ser at intel.com
Thu May 16 07:27:57 UTC 2019


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 at intel.com>
Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Arek <arkadiusz.hiler at intel.com>
---

Changes from v4 to v5: don't expose chamelium_supports_get_audio_format
directly, instead call it in chamelium_has_audio_support (Arek)

 lib/igt_chamelium.c   | 73 +++++++++++++++++++++++++++++++++++++------
 tests/kms_chamelium.c |  4 +--
 2 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 94825002cab3..649d807a18fa 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);
@@ -930,12 +961,36 @@ int chamelium_get_captured_frame_count(struct chamelium *chamelium)
 	return ret;
 }

+/**
+ * chamelium_supports_get_audio_format: check the Chamelium device supports
+ * retrieving the capture audio format.
+ */
+static 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);
+
+	/* XML-RPC has a special code for unsupported methods
+	 * (XMLRPC_NO_SUCH_METHOD_ERROR) however the Chamelium implementation
+	 * doesn't return it. */
+	return (!chamelium->env.fault_occurred ||
+		strstr(chamelium->env.fault_string, "not supported") == NULL);
+}
+
 bool chamelium_has_audio_support(struct chamelium *chamelium,
 				 struct chamelium_port *port)
 {
 	xmlrpc_value *res;
 	xmlrpc_bool has_support;

+	if (!chamelium_supports_get_audio_format(chamelium)) {
+		igt_debug("The Chamelium device doesn't support GetAudioFormat\n");
+		return false;
+	}
+
 	res = chamelium_rpc(chamelium, port, "HasAudioSupport", "(i)", port->id);
 	xmlrpc_read_bool(&chamelium->env, res, &has_support);
 	xmlrpc_DECREF(res);
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 7c3006982abd..88e2163d39a4 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -1033,8 +1033,8 @@ 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));

 	alsa = alsa_init();
--
2.21.0



More information about the igt-dev mailing list