Add support for XFAILing valgrind runs with memory leak checking independently
authorJeffrey Yasskin <jyasskin@google.com>
Sat, 20 Mar 2010 23:08:45 +0000 (23:08 +0000)
committerJeffrey Yasskin <jyasskin@google.com>
Sat, 20 Mar 2010 23:08:45 +0000 (23:08 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99103 91177308-0d34-0410-b5e6-96231b3b80d8

40 files changed:
test/TableGen/2003-08-03-PassCode.td
test/TableGen/2006-09-18-LargeInt.td
test/TableGen/AnonDefinitionOnDemand.td
test/TableGen/DagDefSubst.td
test/TableGen/DagIntSubst.td
test/TableGen/DefmInherit.td
test/TableGen/ForwardRef.td
test/TableGen/GeneralList.td
test/TableGen/IntBitInit.td
test/TableGen/LazyChange.td
test/TableGen/ListArgs.td
test/TableGen/ListArgsSimple.td
test/TableGen/ListConversion.td
test/TableGen/ListSlices.td
test/TableGen/MultiClass.td
test/TableGen/MultiClassDefName.td
test/TableGen/MultiClassInherit.td
test/TableGen/Slice.td
test/TableGen/String.td
test/TableGen/SuperSubclassSameName.td
test/TableGen/TargetInstrInfo.td
test/TableGen/TargetInstrSpec.td
test/TableGen/TemplateArgRename.td
test/TableGen/Tree.td
test/TableGen/TreeNames.td
test/TableGen/UnsetBitInit.td
test/TableGen/cast.td
test/TableGen/eq.td
test/TableGen/foreach.td
test/TableGen/if.td
test/TableGen/lisp.td
test/TableGen/nameconcat.td
test/TableGen/strconcat.td
test/TableGen/subst.td
test/TableGen/subst2.td
test/lit.cfg
utils/lit/lit/LitConfig.py
utils/lit/lit/TestFormats.py
utils/lit/lit/TestRunner.py
utils/lit/lit/lit.py

index 71421865a5880ed07940d7e39da4270594d413e5..c02f499b3822b57fc41923f1e15dd9974990721c 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 
 class test<code C> {
   code Code = C;
index afd813fab653cb81d4c9e27a174db1005585ecb5..194699acc632c0200c4b789a7769aef42ff65436 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep -- 4294901760
+// XFAIL: vg_leak
 
 def X {
   int Y = 0xFFFF0000;
index d567fc807e85ffd71ec2036f2e8305e7fb907c05..b10ad5870de194c311378d5f0d10bb5f89623622 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen < %s
+// XFAIL: vg_leak
 
 class foo<int X> { int THEVAL = X; }
 def foo_imp : foo<1>;
index e5eebe99e8c1c358dcc48ca106843f6b72aa6619..92a207f4182957c7f6eb65eeca9cd247ea346990 100644 (file)
@@ -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;
index 3c1291c3eca6e653384164dc1f4c42ee6ccf1475..00fde694e7dc93dd87b8dffa12cf36ebbe8a8805 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep {dag d = (X 13)}
+// XFAIL: vg_leak
 def X;
 
 class C<int N> {
index 4f37edf056c56a261b496b00f64685ce3d26cb76..9e16670526970f2d5ca5eac9ff2ad81ae183ddea 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep {zing = 4} | count 4
+// XFAIL: vg_leak
 
 class C1<int A, string B> { 
   int bar = A;
index 2056b1faff35dcdc2d123a3a3c4fef173847646d..955cc14248f841d32ede4b3cb5374affd4a7a434 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s -o -
+// XFAIL: vg_leak
 
 class bar {
   list<bar> x;
index 7f099f2864999be51a76e9c60b2311b01218f834..ca92a213b22888f220b480ec20d9810c339b06b9 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 //
 // Test to make sure that lists work with any data-type
 
index b949bfea7b13f846e4400ebade597f1ff6da7a61..16ac9c8f912d715742d1ec693821398a82f36443 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 def {
   bit A = 1;
   int B = A;
index 145fd0bb79f3c9a25cff6d8a275d5edd15c604dc..fa53562b8c2724e8d9c3d507c5910a22f88966b0 100644 (file)
@@ -1,5 +1,5 @@
 // RUN: tblgen %s | grep {int Y = 3}
-
+// XFAIL: vg_leak
 
 class C {
   int X = 4;
index daa0de66bed5581b1523208404f98bbc923e837d..a513db6da3cd80624a196edde045b255c14bec23 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 
 class B<list<int> v> {
   list<int> vals = v;
index b3b207825e8b66b1a1242e064b7c45f3df2e7032..f7caed69a9964c9f6f28d3e8bda62b1ec734d7b5 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 
 class B<int v> {
   int val = v;
index 773ed6e4d11468bea03263751768fdacb9828d3c..222b6140564e9ef2bcd436e10ee5392ef5dd3e62 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 class A;
 class B : A;
 
index be794cf2174adb6071230b23cf18e2b1cf32c47f..5848a4e487042660cffd147eab11548e136d6563 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 
 def A {
   list<int> B = [10, 20, 30, 4, 1, 1231, 20];
index 52ba59c230f1b50d3fdd6f8d374a058f6db2d87b..9f92b73dba65bdc1c437eab8c2f0b9f4e6a4e338 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep {zing = 4} | count 2
+// XFAIL: vg_leak
 
 class C1<int A, string B> { 
   int bar = A;
index 2e71f7d0616913b9e94ef0f25c595e6c78570e3c..138c93d9bb0c408cc7e707bb377ae7a58bf37e54 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep WorldHelloCC | count 1
+// XFAIL: vg_leak
 
 class C<string n> {
   string name = n;
index d4c4ce58daa0c6eb0656859b1f3cd61aec566f48..9da80bad2d74ab34372b0eb41c69dffcb2a21967 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep {zing = 4} | count 28
+// XFAIL: vg_leak
 
 class C1<int A, string B> { 
   int bar = A;
index cd9c6da1539841e552f56f405cb61110b7321fab..22bf7fbfe8cf3fdd3415dbade3bf59534ac4fdef 100644 (file)
@@ -1,5 +1,6 @@
 // RUN: tblgen %s | grep {\\\[(set} | count 2
 // RUN: tblgen %s | grep {\\\[\\\]} | count 2
+// XFAIL: vg_leak
 
 class ValueType<int size, int value> {
   int Size = size;
index d2ae451c295d9e4b3efc805f11db3602600c3a29..fc0f5b8eb5464b54ebf463e5fa6b5a6c326d9f99 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s 
+// XFAIL: vg_leak
 class x {
   string y = "missing terminating '\"' character";
 }
index 087df87124bfb9badcf73d00198de084dbab73ea..304c883417fac06fe3f8d1d634489ff3dbb452e8 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen < %s
+// XFAIL: vg_leak
 // Test for template arguments that have the same name as superclass template
 // arguments.
 
index 8299541e3c5134936611280857f0fbd5f3d72971..2871eb81df9cd804e018e5f2da2f93ad67961f49 100644 (file)
@@ -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
index 7c3dd579aec99650d371db5be8b9433789ce1157..a7ca9022f8480781b38552386d8896b7be18b73b 100644 (file)
@@ -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, int value> {
   int Size = size;
index 535c2e430129534067adc02f267d8b5ec8bc9fbb..ee5d2cf775252476d0d33507b7f2665ea57c9803 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 
 // Make sure there is no collision between XX and XX.
 def S;
index f9f1f15139d2444c14315aa886ea8509ba97b459..2796cfd3586f672ef02480b70ba4ab37fd3a4d3b 100644 (file)
@@ -1,5 +1,6 @@
 // This tests to make sure we can parse tree patterns.
 // RUN: tblgen %s
+// XFAIL: vg_leak
 
 class TreeNode;
 class RegisterClass;
index 05a3298adb7f6a4ff236015334a61d9f8e2bf303..ccdeb88dd02adb17c47e1313fa0beef6223f9346 100644 (file)
@@ -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;
index 91342ecb96635ae3b0d3db55c5e0e36388e8bf6a..ff7010868bc0d21ca6779d33b7a0145e5bc6af30 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s
+// XFAIL: vg_leak
 class x {
   field bits<32> A;
 }
index 4a771ae874fc6af44c21837ba332a56d86a1928e..8164e74eae43a79f476e69d11ec0337998dadc9c 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep {add_ps} | count 3
+// XFAIL: vg_leak
 
 class ValueType<int size, int value> {
   int Size = size;
index 8ba6d7ec833554cf8adcba4007c57a89a795c115..518a80ac0d2680ad2f838bfeac0b85494f27ea91 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | FileCheck %s
+// XFAIL: vg_leak
 // CHECK: Value = 0
 // CHECK: Value = 1
 
index acce4493b518e58f97a37b7bbf2ab79a0b29dbbe..d4d81f829ed72b20e6243dd3bc9a7b4c0cbcafe9 100644 (file)
@@ -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 {
index 9b2438245db1cee78cca8e8991ec35c22f6d295c..0bac0bac3e985c56a427a40c13f9020479eb485d 100644 (file)
@@ -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<list<list<int>> vals> {
   list<int> first = vals[0];
index 3e392fda84ff3ba139e7c1eab8063655b964c838..b521e04c89132416bfa878e188972f8b2669eba9 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep {}
+// XFAIL: vg_leak
 
 class List<list<string> n> {
   list<string> names = n;
index fc865f9a464d95317510ff80ae011787f7e3185e..fd2880a80dfff342793a8e0be5c15cd502c7c2e1 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep {add_ps} | count 3
+// XFAIL: vg_leak
 
 class ValueType<int size, int value> {
   int Size = size;
index fc0d80596c92584ddeb068288c85f4aea5e1d0ca..38409a99dc4e6afc18b6e15f9ab208f87d0985fd 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | grep fufoo
+// XFAIL: vg_leak
 
 class Y<string S> {
   string T = !strconcat(S, "foo");
index ce9f45d0a481950e5de04349dbb17ad201683ae0..05d424f6835576a2b672d9d27c2605f31ed36415 100644 (file)
@@ -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 t> {
   string honorific = t;
index 3366c9d9cf7f4bba4e336c43ace9571da2d54d71..584266ef2335748f41c9b397269cde143fcdddea 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: tblgen %s | FileCheck %s
+// XFAIL: vg_leak
 // CHECK: No subst
 // CHECK: No foo
 // CHECK: RECURSE foo
index e65b8bec9e4e3caa1b800a1ed91ca52ccc796708..fd3120a29fe984bb954e7f381dab5aee3747a569 100644 (file)
@@ -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())
index 0e0a4931dca7ae0228c122922a3c5194bafe88b3..98ca2f047306cbc91285a756ebe6dcd024d5a72a 100644 (file)
@@ -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."""
index 33fd1c1d125ad7a9743546fb0a2b8cdf40f0ca92..433e39a6278076a5d76256e691b8db5c0c570355 100644 (file)
@@ -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)
index 2778469daa91a1c272b086d6ef61e707124ae84b..29adff2229839f4b1656cfa0cd1eb0e0917e372d 100644 (file)
@@ -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)
 
index 436f8e7a4166cdb95e097e783a5cf9b5f2e9794f..e80075478a6dcc9b0472ea9a4636af4430d22dc7 100755 (executable)
@@ -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,