diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2018-09-07 09:10:44 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-09-07 17:46:09 +0100 |
commit | a4d1158b171ad6774a91562766817d93befdabf6 (patch) | |
tree | d820ffdeb42489dbdfa59ce3fd0a783b01fc954a | |
parent | 3bd68529c46401630467b85e5a8f1a3902280834 (diff) |
igt/pm_backlight: Make the actual_brightness test readable
Previous horror
(pm_backlight:2947) CRITICAL: Test assertion failure function test_and_verify, file ../tests/pm_backlight.c:112:
(pm_backlight:2947) CRITICAL: Failed assertion: ({ typeof(0) _a = (0); typeof(val - tolerance) _b = (val - tolerance); _a > _b ? _a : _b; }) <= result
(pm_backlight:2947) CRITICAL: error: 7125 > 0
References: https://bugs.freedesktop.org/show_bug.cgi?id=107847
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
-rw-r--r-- | tests/pm_backlight.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/pm_backlight.c b/tests/pm_backlight.c index e94340a2..32808cdf 100644 --- a/tests/pm_backlight.c +++ b/tests/pm_backlight.c @@ -98,8 +98,8 @@ static int backlight_write(int value, const char *fname) static void test_and_verify(struct context *context, int val) { + const int tolerance = val * TOLERANCE / 100; int result; - int tolerance = val * TOLERANCE / 100; igt_assert_eq(backlight_write(val, "brightness"), 0); igt_assert_eq(backlight_read(&result, "brightness"), 0); @@ -107,9 +107,11 @@ static void test_and_verify(struct context *context, int val) igt_assert_eq(result, val); igt_assert_eq(backlight_read(&result, "actual_brightness"), 0); - /* Some rounding may happen depending on hw. Just check that it's close enough. */ - igt_assert_lte(result, min(context->max, val + tolerance)); - igt_assert_lte(max(0, val - tolerance), result); + /* Some rounding may happen depending on hw */ + igt_assert_f(result >= max(0, val - tolerance) && + result <= min(context->max, val + tolerance), + "actual_brightness [%d] did not match expected brightness [%d +- %d]\n", + result, val, tolerance); } static void test_brightness(struct context *context) |