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 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 static void test_syscalls(void) {
30 memset(buf, 99, sizeof buf);
32 while(write(p[1], buf, sizeof buf) > 0)
34 insist(errno == EAGAIN);
35 memset(buf, 0, sizeof buf);
36 insist(read(p[0], buf, sizeof buf) == sizeof buf);
38 insist(buf[(sizeof buf) - 1] == 99);
43 insist(read(p[0], buf, sizeof buf) < 0);
44 insist(errno == EBADF);
46 insist(write(p[1], buf, sizeof buf) < 0);
47 insist(errno == EBADF);
51 sprintf(buf, "%ld", LONG_MAX);
52 insist(xstrtol(&n, buf, &e, 0) == 0);
53 insist(n == LONG_MAX);
54 insist(e == buf + strlen(buf));
58 sprintf(buf, "%ld0", LONG_MAX);
59 insist(xstrtol(&n, buf, &e, 0) == ERANGE);
60 insist(n == LONG_MAX);
61 insist(e == buf + strlen(buf));
65 sprintf(buf, "%ldxyzzy", LONG_MAX);
66 insist(xstrtol(&n, buf, &e, 0) == 0);
67 insist(n == LONG_MAX);
69 check_string(e, "xyzzy");
72 /* Debian's gcc 2.95 cannot easily be persuaded to define LLONG_MAX even in
73 * extensions modes. If your compiler is this broken you just don't get the
74 * full set of tests. Deal. */
77 sprintf(buf, "%lld", LLONG_MAX);
78 insist(xstrtoll(&nn, buf, &e, 0) == 0);
79 insist(nn == LLONG_MAX);
80 insist(e == buf + strlen(buf));
84 sprintf(buf, "%lld0", LLONG_MAX);
85 insist(xstrtoll(&nn, buf, &e, 0) == ERANGE);
86 insist(nn == LLONG_MAX);
87 insist(e == buf + strlen(buf));
91 sprintf(buf, "%lldxyzzy", LLONG_MAX);
92 insist(xstrtoll(&nn, buf, &e, 0) == 0);
93 insist(nn == LLONG_MAX);
95 check_string(e, "xyzzy");