summaryrefslogtreecommitdiff
path: root/login
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-19 00:21:23 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-19 00:21:23 +0000
commit9cddf9deda4c6ac0339d3aa4be3cceef4d8e9b6a (patch)
tree86e4e74103036dfd33acf4b0a91f20b137371d76 /login
parent46089c83d119050998387d7a8fb896514c92618b (diff)
Update.
2001-12-18 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (clone): Subtract stack bias from child stack pointer before passing it to clone syscall. 2001-12-18 Ulrich Drepper <drepper@redhat.com> * sysdeps/posix/sysconf.c (__sysconf): Respect POSIX minimum for _SC_TZNAME_MAX. * sysdeps/generic/sysconf.c (__sysconf): Likewise. Reported by Thorsten Kukuk <kukuk@suse.de>. * sysdeps/unix/grantpt.c (grantpt): Correct typo in comment and add some casts. * sysdeps/unix/sysv/linux/grantpt.c: Make __unix_grantpt static. 2001-12-18 Thorsten Kukuk <kukuk@suse.de> * sysdeps/unix/sysv/linux/grantpt.c: Make errno results standard conforming: return EBADF if file descriptor is invalid and EINVAL if file descriptor is no valid tty. * login/tst-grantpt.c: New file. * login/Makefile (tests): Add tst-grantpt.
Diffstat (limited to 'login')
-rw-r--r--login/Makefile2
-rw-r--r--login/tst-grantpt.c78
2 files changed, 79 insertions, 1 deletions
diff --git a/login/Makefile b/login/Makefile
index b1fd3055e7..97fab761f3 100644
--- a/login/Makefile
+++ b/login/Makefile
@@ -37,7 +37,7 @@ distribute := utmp-private.h pty-private.h
subdir-dirs = programs
vpath %.c programs
-tests := tst-utmp tst-utmpx
+tests := tst-utmp tst-utmpx tst-grantpt
# Build the -lutil library with these extra functions.
extra-libs := libutil
diff --git a/login/tst-grantpt.c b/login/tst-grantpt.c
new file mode 100644
index 0000000000..9b993daaca
--- /dev/null
+++ b/login/tst-grantpt.c
@@ -0,0 +1,78 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+static int
+test_ebadf (void)
+{
+ int fd, ret, err;
+
+ fd = posix_openpt (O_RDWR);
+ if (fd == -1)
+ {
+ printf ("posix_openpt(O_RDWR) failed\nerrno %d (%s)\n",
+ errno, strerror (errno));
+ /* We don't fail because of this; maybe the system does not have
+ SUS pseudo terminals. */
+ return 0;
+ }
+ unlockpt (fd);
+ close (fd);
+
+ ret = grantpt (fd);
+ err = errno;
+ if (ret != -1 || err != EBADF)
+ {
+ printf ("grantpt(): expected: return = %d, errno = %d\n", -1, EBADF);
+ printf (" got: return = %d, errno = %d\n", ret, err);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+test_einval (void)
+{
+ int fd, ret, err;
+ const char file[] = "./grantpt-einval";
+
+ fd = open (file, O_RDWR | O_CREAT);
+ if (fd == -1)
+ {
+ printf ("open(\"%s\", O_RDWR) failed\nerrno %d (%s)\n",
+ file, errno, strerror (errno));
+ return 0;
+ }
+ unlink (file);
+
+ ret = grantpt (fd);
+ err = errno;
+ if (ret != -1 || err != EINVAL)
+ {
+ printf ("grantpt(): expected: return = %d, errno = %d\n", -1, EINVAL);
+ printf (" got: return = %d, errno = %d\n", ret, err);
+ ret = 1;
+ }
+ else
+ ret = 0;
+
+ close (fd);
+
+ return ret;
+}
+
+int
+main (void)
+{
+ int result = 0;
+
+ result += test_ebadf ();
+ result += test_einval ();
+
+ return result;
+}