diff options
author | Robert Mustacchi <rm@fingolfin.org> | 2020-05-20 09:37:32 -0700 |
---|---|---|
committer | Robert Mustacchi <rm@fingolfin.org> | 2020-05-22 14:08:20 -0700 |
commit | cf3ec608f736765ec9852eed5e611848a25de9a4 (patch) | |
tree | 217276bd6a22ddb4f46efa2dbb49d99a86d12183 | |
parent | 165c5c6fe7d6c7a95878c8a3aae7da65d1da1d90 (diff) | |
download | illumos-joyent-cf3ec608f736765ec9852eed5e611848a25de9a4.tar.gz |
12768 12392 regressed ftello64 behavior
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Reviewed by: John Levon <john.levon@joyent.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/lib/libc/port/stdio/ftell.c | 2 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-test-libctest.mf | 2 | ||||
-rw-r--r-- | usr/src/test/libc-tests/runfiles/default.run | 2 | ||||
-rw-r--r-- | usr/src/test/libc-tests/tests/stdio/Makefile | 18 | ||||
-rw-r--r-- | usr/src/test/libc-tests/tests/stdio/ftello_12768.c | 73 |
5 files changed, 92 insertions, 5 deletions
diff --git a/usr/src/lib/libc/port/stdio/ftell.c b/usr/src/lib/libc/port/stdio/ftell.c index dae2abea03..31aabec082 100644 --- a/usr/src/lib/libc/port/stdio/ftell.c +++ b/usr/src/lib/libc/port/stdio/ftell.c @@ -91,7 +91,7 @@ ftell_common(FILE *iop) tres += adjust; FUNLOCKFILE(lk); - return ((long)tres); + return (tres); } long diff --git a/usr/src/pkg/manifests/system-test-libctest.mf b/usr/src/pkg/manifests/system-test-libctest.mf index d7aa433d1e..67594901aa 100644 --- a/usr/src/pkg/manifests/system-test-libctest.mf +++ b/usr/src/pkg/manifests/system-test-libctest.mf @@ -162,6 +162,8 @@ file path=opt/libc-tests/tests/stdio/fmemopentest.32 mode=0555 file path=opt/libc-tests/tests/stdio/fmemopentest.64 mode=0555 file path=opt/libc-tests/tests/stdio/ftell_ungetc.32 mode=0555 file path=opt/libc-tests/tests/stdio/ftell_ungetc.64 mode=0555 +file path=opt/libc-tests/tests/stdio/ftello_12768.64 mode=0555 +file path=opt/libc-tests/tests/stdio/ftello_12768.lfs mode=0555 file path=opt/libc-tests/tests/stdio/memstream.32 mode=0555 file path=opt/libc-tests/tests/stdio/memstream.64 mode=0555 file path=opt/libc-tests/tests/stdio/memstream_reopen.32 mode=0555 diff --git a/usr/src/test/libc-tests/runfiles/default.run b/usr/src/test/libc-tests/runfiles/default.run index 6e0346c200..0af74f8780 100644 --- a/usr/src/test/libc-tests/runfiles/default.run +++ b/usr/src/test/libc-tests/runfiles/default.run @@ -68,6 +68,8 @@ timeout = 600 [/opt/libc-tests/tests/stdio/fmemopentest.64] [/opt/libc-tests/tests/stdio/ftell_ungetc.32] [/opt/libc-tests/tests/stdio/ftell_ungetc.64] +[/opt/libc-tests/tests/stdio/ftello_12768.lfs] +[/opt/libc-tests/tests/stdio/ftello_12768.64] [/opt/libc-tests/tests/stdio/memstream.32] [/opt/libc-tests/tests/stdio/memstream.64] [/opt/libc-tests/tests/stdio/memstream_reopen.32] diff --git a/usr/src/test/libc-tests/tests/stdio/Makefile b/usr/src/test/libc-tests/tests/stdio/Makefile index b94c42df30..092d62bc60 100644 --- a/usr/src/test/libc-tests/tests/stdio/Makefile +++ b/usr/src/test/libc-tests/tests/stdio/Makefile @@ -23,17 +23,23 @@ PROGS = \ orientation_test \ test_mbrtowc +LFSPROGS = \ + ftello_12768 + PROGS32 = $(PROGS:%=%.32) -PROGS64 = $(PROGS:%=%.64) +PROGSLFS = $(LFSPROGS:%=%.lfs) +PROGS64 = $(PROGS:%=%.64) $(LFSPROGS:%=%.64) ROOTOPTDIR = $(ROOT)/opt/libc-tests/tests ROOTOPTSTDIO = $(ROOTOPTDIR)/stdio ROOTOPTPROGS = $(PROGS32:%=$(ROOTOPTSTDIO)/%) \ - $(PROGS64:%=$(ROOTOPTSTDIO)/%) + $(PROGS64:%=$(ROOTOPTSTDIO)/%) \ + $(PROGSLFS:%=$(ROOTOPTSTDIO)/%) include $(SRC)/cmd/Makefile.cmd CPPFLAGS += -D_REENTRANT -D__EXTENSIONS__ +LFSCPPFLAGS = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 # # libumem is used to interpose on all of these tests to modify the @@ -58,10 +64,10 @@ orientation_test.64 := SMOFF += all_func_returns .KEEP_STATE: -install: $(ROOTOPTPROGS) - all: $(PROGS32) $(PROGS64) +install: $(ROOTOPTPROGS) + clean: $(ROOTOPTPROGS): $(PROGS32) $(PROGS64) $(ROOTOPTSTDIO) @@ -79,6 +85,10 @@ $(ROOTOPTSTDIO)/%: % $(LINK64.c) -o $@ $< $(LDLIBS64) $(POST_PROCESS) +%.lfs: %.c + $(LINK.c) $(LFSCPPFLAGS) -o $@ $< $(LDLIBS) + $(POST_PROCESS) + %.32: %.c $(LINK.c) -o $@ $< $(LDLIBS) $(POST_PROCESS) diff --git a/usr/src/test/libc-tests/tests/stdio/ftello_12768.c b/usr/src/test/libc-tests/tests/stdio/ftello_12768.c new file mode 100644 index 0000000000..014f207876 --- /dev/null +++ b/usr/src/test/libc-tests/tests/stdio/ftello_12768.c @@ -0,0 +1,73 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2020 Oxide Computer Company + */ + +/* + * Regression test for 12768 '12392 regressed ftello64 behavior'. The heart of + * the problem was a bad cast that resulted in us not properly transmitting that + * size. + */ + +#include <stdio.h> +#include <err.h> +#include <stdlib.h> +#include <sys/sysmacros.h> + +int +main(void) +{ + FILE *f; + size_t i; + int ret = EXIT_SUCCESS; + static off_t offsets[] = { + 23, + 0xa0000, /* 64 KiB */ + 0x100000, /* 1 MiB */ + 0x7fffffffULL, /* 2 GiB - 1 */ + 0xc0000000ULL, /* 3 GiB */ + 0x200005432ULL /* 8 GiB + misc */ + }; + + f = tmpfile(); + if (f == NULL) { + err(EXIT_FAILURE, "TEST FAILED: failed to create " + "temporary file"); + } + + for (i = 0; i < ARRAY_SIZE(offsets); i++) { + off_t ftret; + + if (fseeko(f, offsets[i], SEEK_SET) != 0) { + warn("TEST FAILED: failed to seek to %lld", + (long long)offsets[i]); + ret = EXIT_FAILURE; + } + + ftret = ftello(f); + if (ftret == -1) { + warn("TEST FAILED: failed to get stream position at " + "%lld", (long long)offsets[i]); + ret = EXIT_FAILURE; + } + + if (ftret != offsets[i]) { + warnx("TEST FAILED: stream position mismatch: expected " + "%lld, found %lld", (long long)offsets[i], + (long long)ftret); + ret = EXIT_FAILURE; + } + } + + return (ret); +} |