Signed-off-by: Marius Vlad <marius.c.vlad@xxxxxxxxx> --- lib/igt_gvt.c | 42 +++++++++++++++++++++++++++++++++++------- tests/gvt_basic.c | 2 +- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/lib/igt_gvt.c b/lib/igt_gvt.c index 8bbf9bd..d868cb3 100644 --- a/lib/igt_gvt.c +++ b/lib/igt_gvt.c @@ -24,23 +24,26 @@ #include "igt.h" #include "igt_gvt.h" #include "igt_sysfs.h" +#include "igt_kmod.h" +#include <signal.h> #include <dirent.h> #include <unistd.h> #include <fcntl.h> +#include <time.h> static bool is_gvt_enabled(void) { FILE *file; - int value; + char value; bool enabled = false; file = fopen("/sys/module/i915/parameters/enable_gvt", "r"); if (!file) return false; - if (fscanf(file, "%d", &value) == 1) - enabled = value; + if (fscanf(file, "%c", &value) == 1) + enabled = (value == 'Y' ? true : false); fclose(file); errno = 0; @@ -50,9 +53,20 @@ static bool is_gvt_enabled(void) static void unload_i915(void) { kick_fbcon(false); - /* pkill alsact */ - igt_ignore_warn(system("/sbin/modprobe -s -r i915")); + + if (igt_kmod_is_loaded("i915")) { + + if (igt_kmod_is_loaded("snd_hda_intel")) { + igt_assert(!igt_pkill(SIGTERM, "alsactl")); + igt_assert(!igt_kmod_unload("snd_hda_intel", 0)); + } + + igt_assert(!igt_kmod_unload("i915", 0)); + igt_assert(!igt_kmod_unload("drm_kms_helper", 0)); + igt_assert(!igt_kmod_unload("drm", 0)); + } + } bool igt_gvt_load_module(void) @@ -61,8 +75,15 @@ bool igt_gvt_load_module(void) return true; unload_i915(); - igt_ignore_warn(system("/sbin/modprobe -s i915 enable_gvt=1")); + igt_assert(!igt_kmod_load("drm", NULL)); + igt_assert(!igt_kmod_load("drm_kms_helper", NULL)); + + igt_assert(!igt_kmod_load("i915", "enable_gvt=1")); + + kick_fbcon(true); + + igt_assert(!igt_kmod_load("snd_hda_intel", NULL)); return is_gvt_enabled(); } @@ -72,7 +93,14 @@ void igt_gvt_unload_module(void) return; unload_i915(); - igt_ignore_warn(system("/sbin/modprobe -s i915 enable_gvt=0")); + + igt_assert(!igt_kmod_load("drm", NULL)); + igt_assert(!igt_kmod_load("drm_kms_helper", NULL)); + + igt_assert(!igt_kmod_load("i915", "enable_gvt=0")); igt_assert(!is_gvt_enabled()); + + kick_fbcon(true); + igt_assert(!igt_kmod_load("snd_hda_intel", NULL)); } diff --git a/tests/gvt_basic.c b/tests/gvt_basic.c index 48b853a..4e909a5 100644 --- a/tests/gvt_basic.c +++ b/tests/gvt_basic.c @@ -32,7 +32,7 @@ igt_main igt_fixture { igt_require(igt_gvt_load_module()); - fd = drm_open_driver(DRIVER_INTEL); + fd = __drm_open_driver(DRIVER_INTEL); } igt_subtest_f("invalid-placeholder-test"); -- 2.7.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx