[igt-dev] [PATCH i-g-t v3 1/9] tests/kms_chamelium: skip if GetAudioFormat is not supported
Simon Ser
simon.ser at intel.com
Tue May 14 12:06:38 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>
---
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
More information about the igt-dev
mailing list