From 2f87b54f1a7b8b863fab196ce905ebb8180c6626 Mon Sep 17 00:00:00 2001 From: Jeffrey Yasskin Date: Sat, 20 Mar 2010 23:08:45 +0000 Subject: [PATCH] Add support for XFAILing valgrind runs with memory leak checking independently of runs without leak checking. We add -vg to the triple for non-checked runs, or -vg_leak for checked runs. Also use this to XFAIL the TableGen tests, since tablegen leaks like a sieve. This includes some valgrindArgs refactoring. llvm-svn: 99103 --- llvm/test/TableGen/2003-08-03-PassCode.td | 1 + llvm/test/TableGen/2006-09-18-LargeInt.td | 1 + llvm/test/TableGen/AnonDefinitionOnDemand.td | 1 + llvm/test/TableGen/DagDefSubst.td | 1 + llvm/test/TableGen/DagIntSubst.td | 1 + llvm/test/TableGen/DefmInherit.td | 1 + llvm/test/TableGen/ForwardRef.td | 1 + llvm/test/TableGen/GeneralList.td | 1 + llvm/test/TableGen/IntBitInit.td | 1 + llvm/test/TableGen/LazyChange.td | 2 +- llvm/test/TableGen/ListArgs.td | 1 + llvm/test/TableGen/ListArgsSimple.td | 1 + llvm/test/TableGen/ListConversion.td | 1 + llvm/test/TableGen/ListSlices.td | 1 + llvm/test/TableGen/MultiClass.td | 1 + llvm/test/TableGen/MultiClassDefName.td | 1 + llvm/test/TableGen/MultiClassInherit.td | 1 + llvm/test/TableGen/Slice.td | 1 + llvm/test/TableGen/String.td | 1 + llvm/test/TableGen/SuperSubclassSameName.td | 1 + llvm/test/TableGen/TargetInstrInfo.td | 1 + llvm/test/TableGen/TargetInstrSpec.td | 1 + llvm/test/TableGen/TemplateArgRename.td | 1 + llvm/test/TableGen/Tree.td | 1 + llvm/test/TableGen/TreeNames.td | 1 + llvm/test/TableGen/UnsetBitInit.td | 1 + llvm/test/TableGen/cast.td | 1 + llvm/test/TableGen/eq.td | 1 + llvm/test/TableGen/foreach.td | 1 + llvm/test/TableGen/if.td | 1 + llvm/test/TableGen/lisp.td | 1 + llvm/test/TableGen/nameconcat.td | 1 + llvm/test/TableGen/strconcat.td | 1 + llvm/test/TableGen/subst.td | 1 + llvm/test/TableGen/subst2.td | 1 + llvm/test/lit.cfg | 7 +++---- llvm/utils/lit/lit/LitConfig.py | 18 ++++++++++++++++-- llvm/utils/lit/lit/TestFormats.py | 7 +------ llvm/utils/lit/lit/TestRunner.py | 13 ++----------- llvm/utils/lit/lit/lit.py | 4 ++++ 40 files changed, 61 insertions(+), 24 deletions(-) diff --git a/llvm/test/TableGen/2003-08-03-PassCode.td b/llvm/test/TableGen/2003-08-03-PassCode.td index 71421865a588..c02f499b3822 100644 --- a/llvm/test/TableGen/2003-08-03-PassCode.td +++ b/llvm/test/TableGen/2003-08-03-PassCode.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak class test { code Code = C; diff --git a/llvm/test/TableGen/2006-09-18-LargeInt.td b/llvm/test/TableGen/2006-09-18-LargeInt.td index afd813fab653..194699acc632 100644 --- a/llvm/test/TableGen/2006-09-18-LargeInt.td +++ b/llvm/test/TableGen/2006-09-18-LargeInt.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep -- 4294901760 +// XFAIL: vg_leak def X { int Y = 0xFFFF0000; diff --git a/llvm/test/TableGen/AnonDefinitionOnDemand.td b/llvm/test/TableGen/AnonDefinitionOnDemand.td index d567fc807e85..b10ad5870de1 100644 --- a/llvm/test/TableGen/AnonDefinitionOnDemand.td +++ b/llvm/test/TableGen/AnonDefinitionOnDemand.td @@ -1,4 +1,5 @@ // RUN: tblgen < %s +// XFAIL: vg_leak class foo { int THEVAL = X; } def foo_imp : foo<1>; diff --git a/llvm/test/TableGen/DagDefSubst.td b/llvm/test/TableGen/DagDefSubst.td index e5eebe99e8c1..92a207f41829 100644 --- a/llvm/test/TableGen/DagDefSubst.td +++ b/llvm/test/TableGen/DagDefSubst.td @@ -1,5 +1,6 @@ // RUN: tblgen %s | grep {dag d = (X Y)} // RUN: tblgen %s | grep {dag e = (Y X)} +// XFAIL: vg_leak def X; class yclass; diff --git a/llvm/test/TableGen/DagIntSubst.td b/llvm/test/TableGen/DagIntSubst.td index 3c1291c3eca6..00fde694e7dc 100644 --- a/llvm/test/TableGen/DagIntSubst.td +++ b/llvm/test/TableGen/DagIntSubst.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep {dag d = (X 13)} +// XFAIL: vg_leak def X; class C { diff --git a/llvm/test/TableGen/DefmInherit.td b/llvm/test/TableGen/DefmInherit.td index 4f37edf056c5..9e1667052697 100644 --- a/llvm/test/TableGen/DefmInherit.td +++ b/llvm/test/TableGen/DefmInherit.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep {zing = 4} | count 4 +// XFAIL: vg_leak class C1 { int bar = A; diff --git a/llvm/test/TableGen/ForwardRef.td b/llvm/test/TableGen/ForwardRef.td index 2056b1faff35..955cc14248f8 100644 --- a/llvm/test/TableGen/ForwardRef.td +++ b/llvm/test/TableGen/ForwardRef.td @@ -1,4 +1,5 @@ // RUN: tblgen %s -o - +// XFAIL: vg_leak class bar { list x; diff --git a/llvm/test/TableGen/GeneralList.td b/llvm/test/TableGen/GeneralList.td index 7f099f286499..ca92a213b228 100644 --- a/llvm/test/TableGen/GeneralList.td +++ b/llvm/test/TableGen/GeneralList.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak // // Test to make sure that lists work with any data-type diff --git a/llvm/test/TableGen/IntBitInit.td b/llvm/test/TableGen/IntBitInit.td index b949bfea7b13..16ac9c8f912d 100644 --- a/llvm/test/TableGen/IntBitInit.td +++ b/llvm/test/TableGen/IntBitInit.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak def { bit A = 1; int B = A; diff --git a/llvm/test/TableGen/LazyChange.td b/llvm/test/TableGen/LazyChange.td index 145fd0bb79f3..fa53562b8c27 100644 --- a/llvm/test/TableGen/LazyChange.td +++ b/llvm/test/TableGen/LazyChange.td @@ -1,5 +1,5 @@ // RUN: tblgen %s | grep {int Y = 3} - +// XFAIL: vg_leak class C { int X = 4; diff --git a/llvm/test/TableGen/ListArgs.td b/llvm/test/TableGen/ListArgs.td index daa0de66bed5..a513db6da3cd 100644 --- a/llvm/test/TableGen/ListArgs.td +++ b/llvm/test/TableGen/ListArgs.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak class B v> { list vals = v; diff --git a/llvm/test/TableGen/ListArgsSimple.td b/llvm/test/TableGen/ListArgsSimple.td index b3b207825e8b..f7caed69a996 100644 --- a/llvm/test/TableGen/ListArgsSimple.td +++ b/llvm/test/TableGen/ListArgsSimple.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak class B { int val = v; diff --git a/llvm/test/TableGen/ListConversion.td b/llvm/test/TableGen/ListConversion.td index 773ed6e4d114..222b6140564e 100644 --- a/llvm/test/TableGen/ListConversion.td +++ b/llvm/test/TableGen/ListConversion.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak class A; class B : A; diff --git a/llvm/test/TableGen/ListSlices.td b/llvm/test/TableGen/ListSlices.td index be794cf2174a..5848a4e48704 100644 --- a/llvm/test/TableGen/ListSlices.td +++ b/llvm/test/TableGen/ListSlices.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak def A { list B = [10, 20, 30, 4, 1, 1231, 20]; diff --git a/llvm/test/TableGen/MultiClass.td b/llvm/test/TableGen/MultiClass.td index 52ba59c230f1..9f92b73dba65 100644 --- a/llvm/test/TableGen/MultiClass.td +++ b/llvm/test/TableGen/MultiClass.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep {zing = 4} | count 2 +// XFAIL: vg_leak class C1 { int bar = A; diff --git a/llvm/test/TableGen/MultiClassDefName.td b/llvm/test/TableGen/MultiClassDefName.td index 2e71f7d06169..138c93d9bb0c 100644 --- a/llvm/test/TableGen/MultiClassDefName.td +++ b/llvm/test/TableGen/MultiClassDefName.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep WorldHelloCC | count 1 +// XFAIL: vg_leak class C { string name = n; diff --git a/llvm/test/TableGen/MultiClassInherit.td b/llvm/test/TableGen/MultiClassInherit.td index d4c4ce58daa0..9da80bad2d74 100644 --- a/llvm/test/TableGen/MultiClassInherit.td +++ b/llvm/test/TableGen/MultiClassInherit.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep {zing = 4} | count 28 +// XFAIL: vg_leak class C1 { int bar = A; diff --git a/llvm/test/TableGen/Slice.td b/llvm/test/TableGen/Slice.td index cd9c6da15398..22bf7fbfe8cf 100644 --- a/llvm/test/TableGen/Slice.td +++ b/llvm/test/TableGen/Slice.td @@ -1,5 +1,6 @@ // RUN: tblgen %s | grep {\\\[(set} | count 2 // RUN: tblgen %s | grep {\\\[\\\]} | count 2 +// XFAIL: vg_leak class ValueType { int Size = size; diff --git a/llvm/test/TableGen/String.td b/llvm/test/TableGen/String.td index d2ae451c295d..fc0f5b8eb546 100644 --- a/llvm/test/TableGen/String.td +++ b/llvm/test/TableGen/String.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak class x { string y = "missing terminating '\"' character"; } diff --git a/llvm/test/TableGen/SuperSubclassSameName.td b/llvm/test/TableGen/SuperSubclassSameName.td index 087df87124bf..304c883417fa 100644 --- a/llvm/test/TableGen/SuperSubclassSameName.td +++ b/llvm/test/TableGen/SuperSubclassSameName.td @@ -1,4 +1,5 @@ // RUN: tblgen < %s +// XFAIL: vg_leak // Test for template arguments that have the same name as superclass template // arguments. diff --git a/llvm/test/TableGen/TargetInstrInfo.td b/llvm/test/TableGen/TargetInstrInfo.td index 8299541e3c51..2871eb81df9c 100644 --- a/llvm/test/TableGen/TargetInstrInfo.td +++ b/llvm/test/TableGen/TargetInstrInfo.td @@ -1,6 +1,7 @@ // This test describes how we eventually want to describe instructions in // the target independent code generators. // RUN: tblgen %s +// XFAIL: vg_leak // Target indep stuff. class Instruction { // Would have other stuff eventually diff --git a/llvm/test/TableGen/TargetInstrSpec.td b/llvm/test/TableGen/TargetInstrSpec.td index 7c3dd579aec9..a7ca9022f848 100644 --- a/llvm/test/TableGen/TargetInstrSpec.td +++ b/llvm/test/TableGen/TargetInstrSpec.td @@ -1,5 +1,6 @@ // RUN: tblgen %s | grep {\\\[(set VR128:\$dst, (int_x86_sse2_add_pd VR128:\$src1, VR128:\$src2))\\\]} | count 1 // RUN: tblgen %s | grep {\\\[(set VR128:\$dst, (int_x86_sse2_add_ps VR128:\$src1, VR128:\$src2))\\\]} | count 1 +// XFAIL: vg_leak class ValueType { int Size = size; diff --git a/llvm/test/TableGen/TemplateArgRename.td b/llvm/test/TableGen/TemplateArgRename.td index 535c2e430129..ee5d2cf77525 100644 --- a/llvm/test/TableGen/TemplateArgRename.td +++ b/llvm/test/TableGen/TemplateArgRename.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak // Make sure there is no collision between XX and XX. def S; diff --git a/llvm/test/TableGen/Tree.td b/llvm/test/TableGen/Tree.td index f9f1f15139d2..2796cfd3586f 100644 --- a/llvm/test/TableGen/Tree.td +++ b/llvm/test/TableGen/Tree.td @@ -1,5 +1,6 @@ // This tests to make sure we can parse tree patterns. // RUN: tblgen %s +// XFAIL: vg_leak class TreeNode; class RegisterClass; diff --git a/llvm/test/TableGen/TreeNames.td b/llvm/test/TableGen/TreeNames.td index 05a3298adb7f..ccdeb88dd02a 100644 --- a/llvm/test/TableGen/TreeNames.td +++ b/llvm/test/TableGen/TreeNames.td @@ -1,5 +1,6 @@ // This tests to make sure we can parse tree patterns with names. // RUN: tblgen %s +// XFAIL: vg_leak class TreeNode; class RegisterClass; diff --git a/llvm/test/TableGen/UnsetBitInit.td b/llvm/test/TableGen/UnsetBitInit.td index 91342ecb9663..ff7010868bc0 100644 --- a/llvm/test/TableGen/UnsetBitInit.td +++ b/llvm/test/TableGen/UnsetBitInit.td @@ -1,4 +1,5 @@ // RUN: tblgen %s +// XFAIL: vg_leak class x { field bits<32> A; } diff --git a/llvm/test/TableGen/cast.td b/llvm/test/TableGen/cast.td index 4a771ae874fc..8164e74eae43 100644 --- a/llvm/test/TableGen/cast.td +++ b/llvm/test/TableGen/cast.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep {add_ps} | count 3 +// XFAIL: vg_leak class ValueType { int Size = size; diff --git a/llvm/test/TableGen/eq.td b/llvm/test/TableGen/eq.td index 8ba6d7ec8335..518a80ac0d26 100644 --- a/llvm/test/TableGen/eq.td +++ b/llvm/test/TableGen/eq.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | FileCheck %s +// XFAIL: vg_leak // CHECK: Value = 0 // CHECK: Value = 1 diff --git a/llvm/test/TableGen/foreach.td b/llvm/test/TableGen/foreach.td index acce4493b518..d4d81f829ed7 100644 --- a/llvm/test/TableGen/foreach.td +++ b/llvm/test/TableGen/foreach.td @@ -1,6 +1,7 @@ // RUN: tblgen %s | grep {Jr} | count 2 // RUN: tblgen %s | grep {Sr} | count 2 // RUN: tblgen %s | grep {NAME} | count 1 +// XFAIL: vg_leak // Variables for foreach class decls { diff --git a/llvm/test/TableGen/if.td b/llvm/test/TableGen/if.td index 9b2438245db1..0bac0bac3e98 100644 --- a/llvm/test/TableGen/if.td +++ b/llvm/test/TableGen/if.td @@ -1,5 +1,6 @@ // RUN: tblgen %s | grep {\\\[1, 2, 3\\\]} | count 4 // RUN: tblgen %s | grep {\\\[4, 5, 6\\\]} | count 2 +// XFAIL: vg_leak class A> vals> { list first = vals[0]; diff --git a/llvm/test/TableGen/lisp.td b/llvm/test/TableGen/lisp.td index 3e392fda84ff..b521e04c8913 100644 --- a/llvm/test/TableGen/lisp.td +++ b/llvm/test/TableGen/lisp.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep {} +// XFAIL: vg_leak class List n> { list names = n; diff --git a/llvm/test/TableGen/nameconcat.td b/llvm/test/TableGen/nameconcat.td index fc865f9a464d..fd2880a80dff 100644 --- a/llvm/test/TableGen/nameconcat.td +++ b/llvm/test/TableGen/nameconcat.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep {add_ps} | count 3 +// XFAIL: vg_leak class ValueType { int Size = size; diff --git a/llvm/test/TableGen/strconcat.td b/llvm/test/TableGen/strconcat.td index fc0d80596c92..38409a99dc4e 100644 --- a/llvm/test/TableGen/strconcat.td +++ b/llvm/test/TableGen/strconcat.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | grep fufoo +// XFAIL: vg_leak class Y { string T = !strconcat(S, "foo"); diff --git a/llvm/test/TableGen/subst.td b/llvm/test/TableGen/subst.td index ce9f45d0a481..05d424f68355 100644 --- a/llvm/test/TableGen/subst.td +++ b/llvm/test/TableGen/subst.td @@ -4,6 +4,7 @@ // RUN: tblgen %s | grep {LAST} | count 1 // RUN: tblgen %s | grep {TVAR} | count 2 // RUN: tblgen %s | grep {Bogus} | count 1 +// XFAIL: vg_leak class Honorific { string honorific = t; diff --git a/llvm/test/TableGen/subst2.td b/llvm/test/TableGen/subst2.td index 3366c9d9cf7f..584266ef2335 100644 --- a/llvm/test/TableGen/subst2.td +++ b/llvm/test/TableGen/subst2.td @@ -1,4 +1,5 @@ // RUN: tblgen %s | FileCheck %s +// XFAIL: vg_leak // CHECK: No subst // CHECK: No foo // CHECK: RECURSE foo diff --git a/llvm/test/lit.cfg b/llvm/test/lit.cfg index e65b8bec9e4e..fd3120a29fe9 100644 --- a/llvm/test/lit.cfg +++ b/llvm/test/lit.cfg @@ -128,10 +128,9 @@ excludes = [] # Provide target_triple for use in XFAIL and XTARGET. config.target_triple = site_exp['target_triplet'] -# When running under valgrind, we mangle '-vg' onto the end of the triple so we -# can check it with XFAIL and XTARGET. -if lit.useValgrind: - config.target_triple += '-vg' +# When running under valgrind, we mangle '-vg' or '-vg_leak' onto the end of the +# triple so we can check it with XFAIL and XTARGET. +config.target_triple += lit.valgrindTriple # Provide llvm_supports_target for use in local configs. targets = set(site_exp["TARGETS_TO_BUILD"].split()) diff --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py index 0e0a4931dca7..98ca2f047306 100644 --- a/llvm/utils/lit/lit/LitConfig.py +++ b/llvm/utils/lit/lit/LitConfig.py @@ -15,7 +15,7 @@ class LitConfig: import Util as util def __init__(self, progname, path, quiet, - useValgrind, valgrindArgs, + useValgrind, valgrindLeakCheck, valgrindArgs, useTclAsSh, noExecute, debug, isWindows, params): @@ -25,7 +25,8 @@ class LitConfig: self.path = list(map(str, path)) self.quiet = bool(quiet) self.useValgrind = bool(useValgrind) - self.valgrindArgs = list(valgrindArgs) + self.valgrindLeakCheck = bool(valgrindLeakCheck) + self.valgrindUserArgs = list(valgrindArgs) self.useTclAsSh = bool(useTclAsSh) self.noExecute = noExecute self.debug = debug @@ -36,6 +37,19 @@ class LitConfig: self.numErrors = 0 self.numWarnings = 0 + self.valgrindArgs = [] + self.valgrindTriple = "" + if self.useValgrind: + self.valgrindTriple = "-vg" + self.valgrindArgs = ['valgrind', '-q', '--run-libc-freeres=no', + '--tool=memcheck', '--trace-children=yes', + '--error-exitcode=123'] + if self.valgrindLeakCheck: + self.valgrindTriple += "_leak" + self.valgrindArgs.append('--leak-check=full') + self.valgrindArgs.extend(self.valgrindUserArgs) + + def load_config(self, config, path): """load_config(config, path) - Load a config object from an alternate path.""" diff --git a/llvm/utils/lit/lit/TestFormats.py b/llvm/utils/lit/lit/TestFormats.py index 33fd1c1d125a..433e39a62780 100644 --- a/llvm/utils/lit/lit/TestFormats.py +++ b/llvm/utils/lit/lit/TestFormats.py @@ -73,12 +73,7 @@ class GoogleTest(object): cmd = [testPath, '--gtest_filter=' + testName] if litConfig.useValgrind: - valgrindArgs = ['valgrind', '-q', '--run-libc-freeres=no', - '--tool=memcheck', '--trace-children=yes', - '--error-exitcode=123'] - valgrindArgs.extend(litConfig.valgrindArgs) - - cmd = valgrindArgs + cmd + cmd = litConfig.valgrindArgs + cmd out, err, exitCode = TestRunner.executeCommand( cmd, env=test.config.environment) diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index 2778469daa91..29adff222983 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -253,16 +253,12 @@ def executeTclScriptInternal(test, litConfig, tmpBase, commands, cwd): return (Test.FAIL, "Tcl 'exec' parse error on: %r" % ln) if litConfig.useValgrind: - valgrindArgs = ['valgrind', '-q', '--run-libc-freeres=no', - '--tool=memcheck', '--trace-children=yes', - '--error-exitcode=123'] - valgrindArgs.extend(litConfig.valgrindArgs) for pipeline in cmds: if pipeline.commands: # Only valgrind the first command in each pipeline, to avoid # valgrinding things like grep, not, and FileCheck. cmd = pipeline.commands[0] - cmd.args = valgrindArgs + cmd.args + cmd.args = litConfig.valgrindArgs + cmd.args cmd = cmds[0] for c in cmds[1:]: @@ -339,12 +335,7 @@ def executeScript(test, litConfig, tmpBase, commands, cwd): if litConfig.useValgrind: # FIXME: Running valgrind on sh is overkill. We probably could just # run on clang with no real loss. - valgrindArgs = ['valgrind', '-q', '--run-libc-freeres=no', - '--tool=memcheck', '--trace-children=yes', - '--error-exitcode=123'] - valgrindArgs.extend(litConfig.valgrindArgs) - - command = valgrindArgs + command + command = litConfig.valgrindArgs + command return executeCommand(command, cwd=cwd, env=test.config.environment) diff --git a/llvm/utils/lit/lit/lit.py b/llvm/utils/lit/lit/lit.py index 436f8e7a4166..e80075478a6d 100755 --- a/llvm/utils/lit/lit/lit.py +++ b/llvm/utils/lit/lit/lit.py @@ -362,6 +362,9 @@ def main(): group.add_option("", "--vg", dest="useValgrind", help="Run tests under valgrind", action="store_true", default=False) + group.add_option("", "--vg-leak", dest="valgrindLeakCheck", + help="Check for memory leaks under valgrind", + action="store_true", default=False) group.add_option("", "--vg-arg", dest="valgrindArgs", metavar="ARG", help="Specify an extra argument for valgrind", type=str, action="append", default=[]) @@ -436,6 +439,7 @@ def main(): path = opts.path, quiet = opts.quiet, useValgrind = opts.useValgrind, + valgrindLeakCheck = opts.valgrindLeakCheck, valgrindArgs = opts.valgrindArgs, useTclAsSh = opts.useTclAsSh, noExecute = opts.noExecute,