Re: [igt-dev] [PATCH i-g-t v2] Add support for forcing specific module

Chris Wilson
2018-09-05T22:49:08Z

Quoting Rodrigo Siqueira (2018-09-05 21:38:27)
> This commit adds a new option for forcing the use of a specific driver
> indicated via an environment variable.
>
> Changes since V1:
> Petri:
> - Use an environment variable instead of command line
> - Refactor the loop in __search_and_open to accept forced module
> - Don't try to load kernel modules

I am still not convinced this is a good solution to the problem of
running tests against all applicable devices, along with generic
filtering of that set (both from the test profile and user config).

Short term wise I'd rather see DRIVER_ANY translated into a known
DRIVER_X selector (so that we have a complete list of drivers for later
exploitation), say

diff --git a/lib/drmtest.c b/lib/drmtest.c
index bfa2e0f..5c96c1d 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -257,11 +257,16 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset)
return -1;
}

+static unsigned int driver_any_chipset = DRIVER_ANY; // give me a better name
+
static int __open_driver(const char *base, int offset, unsigned int chipset)
{
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int fd;

+ if (chipset == DRIVER_ANY)
+ chipset = driver_any_chipset;
+
fd = __search_and_open(base, offset, chipset);
if (fd != -1)
return fd;
@@ -428,3 +433,21 @@ void igt_require_intel(int fd)
{
igt_require(is_i915_device(fd) && has_known_intel_chipset(fd));
}
+
+bool set_driver_any(const char *name)
+{
+ for (int start = 0, end = ARRAY_SIZE(modules) - 1; start < end; ) { // repetitive much?
+ int mid = start + (end - start) / 2;
+ int ret = strcmp(modules[mid].module, name);
+ if (ret < 0) {
+ start = mid + 1;
+ } else if (ret > 0) {
+ end = mid;
+ } else {
+ driver_any_chipset = modules[mid].bit;
+ return true;
+ }
+ }
+
+ return false;
+}