Commit | Line | Data |
---|---|---|
7217e0ca ML |
1 | From d4934a8fb4fab54d39c42ca445687985fe4410cd Mon Sep 17 00:00:00 2001 |
2 | From: Alan Coopersmith <alan.coopersmith@oracle.com> | |
3 | Date: Sun, 9 Feb 2014 22:42:47 -0800 | |
4 | Subject: [PATCH 19/33] Add REQUEST_FIXED_SIZE testcases to test/misc.c | |
5 | ||
6 | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> | |
7 | Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> | |
8 | --- | |
9 | test/misc.c | 37 +++++++++++++++++++++++++++++++++++++ | |
10 | 1 file changed, 37 insertions(+) | |
11 | ||
7217e0ca ML |
12 | --- a/test/misc.c |
13 | +++ b/test/misc.c | |
14 | @@ -28,6 +28,8 @@ | |
15 | #include <stdint.h> | |
16 | #include "misc.h" | |
17 | #include "scrnintstr.h" | |
18 | +#include "dix.h" | |
19 | +#include "dixstruct.h" | |
20 | ||
21 | ScreenInfo screenInfo; | |
22 | ||
23 | @@ -155,11 +157,46 @@ dix_update_desktop_dimensions(void) | |
24 | assert_dimensions(-w2, -h2, w2, h2); | |
25 | } | |
26 | ||
27 | +static int | |
28 | +dix_request_fixed_size_overflow(ClientRec *client) | |
29 | +{ | |
30 | + xReq req = { 0 }; | |
31 | + | |
32 | + client->req_len = req.length = 1; | |
33 | + REQUEST_FIXED_SIZE(req, SIZE_MAX); | |
34 | + return Success; | |
35 | +} | |
36 | + | |
37 | +static int | |
38 | +dix_request_fixed_size_match(ClientRec *client) | |
39 | +{ | |
40 | + xReq req = { 0 }; | |
41 | + | |
42 | + client->req_len = req.length = 9; | |
43 | + REQUEST_FIXED_SIZE(req, 30); | |
44 | + return Success; | |
45 | +} | |
46 | + | |
47 | +static void | |
48 | +dix_request_size_checks(void) | |
49 | +{ | |
50 | + ClientRec client = { 0 }; | |
51 | + int rc; | |
52 | + | |
53 | + rc = dix_request_fixed_size_overflow(&client); | |
54 | + assert(rc == BadLength); | |
55 | + | |
56 | + rc = dix_request_fixed_size_match(&client); | |
57 | + assert(rc == Success); | |
58 | +} | |
59 | + | |
60 | + | |
61 | int | |
62 | main(int argc, char **argv) | |
63 | { | |
64 | dix_version_compare(); | |
65 | dix_update_desktop_dimensions(); | |
66 | + dix_request_size_checks(); | |
67 | ||
68 | return 0; | |
69 | } |