[LNT] r266758 - fixup diagnose tests

Chris Matthews via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 09:45:27 PDT 2016


Author: cmatthews
Date: Tue Apr 19 11:45:27 2016
New Revision: 266758

URL: http://llvm.org/viewvc/llvm-project?rev=266758&view=rev
Log:
fixup diagnose tests

I realized these require passwordless sudo to work correctly.  This
allows the tests to run with a stubed iprofiler and no sudo.  Add benefit
this allows the power user to customize the iprofiler command used.

Added:
    lnt/trunk/tests/runtest/Inputs/test-suite-cmake/file-iprofiler
Modified:
    lnt/trunk/lnt/tests/test_suite.py
    lnt/trunk/tests/runtest/test_suite_diagnose.py

Modified: lnt/trunk/lnt/tests/test_suite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/test_suite.py?rev=266758&r1=266757&r2=266758&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/test_suite.py (original)
+++ lnt/trunk/lnt/tests/test_suite.py Tue Apr 19 11:45:27 2016
@@ -788,8 +788,19 @@ class TestSuiteTest(BuiltinTest):
 
         #  Collect Profile:
         if "Darwin" in platform.platform():
-            cmd_iprofiler = cmd + ['-DTEST_SUITE_RUN_UNDER=iprofiler '
-                                   '-timeprofiler -I 40u']
+            # For testing and power users, lets allow overrides of how sudo
+            # and iprofiler are called.
+            sudo = os.getenv("SUDO_CMD", "sudo")
+            if " " in sudo:
+                sudo = sudo.split(" ")
+            if not sudo:
+                sudo = []
+            else:
+                sudo = [sudo]
+            iprofiler = os.getenv("IPROFILER_CMD",
+                                  "iprofiler -timeprofiler -I 40u")
+            
+            cmd_iprofiler = cmd + ['-DTEST_SUITE_RUN_UNDER=' + iprofiler]
             print ' '.join(cmd_iprofiler)
 
             out = subprocess.check_output(cmd_iprofiler)
@@ -801,7 +812,7 @@ class TestSuiteTest(BuiltinTest):
                                  stderr=subprocess.PIPE)
             std_out, std_err = p.communicate()
             warning("Using sudo to collect execution trace.")
-            make_save_temps = ["sudo", self.opts.lit, short_name + ".test"]
+            make_save_temps = sudo + [self.opts.lit, short_name + ".test"]
             p = subprocess.Popen(make_save_temps,
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
@@ -811,7 +822,7 @@ class TestSuiteTest(BuiltinTest):
             warning("Tests may fail because of iprofiler's output.")
             # The dtps file will be saved as root, make it so
             # that we can read it.
-            chmod = ["sudo", "chown", "-R", getpass.getuser(),
+            chmod = sudo + ["chown", "-R", getpass.getuser(),
                      short_name + ".dtps"]
             subprocess.call(chmod)
             profile = local_path + "/" + short_name + ".dtps"

Added: lnt/trunk/tests/runtest/Inputs/test-suite-cmake/file-iprofiler
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/runtest/Inputs/test-suite-cmake/file-iprofiler?rev=266758&view=auto
==============================================================================
--- lnt/trunk/tests/runtest/Inputs/test-suite-cmake/file-iprofiler (added)
+++ lnt/trunk/tests/runtest/Inputs/test-suite-cmake/file-iprofiler Tue Apr 19 11:45:27 2016
@@ -0,0 +1,2 @@
+#!/bin/bash
+echo "iProfiler output"

Modified: lnt/trunk/tests/runtest/test_suite_diagnose.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/runtest/test_suite_diagnose.py?rev=266758&r1=266757&r2=266758&view=diff
==============================================================================
--- lnt/trunk/tests/runtest/test_suite_diagnose.py (original)
+++ lnt/trunk/tests/runtest/test_suite_diagnose.py Tue Apr 19 11:45:27 2016
@@ -1,7 +1,8 @@
 # Testing for the 'lnt runtest test-suite --diagnose' feature.
 #
 # RUN: rm -rf  %t.SANDBOX  %t.SANDBOX2 || true
-#
+# RUN: export SUDO_CMD=""
+# RUN: export IPROFILER_CMD=%S/Inputs/test-suite-cmake/fake-iprofiler
 
 # Check --diagnose requires --only-test
 # RUN: lnt runtest test-suite \




More information about the llvm-commits mailing list