summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-03-25 13:05:38 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-03-25 13:11:10 +0000
commite77299156606f3f3bf5610586a6a0879bdffcf11 (patch)
treeb722e9e5971144f086cb5adb16be82ceab26bd4d
parent2297766d8101661cd03749630aeb1c60cc615da1 (diff)
Replace more system("modprobe")
As we have libkmod available, it is faster and safer than calling system(). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/sw_sync.c8
-rw-r--r--tests/pm_rpm.c10
-rw-r--r--tests/vgem_basic.c3
3 files changed, 17 insertions, 4 deletions
diff --git a/lib/sw_sync.c b/lib/sw_sync.c
index 9dc6ec85..c05a7876 100644
--- a/lib/sw_sync.c
+++ b/lib/sw_sync.c
@@ -36,6 +36,7 @@
#include <sys/ioctl.h>
#include "igt_debugfs.h"
+#include "igt_kmod.h"
#include "sw_sync.h"
#include "drmtest.h"
#include "ioctl_wrappers.h"
@@ -248,11 +249,16 @@ int sync_fence_status(int fence)
return fence_info.status;
}
+static void modprobe(const char *driver)
+{
+ igt_kmod_load(driver, "");
+}
+
static bool kernel_has_sw_sync(void)
{
char buf[128];
- igt_ignore_warn(system("/sbin/modprobe -s r sw_sync"));
+ modprobe("sw_sync");
return kernel_sw_sync_path(buf, sizeof(buf));
}
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index e5475c91..3b88348a 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -26,6 +26,7 @@
*/
#include "igt.h"
+#include "igt_kmod.h"
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
@@ -111,6 +112,11 @@ struct modeset_params *default_mode_params;
static int8_t *pm_data = NULL;
+static int modprobe(const char *driver)
+{
+ return igt_kmod_load(driver, "");
+}
+
/* If the read fails, then the machine doesn't support PC8+ residencies. */
static bool supports_pc8_plus_residencies(void)
{
@@ -647,7 +653,7 @@ static void setup_pc8(void)
return;
/* Make sure our Kernel supports MSR and the module is loaded. */
- igt_require(system("modprobe -s msr") == 0);
+ igt_require(modprobe("msr") == 0);
msr_fd = open("/dev/cpu/0/msr", O_RDONLY);
igt_assert_f(msr_fd >= 0,
@@ -793,7 +799,7 @@ static void i2c_subtest_check_environment(void)
struct dirent *dirent;
/* Make sure the /dev/i2c-* files exist. */
- igt_require(system("modprobe -s i2c-dev") == 0);
+ igt_require(modprobe("i2c-dev") == 0);
dev_dir = opendir("/dev");
igt_assert(dev_dir);
diff --git a/tests/vgem_basic.c b/tests/vgem_basic.c
index 5b54a4a3..cce9229f 100644
--- a/tests/vgem_basic.c
+++ b/tests/vgem_basic.c
@@ -22,6 +22,7 @@
*/
#include "igt.h"
+#include "igt_kmod.h"
#include "igt_vgem.h"
#include "igt_debugfs.h"
#include "igt_sysfs.h"
@@ -290,7 +291,7 @@ static void test_debugfs_read(int fd)
static int module_unload(void)
{
- return system("/sbin/modprobe -s -r vgem");
+ return igt_kmod_unload("vgem", 0);
}
static void test_unload(void)