summaryrefslogtreecommitdiffstats
path: root/llvm/utils/unittest
Commit message (Collapse)AuthorAgeFilesLines
* [unittests] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-04-071-1/+1
| | | | | | | | | | | | | | | r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches. llvm-svn: 329475
* Revert r326092: [gtest] Add PrintTo overload for StringRef.Ilya Biryukov2018-02-261-13/+0
| | | | | | | | | It seems to break the following buildbot: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/24729 Will resubmit after investigating and fixing it. llvm-svn: 326096
* [gtest] Add PrintTo overload for StringRef.Ilya Biryukov2018-02-261-0/+13
| | | | | | | | | | | | | | | | Summary: It was printed using code for generic containers before, resulting in unreadable output. Reviewers: sammccall, labath Reviewed By: sammccall, labath Subscribers: labath, zturner, llvm-commits Differential Revision: https://reviews.llvm.org/D43330 llvm-svn: 326092
* [gtest] Support raw_ostream printing functions more comprehensively.Sam McCall2018-02-123-41/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: These are functions like operator<<(raw_ostream&, Foo). Previously these were only supported for messages. In the assertion EXPECT_EQ(A, B) << C; the local modifications would explicitly try to use raw_ostream printing for C. However A and B would look for a std::ostream printing function, and often fall back to gtest's default "168 byte object <00 01 FE 42 ...>". This patch pulls out the raw_ostream support into a new header under `custom/`. I changed the mechanism: instead of a convertible stream, we wrap the printed value in a proxy object to allow it to be sent to a std::ostream. I think the new way is clearer. I also changed the policy: we prefer raw_ostream printers over std::ostream ones. This is because the fallback printers are defined using std::ostream, while all the raw_ostream printers should be "good". Reviewers: ilya-biryukov, chandlerc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43091 llvm-svn: 324876
* [NFC] fix trivial typos in comments and documentsHiroshi Inoue2018-01-291-1/+1
| | | | | | "to to" -> "to" llvm-svn: 323628
* Fix typos of occurred and occurrenceMalcolm Parsons2018-01-242-2/+2
| | | | llvm-svn: 323318
* Force #define GTEST_LANG_CXX11.Zachary Turner2017-10-271-0/+5
| | | | | | | | | | | | | | | | | | gtest depends on this #define to determine whether it can use various classes like std::tuple, or whether it has to fall back to experimental classes in the std::tr1 namespace. The check in the current version of gtest relies on the value of the `__cplusplus` macro, but MSVC provides a non-conformant value of this macro, making it effectively impossible to detect C++11. In short, LLVM compiled with MSVC has been silently using the tr1 versions of several classes since the beginning of time. This would normally be pretty benign, except that in the latest preview of MSVC they have marked all of the tr1 classes deprecated, so it spews thousands of warnings. llvm-svn: 316798
* Note addition of NetBSD support in googletestKamil Rytarowski2017-05-061-1/+1
| | | | | | Recreated patch for __NetBSD__ has been pushed upstream to Google. llvm-svn: 302329
* Add NetBSD to the list of platforms supporting death tests. Two unitJoerg Sonnenberger2017-05-052-1/+3
| | | | | | tests require this for compilation. llvm-svn: 302264
* [CMake] Fix pthread handling for out-of-tree buildsEric Fiselier2017-02-101-2/+2
| | | | | | | | | | | | | | | LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects to correctly link the threading library when needed. Unfortunately `PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed and therefore can't be used when configuring out-of-tree builds. This causes such builds to fail since `pthread` isn't being correctly linked. This patch attempts to fix that problem by renaming and exporting `LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB` because It seemed likely to cause collisions with downstream users of `LLVMConfig.cmake`. llvm-svn: 294690
* [gmock] Teach gmock ElementsAre and BeginEndDistanceIs matchers toChandler Carruth2017-01-111-12/+28
| | | | | | | | | | | | | | | | | | handle generic ranges by using std::begin and std::end rather than requiring things to look exactly like an STL container. Much of the credit for this goes to Dave Blaikie who helped me figure out the right incantations. This will probably be re-designed when I send this to the maintainers of gmock, so I've instead structured it to change is little as possible while it is a local patch. That makes it somewhat ugly, but I think a focused change is better for getting this to work for LLVM today and letting the upstream maintainers figure out the correct long-term pattern. Differential Revision: https://reviews.llvm.org/D28288 llvm-svn: 291623
* Add the 'googlemock' component of Google Test to LLVM's unittest libraries.Chandler Carruth2017-01-1027-2/+16952
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I have two immediate motivations for adding this: 1) It makes writing expectations in tests *dramatically* easier. A quick example that is a taste of what is possible: std::vector<int> v = ...; EXPECT_THAT(v, UnorderedElementsAre(1, 2, 3)); This checks that v contains '1', '2', and '3' in some order. There are a wealth of other helpful matchers like this. They tend to be highly generic and STL-friendly so they will in almost all cases work out of the box even on custom LLVM data structures. I actually find the matcher syntax substantially easier to read even for simple assertions: EXPECT_THAT(a, Eq(b)); EXPECT_THAT(b, Ne(c)); Both of these make it clear what is being *tested* and what is being *expected*. With `EXPECT_EQ` this is implicit (the LHS is expected, the RHS is tested) and often confusing. With `EXPECT_NE` it is just not clear. Even the failure error messages are superior with the matcher based expectations. 2) When testing any kind of generic code, you are continually defining dummy types with interfaces and then trying to check that the interfaces are manipulated in a particular way. This is actually what mocks are *good* for -- testing *interface interactions*. With generic code, there is often no "fake" or other object that can be used. For a concrete example of where this is currently causing significant pain, look at the pass manager unittests which are riddled with counters incremented when methods are called. All of these could be replaced with mocks. The result would be more effective at testing the code by having tighter constraints. It would be substantially more readable and maintainable when updating the code. And the error messages on failure would have substantially more information as mocks automatically record stack traces and other information *when the API is misused* instead of trying to diagnose it after the fact. I expect that #1 will be the overwhelming majority of the uses of gmock, but I think that is sufficient to justify having it. I would actually like to update the coding standards to encourage the use of matchers rather than any other form of `EXPECT_...` macros as they are IMO a strict superset in terms of functionality and readability. I think that #2 is relatively rarely useful, but there *are* cases where it is useful. Historically, I think misuse of actual mocking as described in #2 has led to resistance towards this framework. I am actually sympathetic to this -- mocking can easily be overused. However I think this is not a significant concern in LLVM. First and foremost, LLVM has very careful and rare exposure of abstract interfaces or dependency injection, which are the most prone to abuse with mocks. So there are few opportunities to abuse them. Second, a large fraction of LLVM's unittests are testing *generic code* where mocks actually make tremendous sense. And gmock is well suited to building interfaces that exercise generic libraries. Finally, I still think we should be willing to have testing utilities in tree even if they should be used rarely. We can use code review to help guide the usage here. For a longer and more complete discussion of this, see the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2017-January/108672.html The general consensus seems that this is a reasonable direction to start down, but that doesn't mean we should race ahead and use this everywhere. I have one test that is blocked on this to land and that was specifically used as an example. Before widespread adoption, I'm going to work up some (brief) guidelines as some of these facilities should be used sparingly and carefully. Differential Revision: https://reviews.llvm.org/D28156 llvm-svn: 291606
* [gtest] Detect warning flags using the positive spelling.Chandler Carruth2017-01-061-2/+2
| | | | | | | | | | | | | | | | | | | | | Some GCC versions will accept any warning flag name after a '-Wno-', which would cause us to try to disable warnings with names GCC didn't understand. This will silently succeed unless there is some other output from GCC in which case we get weird cc1plus warnings about the warning name being bogus. There is still the issue that gtest sets warning flags for building gtest-all.cc using weird 'add_definitions' and the fact that there is a GCC version which warns on the variadic macro usage in gtest under -pedantic, but has no flag analogous to Clang's -Wgnu-zero-variadic-macro-argumnets to suppress this warning. I haven't been able to come up with any good solution here. The closest is to turn off -pedantic for those versions of GCC, but that seems really nasty. For now, those versinos of GCC aren't warning clean. If anyone is broken by this, I'll work on CMake logic to detect and disable -pedantic in these cases. llvm-svn: 291299
* [gtest] Work around broken installs of libc++ where we don't haveChandler Carruth2017-01-051-1/+7
| | | | | | | | | | | | | | | | | | | a cxxabi.h in the include search paths. This comes up when libc++ is installed with some other abi library. At some points in time in history we have had CMake hackery to try and get a cxxabi.h installed that would work, but there are lots of examples lacking this. Also, the just-built tree with libc++ seems to not quite get this right. To let folks make progress, we can easily work around this by detecting that the header is missing and disabling the relevant parts of gtest. This should fix the last remainging build bot failures. While these failures are typically indicative of a questionable install, I don't think gtest should be the thing that surfaces those issues and I don't want folks blocked on this. llvm-svn: 291063
* Patch gtest to move GTEST_IS_THREADSAFE out of unrelated GTEST_HAS_SEH ifdefReid Kleckner2017-01-051-2/+2
| | | | | | | Fixes the sanitizer Windows build, which happens to set -DGTEST_HAS_SEH=0. llvm-svn: 291038
* [gtest] Upgrade googletest to version 1.8.0, minimizing local changes.Chandler Carruth2017-01-0433-2461/+5437
| | | | | | | | | This required re-working the streaming support and lit's support for '--gtest_list_tests' but otherwise seems to be a clean upgrade. Differential Revision: https://reviews.llvm.org/D28154 llvm-svn: 291029
* [cmake] Export gtest/gtest_main and its dependencies via a special build ↵Michael Gottesman2016-09-092-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tree only cmake exports file. Previously, gtest/gtest_main were not exported via cmake. The intention here was to ensure that users whom are linking against the LLVM install tree would not get the gtest/gtest_main targets. This prevents downstream projects that link against the LLVM build tree (i.e. Swift) from getting this dependency information in their cmake builds. Without such dependency information, linker issues can result on linux due to LLVMSupport being put before gtest on the linker command line. This commit preserves behavior that we want for the install tree, while adding support for the build tree by: 1. The special casing for gtest/gtest_main in the add_llvm_library code is removed in favor of a flag called "BUILDTREE_ONLY". If this is set, then the library is communicating that it is only meant to be exported into the build tree and is not meant to be installed or exported via the install tree. This part is just a tweak to remove the special case, the underlying code is the same. 2. The cmake code that exports cmake targets for the build tree has special code to import an additional targets file called LLVMBuildTreeOnlyExports.cmake. Additionally the extra targets are added to the LLVMConfig.cmake's LLVM_EXPORTED_TARGETS variable. In contrast, the "installation" cmake file uses the normal LLVM_EXPORTS_TARGETS as before and does not include the extra exports file. This is implemented by defining/undefining variables when performing a configure of the build/install tree LLVMConfig.cmake files. llvm-svn: 281085
* Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith2016-06-091-1/+2
| | | | | | | looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
* Avoid linking LLVM component libraries with libLLVMAndrew Wilkins2016-02-122-5/+6
| | | | | | | | | | | Patch by Jack Howarth. When linking to libLLVM, don't also link to the component libraries that constitute libLLVM. Differential Revision: http://reviews.llvm.org/D16945 llvm-svn: 260641
* Remove autoconf supportChris Bieneman2016-01-263-87/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 llvm-svn: 258861
* Fix undefined behavior in llvm's local changes to googletest.Nico Weber2016-01-192-1/+5
| | | | | | | | | r100895 landed an llvm-only change to add minix support to googletest. It did that by putting "defined()" in a macro, which has undefined behavior. Slightly reshuffle things to remove that undefined behavior. Also mention in README.LLVM that minix support is a local change. llvm-svn: 258190
* Reordering fields to reduce padding in LLVM. NFCBen Craig2015-12-141-24/+28
| | | | llvm-svn: 255554
* Rename all references to old mailing lists to new lists.llvm.org address.Tanya Lattner2015-08-051-1/+1
| | | | llvm-svn: 243999
* Make UnitTestMain/TestMain.cpp free from llvm/Config/config.h.NAKAMURA Takumi2015-07-061-3/+2
| | | | | | llvm/Config/config.h is unavailable outside of build tree. llvm-svn: 241523
* Revert r240271 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko2015-06-231-1/+1
| | | | llvm-svn: 240393
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | A few more files that were fixed while preparing r240270. llvm-svn: 240271
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-1110-86/+91
| | | | | | | | | | | | | | The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' \ -j=32 -fix -format http://reviews.llvm.org/D8925 llvm-svn: 234679
* Add boolean to PrintStackTraceOnErrorSignal to disable crash reporting.Pete Cooper2015-04-071-1/+1
| | | | | | | | | | | | | | | | | | | The current crash reporting on Mac OS is only disabled via an environment variable. This adds a boolean (default false) which can also disable crash reporting. The only client right now is the unittests which don't ever want crash reporting, but do want to detect killed programs. Reduces the time to run the APFloat unittests on my machine from [----------] 47 tests from APFloatTest (51250 ms total) to [----------] 47 tests from APFloatTest (765 ms total) Reviewed by Reid Kleckner and Justin Bogner llvm-svn: 234353
* Fix a grammar issue I introduced.Chandler Carruth2015-03-111-1/+1
| | | | llvm-svn: 231894
* Inspired by r231891, use gender neutral pronouns in the places I'veChandler Carruth2015-03-112-2/+2
| | | | | | found in LLVM. llvm-svn: 231893
* Avoid explicitly declaring the copy assignment operator, as this ↵David Blaikie2015-03-031-3/+0
| | | | | | unnecessarily makes the copy ctor deprecated in C++11 llvm-svn: 231095
* Reapply r229185(cbieneman) -- Raising minimum required Visual Studio version ↵NAKAMURA Takumi2015-02-151-6/+0
| | | | | | | | to 2013. This is based on the discussions on: [LLVMdev] [RFC] Raising LLVM minimum required MSVC version to 2013 for trunk llvm-svn: 229320
* Revert r229185, "Raising minimum required Visual Studio version to 2013."NAKAMURA Takumi2015-02-141-0/+6
| | | | | | All builders are not ready yet. llvm-svn: 229199
* Raising minimum required Visual Studio version to 2013.Chris Bieneman2015-02-131-6/+0
| | | | | | This is based on the discussions on: [LLVMdev] [RFC] Raising LLVM minimum required MSVC version to 2013 for trunk llvm-svn: 229185
* Use -Wl,defs when linking.Rafael Espindola2015-01-201-2/+11
| | | | | | | | | | | | | | | ELF linkers by default allow shared libraries to contain undefined references and it is up to the dynamic linker to look for them. On COFF and MachO, that is not the case. This creates a situation where a .so might build on an ELF system, but the build of the corresponding .dylib or .dll will fail. This patch changes the cmake build to use -Wl,-z,defs when linking and updates the dependencies so that -DBUILD_SHARED_LIBS=ON build still works. llvm-svn: 226611
* Reverted r203879.Galina Kistanova2014-03-141-1/+1
| | | | llvm-svn: 203880
* Fixed misuse of isascii. Also fixes mingw32 build, see ↵Galina Kistanova2014-03-141-1/+1
| | | | | | http://msdn.microsoft.com/en-us/library/ms235417.aspx llvm-svn: 203879
* [CMake] Use LINK_LIBS instead of target_link_libraries().NAKAMURA Takumi2014-02-262-8/+4
| | | | llvm-svn: 202238
* Support GTest for FreeBSD platforms (9.x)Alexey Samsonov2014-02-192-2/+8
| | | | | | Patch by Viktor Kutuzov! llvm-svn: 201683
* [CMake] Add dependencies to gtest.NAKAMURA Takumi2014-02-102-0/+11
| | | | llvm-svn: 201079
* Comment out unused macro because of warningRenato Golin2014-01-301-0/+3
| | | | | | | | Modern compilers (Clang 3.4, GCC 4.8) warn on variadic macros being introduced in C99, which produces a huge number of useless diagnostics since this macro is unused in the whole project. llvm-svn: 200479
* Sink add_llvm_library(gtest_main) to UnitTestMain/CMakeLists.txt.NAKAMURA Takumi2014-01-102-3/+4
| | | | llvm-svn: 198933
* [weak vtables] Remove a bunch of weak vtablesJuergen Ributzka2013-11-1910-10/+42
| | | | | | | | | | | | This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. The memory leaks in this version have been fixed. Thanks Alexey for pointing them out. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy llvm-svn: 195064
* Unbreak the build after r194997Alexey Samsonov2013-11-181-2/+0
| | | | llvm-svn: 194998
* Revert r194865 and r194874.Alexey Samsonov2013-11-1810-35/+10
| | | | | | | | | | | | This change is incorrect. If you delete virtual destructor of both a base class and a subclass, then the following code: Base *foo = new Child(); delete foo; will not cause the destructor for members of Child class. As a result, I observe plently of memory leaks. Notable examples I investigated are: ObjectBuffer and ObjectBufferStream, AttributeImpl and StringSAttributeImpl. llvm-svn: 194997
* gtest-death-test.cc: Move ~DeathTestFactory() to unbreak cygming build since ↵NAKAMURA Takumi2013-11-161-2/+2
| | | | | | r194865. llvm-svn: 194918
* Fix previous commit (r194865)Juergen Ributzka2013-11-151-0/+2
| | | | llvm-svn: 194874
* [weak vtables] Remove a bunch of weak vtablesJuergen Ributzka2013-11-1510-10/+35
| | | | | | | | | | | This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy llvm-svn: 194865
* Move all of the GoogleTest files back to the same locations they occupyChandler Carruth2013-11-1512-33/+17
| | | | | | | | | | | | | externally to simplify our integration of GoogleTest into LLVM. Also, build the single source file gtest-all.cc instead of the individual source files as we don't expect these to change and thus gain nothing from increased incrementality in compiles. This makes our standard build of googletest exactly like upstream's recommended build and the sanitizer's build. It also simplifies the steps of importing a new version should we ever want one. llvm-svn: 194801
* Get the unittests compiling when building with cmake and the settingDuncan Sands2013-05-141-0/+4
| | | | | | -DLLVM_ENABLE_THREADS=false. llvm-svn: 181788
OpenPOWER on IntegriCloud