summaryrefslogtreecommitdiff
path: root/tests/vgem_basic.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-06-20 19:21:26 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-06-20 19:23:03 +0100
commit8deba38a3af34354680984186bdc80cfc6734138 (patch)
treed101ac1a74a2476360f97ad43483d6392709ae3a /tests/vgem_basic.c
parent0e1f5e3e796ae383daeb8f1aa394ce5f030e7bb9 (diff)
igt/vgem_basic: Exercise opening sysfs/debugfs
For fun, debugfs/.../names currently explodes, so lets capture that and make sure that basic access to debugfs does no harm. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/vgem_basic.c')
-rw-r--r--tests/vgem_basic.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/vgem_basic.c b/tests/vgem_basic.c
index 4e8408f2..b4337ee1 100644
--- a/tests/vgem_basic.c
+++ b/tests/vgem_basic.c
@@ -23,8 +23,12 @@
#include "igt.h"
#include "igt_vgem.h"
+#include "igt_debugfs.h"
+#include "igt_sysfs.h"
#include <sys/mman.h>
+#include <sys/stat.h>
+#include <dirent.h>
IGT_TEST_DESCRIPTION("Basic sanity check of Virtual GEM module (vGEM).");
@@ -140,6 +144,62 @@ static void test_dmabuf_mmap(int fd)
munmap(ptr, bo.size);
}
+static void test_sysfs_read(int fd)
+{
+ int dir = igt_sysfs_open(fd, NULL);
+ DIR *dirp = fdopendir(dir);
+ struct dirent *de;
+
+ while ((de = readdir(dirp))) {
+ struct stat st;
+
+ if (*de->d_name == '.')
+ continue;
+
+ if (fstatat(dir, de->d_name, &st, 0))
+ continue;
+
+ if (S_ISDIR(st.st_mode))
+ continue;
+
+ igt_debug("Reading %s\n", de->d_name);
+ igt_set_timeout(1, "vgem sysfs read stalled");
+ free(igt_sysfs_get(dir, de->d_name));
+ igt_reset_timeout();
+ }
+
+ closedir(dirp);
+ close(dir);
+}
+
+static void test_debugfs_read(int fd)
+{
+ int dir = igt_debugfs_dir(fd);
+ DIR *dirp = fdopendir(dir);
+ struct dirent *de;
+
+ while ((de = readdir(dirp))) {
+ struct stat st;
+
+ if (*de->d_name == '.')
+ continue;
+
+ if (fstatat(dir, de->d_name, &st, 0))
+ continue;
+
+ if (S_ISDIR(st.st_mode))
+ continue;
+
+ igt_debug("Reading %s\n", de->d_name);
+ igt_set_timeout(1, "vgem debugfs read stalled");
+ free(igt_sysfs_get(dir, de->d_name));
+ igt_reset_timeout();
+ }
+
+ closedir(dirp);
+ close(dir);
+}
+
static bool has_prime_export(int fd)
{
uint64_t value;
@@ -176,6 +236,11 @@ igt_main
test_dmabuf_mmap(fd);
}
+ igt_subtest("sysfs")
+ test_sysfs_read(fd);
+ igt_subtest("debugfs")
+ test_debugfs_read(fd);
+
igt_fixture {
close(fd);
}