diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-01-19 01:35:28 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-01-19 01:35:28 +0000 |
commit | 01715b0337fb0a0d94eb605d93c5e91e116179b5 (patch) | |
tree | 0301863b66ab68d0bba95f85285aefc936d959ac | |
parent | a815c3ab359e99edc5d44934a0d00467a9a16bad (diff) | |
download | glibc-01715b0337fb0a0d94eb605d93c5e91e116179b5.tar.gz glibc-01715b0337fb0a0d94eb605d93c5e91e116179b5.tar.xz glibc-01715b0337fb0a0d94eb605d93c5e91e116179b5.zip |
[BZ #2173]
2006-01-18 Ulrich Drepper <drepper@redhat.com> [BZ #2173] * libio/fileops.c (_IO_new_file_fopen): If ,ccs= is given, also set vtable to the wide vtable. * libio/tst-fopenloc2.c: New file. * libio/Makefile (tests): Add tst-fopenloc2. * sysdeps/unix/sysv/linux/shm_open.c [__ASSUME_TMPFS_NAME]
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | libio/Makefile | 2 | ||||
-rw-r--r-- | libio/tst-fopenloc2.c | 116 |
3 files changed, 126 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index aea5524dbb..286c1270a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-01-18 Ulrich Drepper <drepper@redhat.com> + + [BZ #2173] + * libio/fileops.c (_IO_new_file_fopen): If ,ccs= is given, also + set vtable to the wide vtable. + * libio/tst-fopenloc2.c: New file. + * libio/Makefile (tests): Add tst-fopenloc2. + 2006-01-18 Roland McGrath <roland@redhat.com> * sysdeps/ieee754/ldbl-opt/nldbl-dprintf.c: Restore @@ -42,7 +50,7 @@ * sysdeps/unix/sysv/linux/kernel-features.h: Define __ASSUME_TMPFS_NAME. - * sysdeps/unix/sysv/linux/shm_open.c [!__ASSUME_TMPFS_NAME] + * sysdeps/unix/sysv/linux/shm_open.c [__ASSUME_TMPFS_NAME] (where_is_shmfs): Don't test for obsolete shm filesystem name. * sysdeps/unix/sysv/linux/getsysstats.c: Don't search for proc diff --git a/libio/Makefile b/libio/Makefile index 4437872984..e9c1d522fd 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -54,7 +54,7 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \ tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \ tst-mmap2-eofsync tst-mmap-offend bug-fopena+ bug-wfflush \ - bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 \ + bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \ tst-memstream1 tst-memstream2 \ tst-wmemstream1 tst-wmemstream2 test-srcs = test-freopen diff --git a/libio/tst-fopenloc2.c b/libio/tst-fopenloc2.c new file mode 100644 index 0000000000..5ddd63446b --- /dev/null +++ b/libio/tst-fopenloc2.c @@ -0,0 +1,116 @@ +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <wchar.h> + + +static const struct +{ + const char *enc; + const char *data; + size_t datalen; + const wchar_t *expected; + size_t expectedlen; +} tests[] = + { + { "UCS-4LE", "a\0\0\0b\0\0\0", 8, L"ab", 2 }, + { "UCS-4BE", "\0\0\0a\0\0\0b", 8, L"ab", 2 }, + }; +#define ntests (sizeof (tests) / sizeof (tests[0])) + + +static int do_test (void); +#define TEST_FUNCTION do_test () + +static void prepare (void); +#define PREPARE(argc, argv) prepare (); + +#include "../test-skeleton.c" + + +static int fd; +static char *tmpname; + + +static void +prepare (void) +{ + fd = create_temp_file ("tst-fopenloc2", &tmpname); + if (fd == -1) + { + puts ("cannot open temp file"); + exit (1); + } +} + + +static int +do_test (void) +{ + for (int i = 0; i < ntests; ++i) + { + if (ftruncate (fd, 0) != 0) + { + printf ("ftruncate in round %d failed\n", i + 1); + return 1; + } + + if (TEMP_FAILURE_RETRY (write (fd, tests[i].data, tests[i].datalen)) + != tests[i].datalen) + { + printf ("write in round %d failed\n", i + 1); + return 1; + } + + if (lseek (fd, 0, SEEK_SET) != 0) + { + printf ("lseek in round %d failed\n", i + 1); + return 1; + } + + char *ccs; + if (asprintf (&ccs, "r,ccs=%s", tests[i].enc) == -1) + { + printf ("asprintf in round %d failed\n", i + 1); + return 1; + } + + FILE *fp = fopen (tmpname, ccs); + if (fp == NULL) + { + printf ("fopen in round %d failed\n", i + 1); + return 1; + } + +#define LINELEN 100 + wchar_t line[LINELEN]; + if (fgetws (line, LINELEN, fp) != line) + { + printf ("fgetws in round %d failed\n", i + 1); + return 1; + } + + if (wcslen (line) != tests[i].expectedlen) + { + printf ("round %d: expected length %zu, got length %zu\n", + i + 1, tests[i].expectedlen, wcslen (line)); + return 1; + } + + if (wcscmp (tests[i].expected, line) != 0) + { + printf ("round %d: expected L\"%ls\", got L\"%ls\"\n", + i + 1, tests[i].expected, line); + return 1; + } + + fclose (fp); + + free (ccs); + } + + close (fd); + + return 0; +} |