All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marius Vlad <marius.c.vlad@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 2/4 v4] lib/igt_gvt: Make use of libkmod helpers and fix reading gvt parameter.
Date: Fri, 28 Oct 2016 12:31:27 +0300	[thread overview]
Message-ID: <20161028093129.13275-3-marius.c.vlad@intel.com> (raw)
In-Reply-To: <20161028093129.13275-1-marius.c.vlad@intel.com>

Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
---
 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-10-28  9:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28  9:31 [PATCH i-g-t 0/4 v4] Convert sh scripts to C variants Marius Vlad
2016-10-28  9:31 ` [PATCH i-g-t 1/4 v4] lib/{igt_sysfs, igt_aux}: Make available to other users kick_fbcon() (unbind_fbcon()), and added helpers to lib/igt_aux, lib/igt_kmod Marius Vlad
2016-11-26 15:31   ` Chris Wilson
2016-10-28  9:31 ` Marius Vlad [this message]
2016-10-28 10:08   ` [PATCH i-g-t 2/4 v4] lib/igt_gvt: Make use of libkmod helpers and fix reading gvt parameter Chris Wilson
2016-10-30 12:47     ` Marius Vlad
2016-10-30 12:59       ` Chris Wilson
2016-10-28  9:31 ` [PATCH i-g-t 3/4 v4] tests/drv_module_reload: Convert sh script to C version Marius Vlad
2016-10-28  9:48   ` Chris Wilson
2016-10-30 10:53     ` Marius Vlad
2016-10-28  9:31 ` [PATCH i-g-t 4/4 v4] tests/kms_sysfs_edid_timing: Convert sh " Marius Vlad
2016-10-28 10:03   ` Chris Wilson
2016-10-30 11:41     ` Marius Vlad

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=20161028093129.13275-3-marius.c.vlad@intel.com \
    --to=marius.c.vlad@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.