From 3dc91f32424191f28d7512014b2871e22b5a05b9 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 4 Oct 2013 19:49:36 +0200 Subject: [PATCH] tests/pc8+: Only skip i2c subtest if i2c /dev interface is unavailable Through the magic of igt_skip we only need to fail this subtest, not the entire thing. Signed-off-by: Daniel Vetter --- tests/pc8.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/tests/pc8.c b/tests/pc8.c index 9070a6b..e93d928 100644 --- a/tests/pc8.c +++ b/tests/pc8.c @@ -580,10 +580,6 @@ static bool test_i2c(struct mode_set_data *data) static bool setup_environment(void) { - int i2c_dev_files; - DIR *dev_dir; - struct dirent *dirent; - drm_fd = drm_open_any(); if (drm_fd <= 0) return false; @@ -603,23 +599,6 @@ static bool setup_environment(void) return false; } - /* Make sure the /dev/i2c-* files exist. */ - dev_dir = opendir("/dev"); - if (!dev_dir) { - printf("Can't open /dev.\n"); - return false; - } - i2c_dev_files = 0; - while ((dirent = readdir(dev_dir))) { - if (strncmp(dirent->d_name, "i2c-", 4) == 0) - i2c_dev_files++; - } - closedir(dev_dir); - if (!i2c_dev_files) { - printf("No /dev/i2c-* files.\n"); - return false; - } - /* Non-ULT machines don't support PC8+. */ if (!supports_pc8_plus_residencies()) { printf("Machine doesn't support PC8+ residencies.\n"); @@ -701,7 +680,19 @@ static void batch_subtest(void) /* Try to use raw I2C, which also needs interrupts. */ static void i2c_subtest(void) { - printf("Testing raw i2c protocol calls.\n"); + int i2c_dev_files = 0; + DIR *dev_dir; + struct dirent *dirent; + + /* Make sure the /dev/i2c-* files exist. */ + dev_dir = opendir("/dev"); + igt_assert(dev_dir); + while ((dirent = readdir(dev_dir))) { + if (strncmp(dirent->d_name, "i2c-", 4) == 0) + i2c_dev_files++; + } + closedir(dev_dir); + igt_require(i2c_dev_files); enable_one_screen(&ms_data); igt_assert(pc8_plus_disabled()); -- 2.7.4