summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/input.output/file.streams/fstreams
Commit message (Collapse)AuthorAgeFilesLines
* [libc++] Set __file_ to 0 in basic_filebuf::close() even if fclose failsPetr Hosek2019-07-221-0/+56
| | | | | | | | | | | | | | | | | | | | This issue was detected by ASan in one of our tests. This test manually invokes basic_filebuf::cloe(). fclose(__h.release() returned a non-zero exit status, so __file_ wasn't set to 0. Later when basic_filebuf destructor ran, we would enter the if (__file_) block again leading to heap-use-after-free error. The POSIX specification for fclose says that independently of the return value, fclose closes the underlying file descriptor and any further access (including another call to fclose()) to the stream results in undefined behavior. This is exactly what happened in our test case. To avoid this issue, we have to always set __file_ to 0 independently of the fclose return value. Differential Revision: https://reviews.llvm.org/D64979 llvm-svn: 366730
* Add include for 'test_macros.h' to all the tests that were missing them. ↵Marshall Clow2019-05-3152-0/+73
| | | | | | Thanks to Zoe for the (big, but simple) patch. NFC intended. llvm-svn: 362252
* [libc++] Mark <filesystem> tests as failing when the dylib doesn't support ↵Louis Dionne2019-03-207-0/+7
| | | | | | | | | | | | filesystem This fixes CI for back-deployment testers on platforms that don't have <filesystem> support in the dylib. This is effectively half of https://reviews.llvm.org/D59224. The other half requires fixes in Clang. llvm-svn: 356558
* Support tests in freestandingJF Bastien2019-02-0454-54/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Freestanding is *weird*. The standard allows it to differ in a bunch of odd manners from regular C++, and the committee would like to improve that situation. I'd like to make libc++ behave better with what freestanding should be, so that it can be a tool we use in improving the standard. To do that we need to try stuff out, both with "freestanding the language mode" and "freestanding the library subset". Let's start with the super basic: run the libc++ tests in freestanding, using clang as the compiler, and see what works. The easiest hack to do this: In utils/libcxx/test/config.py add: self.cxx.compile_flags += ['-ffreestanding'] Run the tests and they all fail. Why? Because in freestanding `main` isn't special. This "not special" property has two effects: main doesn't get mangled, and main isn't allowed to omit its `return` statement. The first means main gets mangled and the linker can't create a valid executable for us to test. The second means we spew out warnings (ew) and the compiler doesn't insert the `return` we omitted, and main just falls of the end and does whatever undefined behavior (if you're luck, ud2 leading to non-zero return code). Let's start my work with the basics. This patch changes all libc++ tests to declare `main` as `int main(int, char**` so it mangles consistently (enabling us to declare another `extern "C"` main for freestanding which calls the mangled one), and adds `return 0;` to all places where it was missing. This touches 6124 files, and I apologize. The former was done with The Magic Of Sed. The later was done with a (not quite correct but decent) clang tool: https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed This works for most tests, though I did have to adjust a few places when e.g. the test runs with `-x c`, macros are used for main (such as for the filesystem tests), etc. Once this is in we can create a freestanding bot which will prevent further regressions. After that, we can start the real work of supporting C++ freestanding fairly well in libc++. <rdar://problem/47754795> Reviewers: ldionne, mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits Differential Revision: https://reviews.llvm.org/D57624 llvm-svn: 353086
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1954-216/+162
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Implement <filesystem>Eric Fiselier2018-07-277-0/+389
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements the <filesystem> header and uses that to provide <experimental/filesystem>. Unlike other standard headers, the symbols needed for <filesystem> have not yet been placed in libc++.so. Instead they live in the new libc++fs.a library. Users of filesystem are required to link this library. (Also note that libc++experimental no longer contains the definition of <experimental/filesystem>, which now requires linking libc++fs). The reason for keeping <filesystem> out of the dylib for now is that it's still somewhat experimental, and the possibility of requiring an ABI breaking change is very real. In the future the symbols will likely be moved into the dylib, or the dylib will be made to link libc++fs automagically). Note that moving the symbols out of libc++experimental may break user builds until they update to -lc++fs. This should be OK, because the experimental library provides no stability guarantees. However, I plan on looking into ways we can force libc++experimental to automagically link libc++fs. In order to use a single implementation and set of tests for <filesystem>, it has been placed in a special `__fs` namespace. This namespace is inline in C++17 onward, but not before that. As such implementation is available in C++11 onward, but no filesystem namespace is present "directly", and as such name conflicts shouldn't occur in C++11 or C++14. llvm-svn: 338093
* [libcxx] [test] Remove non-portable assertions from filebuf testsBilly Robert O'Neal III2018-04-262-10/+18
| | | | | | | | | | | seekoff.pass.cpp: libc++'s tests are asserting things about the buffer passed to pubsetbuf. [filebuf.virtuals]/12 says that what the filebuf does with the buffer you give it is completely implementation defined. The MSVC++ implementation takes that buffer and hands it off to the CRT (by calling ::setvbuf) and the CRT doesn't necessarily follow the pattern this test wants. This change simply makes asserts against the buffer's contents use LIBCPP_ASSERT instead of assert. pbackfail.pass.cpp: libc++'s tests are asserting about what characters will and will not be available in the putback area. [filebuf.virtuals]/9 says "The function can alter the number of putback positions available as a result of any call." This change LIBCPP_ASSERTS libc++'s behavior, but checks invariants of the putback area independently. llvm-svn: 330999
* Fix Windows test failures caused by identical temp file names.Eric Fiselier2017-05-074-8/+89
| | | | | | | | | | | | This patch fixes test failures that occur on Windows because the tests attempt to generate two distinct temp file names but get the same name both time. The fix for this is to create the first temp file before requesting a second temporary file name. This ensures that the second name will be unique. llvm-svn: 302382
* Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the input.output libraryEric Fiselier2017-04-188-16/+16
| | | | llvm-svn: 300626
* Fix warning caused by platforms providing a signed wint_tEric Fiselier2016-12-241-1/+2
| | | | llvm-svn: 290477
* [libcxx] [test] Change ifstream constructor tests to handle read-only files.Stephan T. Lavavej2016-12-124-24/+36
| | | | | | | | | | | | | Certain source control systems like to set the read-only bit on their files, which interferes with opening "test.dat" for both input and output. Fortunately, we can work around this without losing test coverage. Now, the ifstream.cons tests have comments referring to the ofstream.cons tests. There, we're creating writable files (not checked into source control), where the ifstream constructor tests will succeed. Fixes D26814. llvm-svn: 289463
* Enable the -Wsign-compare warning to better support MSVCEric Fiselier2016-12-111-1/+2
| | | | llvm-svn: 289363
* Move remaining _LIBCPP_VERSION tests into test/libcxxEric Fiselier2016-06-221-20/+0
| | | | llvm-svn: 273367
* [libcxx] Add appropriate 'REQUIRE' directives to tests that require en_US.UTF-8.Daniel Sanders2016-01-212-0/+4
| | | | | | | | | | Reviewers: mclow.lists, hans Subscribers: bcraig, cfe-commits Differential Revision: http://reviews.llvm.org/D16406 llvm-svn: 258403
* Add option to disable access to the global filesystem namespace.Ed Schouten2015-03-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of capability-based security on the way processes can interact with the filesystem API. It is no longer possible to interact with the VFS through calls like open(), unlink(), rename(), etc. Instead, processes are only allowed to interact with files and directories to which they have been granted access. The *at() functions can be used for this purpose. This change adds a new config switch called _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality that requires the global filesystem namespace will be disabled. More concretely: - fstream's open() function will be removed. - cstdio will no longer pull in fopen(), rename(), etc. - The test suite's get_temp_file_name() will be removed. This will cause all tests that use the global filesystem namespace to break, but will at least make all the other tests run (as get_temp_file_name will not build anyway). It is important to mention that this change will make fstream rather useless on those systems for now. Still, I'd rather not have fstream disabled entirely, as it is of course possible to come up with an extension for fstream that would allow access to local filesystem namespaces (e.g., by adding an openat() member function). Differential revision: http://reviews.llvm.org/D8194 Reviewed by: jroelofs (thanks!) llvm-svn: 232049
* Move test into test/std subdirectory.Eric Fiselier2014-12-2054-0/+2399
llvm-svn: 224658
OpenPOWER on IntegriCloud