]>
Commit | Line | Data |
---|---|---|
28f540f4 RM |
1 | #include <stdio.h> |
2 | #include <string.h> | |
3 | ||
8c4f69d7 FB |
4 | #include <support/support.h> |
5 | ||
c1f41083 AS |
6 | static int |
7 | do_test (void) | |
28f540f4 RM |
8 | { |
9 | FILE *f = tmpfile (); | |
10 | char obuf[99999], ibuf[sizeof obuf]; | |
11 | char *line; | |
12 | size_t linesz; | |
13 | ||
14 | if (! f) | |
15 | { | |
16 | perror ("tmpfile"); | |
17 | return 1; | |
18 | } | |
19 | ||
20 | if (fputs ("line\n", f) == EOF) | |
21 | { | |
22 | perror ("fputs"); | |
23 | return 1; | |
24 | } | |
25 | ||
26 | memset (obuf, 'z', sizeof obuf); | |
27 | memset (ibuf, 'y', sizeof ibuf); | |
11336c16 | 28 | |
28f540f4 RM |
29 | if (fwrite (obuf, sizeof obuf, 1, f) != 1) |
30 | { | |
31 | perror ("fwrite"); | |
32 | return 1; | |
33 | } | |
34 | ||
35 | rewind (f); | |
36 | ||
37 | line = NULL; | |
38 | linesz = 0; | |
39 | if (getline (&line, &linesz, f) != 5) | |
40 | { | |
41 | perror ("getline"); | |
42 | return 1; | |
43 | } | |
44 | if (strcmp (line, "line\n")) | |
45 | { | |
46 | puts ("Lines differ. Test FAILED!"); | |
47 | return 1; | |
48 | } | |
49 | ||
50 | if (fread (ibuf, sizeof ibuf, 1, f) != 1) | |
51 | { | |
52 | perror ("fread"); | |
53 | return 1; | |
54 | } | |
55 | ||
56 | if (memcmp (ibuf, obuf, sizeof ibuf)) | |
57 | { | |
58 | puts ("Buffers differ. Test FAILED!"); | |
59 | return 1; | |
60 | } | |
61 | ||
8c4f69d7 | 62 | line = xasprintf ("\ |
28f540f4 RM |
63 | GDB is free software and you are welcome to distribute copies of it\n\ |
64 | under certain conditions; type \"show copying\" to see the conditions.\n\ | |
65 | There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\ | |
66 | "); | |
67 | ||
68 | puts ("Test succeeded."); | |
69 | return 0; | |
70 | } | |
c1f41083 AS |
71 | |
72 | #define TEST_FUNCTION do_test () | |
73 | #include "../test-skeleton.c" |