[llvm] r262790 - unitests: add some ARM TargetParser tests
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 21:06:18 PST 2016
On Sun, Mar 6, 2016 at 12:01 AM, Renato Golin <renato.golin at linaro.org>
wrote:
> Thanks Saleem, we really needed something like this. I'll make a note
> to extend it, so we can retire the Clang tests.
>
My pleasure.
I was actually half tempted to drop a clang test that I added (which then
prompted me to actually put the effort in for this work). Im torn on
whether that is a good thing or not since that ensures that the frontend
actually emits an error, which is a good thing to check anyways.
But, I do think that we should have the more strenuous tests on the LLVM
side rather than clang.
> --renato
>
> On 6 March 2016 at 04:50, Saleem Abdulrasool via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: compnerd
> > Date: Sat Mar 5 22:50:55 2016
> > New Revision: 262790
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=262790&view=rev
> > Log:
> > 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.
> >
> > Added:
> > llvm/trunk/unittests/Support/TargetParserTest.cpp
> > Modified:
> > llvm/trunk/unittests/Support/CMakeLists.txt
> >
> > Modified: llvm/trunk/unittests/Support/CMakeLists.txt
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/CMakeLists.txt?rev=262790&r1=262789&r2=262790&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/unittests/Support/CMakeLists.txt (original)
> > +++ llvm/trunk/unittests/Support/CMakeLists.txt Sat Mar 5 22:50:55 2016
> > @@ -38,6 +38,7 @@ add_llvm_unittest(SupportTests
> > StreamingMemoryObject.cpp
> > StringPool.cpp
> > SwapByteOrderTest.cpp
> > + TargetParserTest.cpp
> > ThreadLocalTest.cpp
> > ThreadPool.cpp
> > TimerTest.cpp
> >
> > Added: llvm/trunk/unittests/Support/TargetParserTest.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TargetParserTest.cpp?rev=262790&view=auto
> >
> ==============================================================================
> > --- llvm/trunk/unittests/Support/TargetParserTest.cpp (added)
> > +++ llvm/trunk/unittests/Support/TargetParserTest.cpp Sat Mar 5
> 22:50:55 2016
> > @@ -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());
> > +}
> > +}
> > +
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160307/f2440aeb/attachment.html>
More information about the llvm-commits
mailing list