Commit e7729915 authored by Chris Wilson's avatar Chris Wilson

Replace more system("modprobe")

As we have libkmod available, it is faster and safer than calling
system().
Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 2297766d
......@@ -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));
}
......
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment