2 * This file is part of DisOrder.
3 * Copyright (C) 2008 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 static void test_syscalls(void) {
28 memset(buf
, 99, sizeof buf
);
30 while(write(p
[1], buf
, sizeof buf
) > 0)
32 insist(errno
== EAGAIN
);
33 memset(buf
, 0, sizeof buf
);
34 insist(read(p
[0], buf
, sizeof buf
) == sizeof buf
);
36 insist(buf
[(sizeof buf
) - 1] == 99);
41 insist(read(p
[0], buf
, sizeof buf
) < 0);
42 insist(errno
== EBADF
);
44 insist(write(p
[1], buf
, sizeof buf
) < 0);
45 insist(errno
== EBADF
);
49 sprintf(buf
, "%ld", LONG_MAX
);
50 insist(xstrtol(&n
, buf
, &e
, 0) == 0);
51 insist(n
== LONG_MAX
);
52 insist(e
== buf
+ strlen(buf
));
56 sprintf(buf
, "%ld0", LONG_MAX
);
57 insist(xstrtol(&n
, buf
, &e
, 0) == ERANGE
);
58 insist(n
== LONG_MAX
);
59 insist(e
== buf
+ strlen(buf
));
63 sprintf(buf
, "%ldxyzzy", LONG_MAX
);
64 insist(xstrtol(&n
, buf
, &e
, 0) == 0);
65 insist(n
== LONG_MAX
);
67 check_string(e
, "xyzzy");
70 /* Debian's gcc 2.95 cannot easily be persuaded to define LLONG_MAX even in
71 * extensions modes. If your compiler is this broken you just don't get the
72 * full set of tests. Deal. */
75 sprintf(buf
, "%lld", LLONG_MAX
);
76 insist(xstrtoll(&nn
, buf
, &e
, 0) == 0);
77 insist(nn
== LLONG_MAX
);
78 insist(e
== buf
+ strlen(buf
));
82 sprintf(buf
, "%lld0", LLONG_MAX
);
83 insist(xstrtoll(&nn
, buf
, &e
, 0) == ERANGE
);
84 insist(nn
== LLONG_MAX
);
85 insist(e
== buf
+ strlen(buf
));
89 sprintf(buf
, "%lldxyzzy", LLONG_MAX
);
90 insist(xstrtoll(&nn
, buf
, &e
, 0) == 0);
91 insist(nn
== LLONG_MAX
);
93 check_string(e
, "xyzzy");