diff options
author | Jeff McGee <jeff.mcgee@intel.com> | 2014-01-10 15:12:31 -0600 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-01-10 22:31:51 +0100 |
commit | 44b5d7b3300dd7c94d09c57c95ab3a407f8b17ef (patch) | |
tree | cfe1395ff2221c93c4f79d6ab24ecaee9e30b5f6 | |
parent | 265efbb2c4401542c8753e0d83d7a98493720865 (diff) |
pm_rps: Assert that valid sysfs writes return success
do_writeval now always checks the return value, whether we expect
success or a specific error. Also add new macro writeval_inval to
simplify repeated use of do_writeval to test for EINVAL return code.
Signed-off-by: Jeff McGee <jeff.mcgee@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | tests/pm_rps.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/pm_rps.c b/tests/pm_rps.c index 91234515..69eeb814 100644 --- a/tests/pm_rps.c +++ b/tests/pm_rps.c @@ -79,11 +79,18 @@ static int do_writeval(FILE *filp, int val, int lerrno) int ret; rewind(filp); ret = fprintf(filp, "%d", val); - if (ret && lerrno) - igt_assert(errno = lerrno); + if (lerrno) { + /* Expecting specific error */ + igt_assert(ret == EOF && errno == lerrno); + } else { + /* Expecting no error */ + igt_assert(ret != EOF); + } + return ret; } #define writeval(filp, val) do_writeval(filp, val, 0) +#define writeval_inval(filp, val) do_writeval(filp, val, EINVAL) #define fcur (readval(stuff[CUR].filp)) #define fmin (readval(stuff[MIN].filp)) @@ -170,16 +177,16 @@ igt_simple_main checkit(); /* And some errors */ - writeval(stuff[MIN].filp, frpn - 1); - writeval(stuff[MAX].filp, frp0 + 1000); + writeval_inval(stuff[MIN].filp, frpn - 1); + writeval_inval(stuff[MAX].filp, frp0 + 1000); checkit(); - writeval(stuff[MIN].filp, fmax + 1000); - writeval(stuff[MAX].filp, fmin - 1); + writeval_inval(stuff[MIN].filp, fmax + 1000); + writeval_inval(stuff[MAX].filp, fmin - 1); checkit(); - do_writeval(stuff[MIN].filp, 0x11111110, EINVAL); - do_writeval(stuff[MAX].filp, 0, EINVAL); + writeval_inval(stuff[MIN].filp, 0x11111110); + writeval_inval(stuff[MAX].filp, 0); writeval(stuff[MIN].filp, origmin); writeval(stuff[MAX].filp, origmax); |