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 void test_syscalls(void) {
28 printf("test_syscalls\n");
32 memset(buf
, 99, sizeof buf
);
34 while(write(p
[1], buf
, sizeof buf
) > 0)
36 insist(errno
== EAGAIN
);
37 memset(buf
, 0, sizeof buf
);
38 insist(read(p
[0], buf
, sizeof buf
) == sizeof buf
);
40 insist(buf
[(sizeof buf
) - 1] == 99);
45 insist(read(p
[0], buf
, sizeof buf
) < 0);
46 insist(errno
== EBADF
);
48 insist(write(p
[1], buf
, sizeof buf
) < 0);
49 insist(errno
== EBADF
);
53 sprintf(buf
, "%ld", LONG_MAX
);
54 insist(xstrtol(&n
, buf
, &e
, 0) == 0);
55 insist(n
== LONG_MAX
);
56 insist(e
== buf
+ strlen(buf
));
60 sprintf(buf
, "%ld0", LONG_MAX
);
61 insist(xstrtol(&n
, buf
, &e
, 0) == ERANGE
);
62 insist(n
== LONG_MAX
);
63 insist(e
== buf
+ strlen(buf
));
67 sprintf(buf
, "%ldxyzzy", LONG_MAX
);
68 insist(xstrtol(&n
, buf
, &e
, 0) == 0);
69 insist(n
== LONG_MAX
);
71 check_string(e
, "xyzzy");
74 /* Debian's gcc 2.95 cannot easily be persuaded to define LLONG_MAX even in
75 * extensions modes. If your compiler is this broken you just don't get the
76 * full set of tests. Deal. */
79 sprintf(buf
, "%lld", LLONG_MAX
);
80 insist(xstrtoll(&nn
, buf
, &e
, 0) == 0);
81 insist(nn
== LLONG_MAX
);
82 insist(e
== buf
+ strlen(buf
));
86 sprintf(buf
, "%lld0", LLONG_MAX
);
87 insist(xstrtoll(&nn
, buf
, &e
, 0) == ERANGE
);
88 insist(nn
== LLONG_MAX
);
89 insist(e
== buf
+ strlen(buf
));
93 sprintf(buf
, "%lldxyzzy", LLONG_MAX
);
94 insist(xstrtoll(&nn
, buf
, &e
, 0) == 0);
95 insist(nn
== LLONG_MAX
);
97 check_string(e
, "xyzzy");