diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-03-06 04:50:55 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-03-06 04:50:55 +0000 |
commit | 11bf1ac297d134bda18ac883fdc20a6f95bfe5c7 (patch) | |
tree | 5f66ec74bf2fa2be34fc174e7de1d3dbc8ff25e6 /llvm/unittests/Support | |
parent | 5d29dee00343de8eecff9c4b7ee1775c4d2eeb47 (diff) | |
download | bcm5719-llvm-11bf1ac297d134bda18ac883fdc20a6f95bfe5c7.tar.gz bcm5719-llvm-11bf1ac297d134bda18ac883fdc20a6f95bfe5c7.zip |
unitests: add some ARM TargetParser tests
The ARM TargetParser would construct invalid StringRefs. This would cause
asserts to trigger. Add some tests in LLVM to ensure that we dont regress on
this in the future. Although there is a test for this in clang, this ensures
that the changes would get caught in the same repository.
llvm-svn: 262790
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r-- | llvm/unittests/Support/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/unittests/Support/TargetParserTest.cpp | 51 |
2 files changed, 52 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt index 690a2e376a3..e4e053f936b 100644 --- a/llvm/unittests/Support/CMakeLists.txt +++ b/llvm/unittests/Support/CMakeLists.txt @@ -38,6 +38,7 @@ add_llvm_unittest(SupportTests StreamingMemoryObject.cpp StringPool.cpp SwapByteOrderTest.cpp + TargetParserTest.cpp ThreadLocalTest.cpp ThreadPool.cpp TimerTest.cpp diff --git a/llvm/unittests/Support/TargetParserTest.cpp b/llvm/unittests/Support/TargetParserTest.cpp new file mode 100644 index 00000000000..4bdf03aa861 --- /dev/null +++ b/llvm/unittests/Support/TargetParserTest.cpp @@ -0,0 +1,51 @@ +//===----------- TargetParser.cpp - Target Parser -------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "gtest/gtest.h" +#include "llvm/Support/TargetParser.h" + +using namespace llvm; + +namespace { +TEST(TargetParserTest, ARMArchName) { + for (ARM::ArchKind AK = static_cast<ARM::ArchKind>(0); + AK <= ARM::ArchKind::AK_LAST; + AK = static_cast<ARM::ArchKind>(static_cast<unsigned>(AK) + 1)) + EXPECT_TRUE(AK == ARM::AK_LAST ? ARM::getArchName(AK).empty() + : !ARM::getArchName(AK).empty()); +} + +TEST(TargetParserTest, ARMCPUAttr) { + for (ARM::ArchKind AK = static_cast<ARM::ArchKind>(0); + AK <= ARM::ArchKind::AK_LAST; + AK = static_cast<ARM::ArchKind>(static_cast<unsigned>(AK) + 1)) + EXPECT_TRUE((AK == ARM::AK_INVALID || AK == ARM::AK_LAST) + ? ARM::getCPUAttr(AK).empty() + : !ARM::getCPUAttr(AK).empty()); +} + +TEST(TargetParserTest, ARMSubArch) { + for (ARM::ArchKind AK = static_cast<ARM::ArchKind>(0); + AK <= ARM::ArchKind::AK_LAST; + AK = static_cast<ARM::ArchKind>(static_cast<unsigned>(AK) + 1)) + EXPECT_TRUE((AK == ARM::AK_INVALID || AK == ARM::AK_IWMMXT || + AK == ARM::AK_IWMMXT2 || AK == ARM::AK_LAST) + ? ARM::getSubArch(AK).empty() + : !ARM::getSubArch(AK).empty()); +} + +TEST(TargetParserTest, ARMFPUName) { + for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0); + FK <= ARM::FPUKind::FK_LAST; + FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1)) + EXPECT_TRUE(FK == ARM::FK_LAST ? ARM::getFPUName(FK).empty() + : !ARM::getFPUName(FK).empty()); +} +} + |