summaryrefslogtreecommitdiff
path: root/tests/sysfs_rps.c
diff options
context:
space:
mode:
authorBen Widawsky <ben@bwidawsk.net>2012-10-15 10:05:56 -0700
committerBen Widawsky <ben@bwidawsk.net>2012-10-15 10:05:56 -0700
commitdc3ac00f033245155c765f308fe76088f9f5bfc0 (patch)
tree46303206c55eaab03aa2ca1234aeedb826d42139 /tests/sysfs_rps.c
parent50d46750d90b30a06d15583abe693550955ebd50 (diff)
sysfs_rps: Add negative test case for bad values
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Diffstat (limited to 'tests/sysfs_rps.c')
-rw-r--r--tests/sysfs_rps.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/sysfs_rps.c b/tests/sysfs_rps.c
index 833c2e97..94c43827 100644
--- a/tests/sysfs_rps.c
+++ b/tests/sysfs_rps.c
@@ -74,12 +74,20 @@ static int readval(FILE *filp)
return val;
}
-static void writeval(FILE *filp, int val)
+static int do_writeval(FILE *filp, int val, int lerrno)
{
+ /* Must write twice to sysfs since the first one simply calculates the size and won't return the error */
+ int ret;
rewind(filp);
- fprintf(filp, "%d", val);
+ ret = fprintf(filp, "%d", val);
+ rewind(filp);
+ ret = fprintf(filp, "%d", val);
+ if (ret && lerrno)
+ assert(errno = lerrno);
fflush(filp);
+ return ret;
}
+#define writeval(filp, val) do_writeval(filp, val, 0)
#define fcur (readval(stuff[CUR].filp))
#define fmin (readval(stuff[MIN].filp))
@@ -176,6 +184,9 @@ int main(int argc, char *argv[])
writeval(stuff[MAX].filp, fmin - 1);
checkit();
+ do_writeval(stuff[MIN].filp, 0x11111110, EINVAL);
+ do_writeval(stuff[MAX].filp, 0, EINVAL);
+
writeval(stuff[MIN].filp, origmin);
writeval(stuff[MAX].filp, origmax);