public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Mohammed Bilal <mohammed.bilal@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: jeevan.b@intel.com, kunal1.joshi@intel.com,
	sameer.lattannavar@intel.com, karthik.b.s@intel.com,
	Mohammed Bilal <mohammed.bilal@intel.com>
Subject: [PATCH i-g-t v5 1/2] lib/igt_chamelium: Add connector_test() macro
Date: Tue,  6 Jan 2026 21:02:31 +0530	[thread overview]
Message-ID: <20260106153232.79004-2-mohammed.bilal@intel.com> (raw)
In-Reply-To: <20260106153232.79004-1-mohammed.bilal@intel.com>

v5:
- Iterate and test all matching connected ports (Kunal)

v4:
- Rename helper to igt_chamelium_get_port (Jeevan)
- Add documentation for helper and macro (Jeevan)
- Use lowercase name for test macro (Sebastien)

Update connector handling to iterate over all matching connected ports and
execute tests accordingly, while fixing unintended fixture execution and
skipping cleanly when no matching connector is present.

Signed-off-by: Mohammed Bilal <mohammed.bilal@intel.com>
---
 lib/igt_chamelium.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index b5d13ddc8..cf530d6cd 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -274,4 +274,35 @@ bool chamelium_plug_all(struct chamelium *chamelium);
 bool chamelium_wait_all_configured_ports_connected(struct chamelium *chamelium,
 						   int drm_fd);
 
+/**
+ * connector_test() - Run a subtest for all ports of a given connector type
+ *
+ * Defines a subtest that iterates over all available Chamelium ports and
+ * executes the provided test function for each port matching the requested
+ * connector type. If no matching port is found, the subtest is skipped
+ * cleanly.
+ *
+ * This helper avoids repeated connector-iteration logic and provides a
+ * consistent pattern for running connector-specific tests.
+ */
+
+#define connector_test(name, connector_type, test_fn, ...)		\
+	{								\
+		int p;							\
+		struct chamelium_port *port;                            \
+		igt_subtest(name) {					\
+			bool found = false;				\
+			for_each_port(p, port) {			\
+				if (chamelium_port_get_type(port) !=	\
+					DRM_MODE_CONNECTOR_##connector_type)	\
+					continue;			\
+				found = true;				\
+				test_fn(&data, port, ##__VA_ARGS__);	\
+			}						\
+			if (!found)					\
+				igt_skip(#connector_type		\
+					 " connector not available\n"); \
+			}						\
+	}
+
 #endif /* IGT_CHAMELIUM_H */
-- 
2.48.1


  reply	other threads:[~2026-01-06 15:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 15:32 [PATCH i-g-t v5 0/2] Fix chamelium port allocation during igt_fixture Mohammed Bilal
2026-01-06 15:32 ` Mohammed Bilal [this message]
2026-01-06 15:32 ` [PATCH i-g-t v5 2/2] tests/chamelium/kms_chamelium_hpd: use helper function for connector lookup in DP/HDMI/VGA tests Mohammed Bilal
2026-01-06 16:07 ` ✓ Xe.CI.BAT: success for Fix chamelium port allocation during igt_fixture Patchwork
2026-01-06 16:24 ` ✗ i915.CI.BAT: failure " Patchwork
2026-01-06 17:37 ` ✗ Xe.CI.Full: " 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=20260106153232.79004-2-mohammed.bilal@intel.com \
    --to=mohammed.bilal@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jeevan.b@intel.com \
    --cc=karthik.b.s@intel.com \
    --cc=kunal1.joshi@intel.com \
    --cc=sameer.lattannavar@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