Mercurial > hg > octave-lojdl > gnulib-hg
annotate tests/test-posix_openpt.c @ 16465:c0803728f645
New module 'modfl-ieee'.
* modules/modfl-ieee: New file.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 26 Feb 2012 17:55:31 +0100 |
parents | 8250f2777afc |
children | 498a2211d839 |
rev | line source |
---|---|
15961 | 1 /* Test of posix_openpt function. |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
15975
diff
changeset
|
2 Copyright (C) 2011-2012 Free Software Foundation, Inc. |
15961 | 3 |
4 This program is free software: you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 3 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
16 | |
17 /* Written by Eric Blake <eblake@redhat.com>, 2011. */ | |
18 | |
19 #include <config.h> | |
20 | |
21 #include <stdlib.h> | |
22 | |
23 #include "signature.h" | |
24 SIGNATURE_CHECK (posix_openpt, int, (int)); | |
25 | |
26 #include <errno.h> | |
27 #include <fcntl.h> | |
28 #include <stdio.h> | |
29 #include <unistd.h> | |
30 | |
31 #if defined __sun || defined __hpux /* Solaris, HP-UX */ | |
32 # include <stropts.h> | |
33 #endif | |
34 | |
35 #include "macros.h" | |
36 | |
37 int | |
38 main (void) | |
39 { | |
40 int master; | |
41 int slave; | |
42 char *name; | |
43 | |
44 /* Open the master of a pseudo-terminal pair. */ | |
15975
ede627d300ff
posix_openpt test: Coding style.
Bruno Haible <bruno@clisp.org>
parents:
15961
diff
changeset
|
45 master = posix_openpt (O_RDWR | O_NOCTTY); |
15961 | 46 if (master < 0 && errno == ENOSYS) |
47 { | |
48 fputs ("skipping: platform lacks pty support\n", stderr); | |
49 return 77; | |
50 } | |
51 | |
52 ASSERT (0 <= master); | |
53 name = ptsname (master); | |
54 ASSERT (name); | |
55 ASSERT (grantpt (master) == 0); | |
56 ASSERT (unlockpt (master) == 0); | |
57 slave = open (name, O_RDWR); | |
58 ASSERT (0 <= slave); | |
59 | |
60 #if defined __sun || defined __hpux /* Solaris, HP-UX */ | |
61 ASSERT (ioctl (slave, I_PUSH, "ptem") == 0); | |
62 ASSERT (ioctl (slave, I_PUSH, "ldterm") == 0); | |
63 # if defined __sun | |
64 ASSERT (ioctl (slave, I_PUSH, "ttcompat") == 0); | |
65 # endif | |
66 #endif | |
67 | |
68 ASSERT (isatty (slave)); | |
69 | |
70 /* Close the master side before the slave side gets closed. | |
71 This is necessary on MacOS X 10.4.11. */ | |
72 ASSERT (close (master) == 0); | |
73 ASSERT (close (slave) == 0); | |
74 | |
75 return 0; | |
76 } |