lyh.kernel
2014-Sep-10 14:48 UTC
[LLVMdev] Does llvm-lit support type substitution (macro)?
Hello all, I am writing test cases which are dedicated to be executed by llvm-lit. Most of my test cases have the same logic but different types. For example: // RUN: %clang_cc1 -fsyntax-only func (int a) { a = 3; } // RUN: %clang_cc1 -fsyntax-only func (char a) { a = 3; } // RUN: %clang_cc1 -fsyntax-only func (unsigned a) { a = 3; } Now I put them in three different test cases but it is hard to maintain. I am wondering whether llvm-lit support writing test cases with macro parameter and a parameter config file: // RUN: %clang_cc1 -fsyntax-only func (TYPE a) { a = 3; } // TYPE config TYPE = {int, char, unsigned} Many thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140910/669295fe/attachment.html>
David Blaikie
2014-Sep-10 15:39 UTC
[LLVMdev] Does llvm-lit support type substitution (macro)?
Nope, lit doesn't have anything like that. Best to keep the tests simple, sometimes to the point of being repetitious. Do you actually have different codepaths to test for each type? On Sep 10, 2014 8:05 AM, "lyh.kernel" <lyh.kernel at gmail.com> wrote:> Hello all, > > I am writing test cases which are dedicated to be executed by llvm-lit. > Most of my test cases have the same logic but different types. For example: > > // RUN: %clang_cc1 -fsyntax-only > func (int a) { > a = 3; > } > > // RUN: %clang_cc1 -fsyntax-only > func (char a) { > a = 3; > } > > // RUN: %clang_cc1 -fsyntax-only > func (unsigned a) { > a = 3; > } > > Now I put them in three different test cases but it is hard to maintain. I > am wondering whether llvm-lit support writing test cases with macro > parameter and a parameter config file: > > // RUN: %clang_cc1 -fsyntax-only > func (TYPE a) { > a = 3; > } > > // TYPE config > TYPE = {int, char, unsigned} > > Many thanks > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140910/c22c7a9a/attachment.html>
Joey Gouly
2014-Sep-10 16:11 UTC
[LLVMdev] Does llvm-lit support type substitution (macro)?
Can't you just use C macros? On 10 Sep 2014 16:05, "lyh.kernel" <lyh.kernel at gmail.com> wrote:> Hello all, > > I am writing test cases which are dedicated to be executed by llvm-lit. > Most of my test cases have the same logic but different types. For example: > > // RUN: %clang_cc1 -fsyntax-only > func (int a) { > a = 3; > } > > // RUN: %clang_cc1 -fsyntax-only > func (char a) { > a = 3; > } > > // RUN: %clang_cc1 -fsyntax-only > func (unsigned a) { > a = 3; > } > > Now I put them in three different test cases but it is hard to maintain. I > am wondering whether llvm-lit support writing test cases with macro > parameter and a parameter config file: > > // RUN: %clang_cc1 -fsyntax-only > func (TYPE a) { > a = 3; > } > > // TYPE config > TYPE = {int, char, unsigned} > > Many thanks > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140910/f9091cfd/attachment.html>
Reid Kleckner
2014-Sep-10 16:15 UTC
[LLVMdev] Does llvm-lit support type substitution (macro)?
You can use the C preprocessor: // RUN: %clang_cc1 -DTYPE=char %s -fsyntax-only // RUN: %clang_cc1 -DTYPE=short %s -fsyntax-only // RUN: %clang_cc1 -DTYPE=unsigned %s -fsyntax-only void func(TYPE a) { a = 3; } But, as David suggests, this kind of data-driven testing usually isn't useful. On Wed, Sep 10, 2014 at 8:39 AM, David Blaikie <dblaikie at gmail.com> wrote:> Nope, lit doesn't have anything like that. > > Best to keep the tests simple, sometimes to the point of being repetitious. > > Do you actually have different codepaths to test for each type? > On Sep 10, 2014 8:05 AM, "lyh.kernel" <lyh.kernel at gmail.com> wrote: > >> Hello all, >> >> I am writing test cases which are dedicated to be executed by llvm-lit. >> Most of my test cases have the same logic but different types. For example: >> >> // RUN: %clang_cc1 -fsyntax-only >> func (int a) { >> a = 3; >> } >> >> // RUN: %clang_cc1 -fsyntax-only >> func (char a) { >> a = 3; >> } >> >> // RUN: %clang_cc1 -fsyntax-only >> func (unsigned a) { >> a = 3; >> } >> >> Now I put them in three different test cases but it is hard to maintain. >> I am wondering whether llvm-lit support writing test cases with macro >> parameter and a parameter config file: >> >> // RUN: %clang_cc1 -fsyntax-only >> func (TYPE a) { >> a = 3; >> } >> >> // TYPE config >> TYPE = {int, char, unsigned} >> >> Many thanks >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140910/4659ef9d/attachment.html>