]> xenbits.xensource.com Git - people/aperard/xtf.git/commitdiff
Revert "Fix the use of ./xtf-runner on Python 2.4"
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 25 Oct 2019 18:00:22 +0000 (19:00 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 29 Oct 2019 17:29:37 +0000 (17:29 +0000)
In order to add Python 3 compatibility, we must set a baseline of Python 2.6.
Drop the 2.4 compatibility hacks.

This logically reverts 1313f37eef92d427bbd77838c3e1b95be323e607

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xtf-runner

index 172cb1d56fa599505339cdc4be1ffed51c150a95..b9f12f198c688be452354d3473f8e28a7b46c30b 100755 (executable)
@@ -10,7 +10,7 @@ Currently assumes the presence and availability of the `xl` toolstack.
 import sys, os, os.path as path
 
 from optparse import OptionParser
-from subprocess import Popen, PIPE, call as subproc_call
+from subprocess import Popen, PIPE, call as subproc_call, check_output
 
 try:
     import json
@@ -22,7 +22,7 @@ except ImportError:
 #  - WARNING is not a result on its own.
 #  - CRASH isn't known to the C code, but covers all cases where a valid
 #    result was not found.
-all_results = ['SUCCESS', 'SKIP', 'ERROR', 'FAILURE', 'CRASH']
+all_results = ('SUCCESS', 'SKIP', 'ERROR', 'FAILURE', 'CRASH')
 
 # Return the exit code for different states.  Avoid using 1 and 2 because
 # python interpreter uses them -- see document for sys.exit.
@@ -36,13 +36,13 @@ def exit_code(state):
     }[state]
 
 # All test categories
-default_categories     = set(("functional", "xsa"))
-non_default_categories = set(("special", "utility", "in-development"))
+default_categories     = {"functional", "xsa"}
+non_default_categories = {"special", "utility", "in-development"}
 all_categories         = default_categories | non_default_categories
 
 # All test environments
-pv_environments        = set(("pv64", "pv32pae"))
-hvm_environments       = set(("hvm64", "hvm32pae", "hvm32pse", "hvm32"))
+pv_environments        = {"pv64", "pv32pae"}
+hvm_environments       = {"hvm64", "hvm32pae", "hvm32pse", "hvm32"}
 all_environments       = pv_environments | hvm_environments
 
 
@@ -356,11 +356,11 @@ def interpret_selection(opts):
     # Allow "pv" and "hvm" as a combination of environments
     if "pv" in others:
         envs |= pv_environments
-        others -= set(("pv", ))
+        others -= {"pv"}
 
     if "hvm" in others:
         envs |= hvm_environments
-        others -= set(("hvm", ))
+        others -= {"hvm"}
 
     # No input? No selection.
     if not cats and not envs and not others:
@@ -391,10 +391,7 @@ def interpret_selection(opts):
 
         host_envs = []
 
-        cmd = Popen(['xl', 'info'], stdout = PIPE)
-        stdout, _ = cmd.communicate()
-
-        for line in stdout.splitlines():
+        for line in check_output(['xl', 'info']).splitlines():
             if not line.startswith("xen_caps"):
                 continue
 
@@ -411,7 +408,7 @@ def interpret_selection(opts):
 
             break
 
-        selection = tests_from_selection(cats = set(),
+        selection = tests_from_selection(cats = {},
                                          envs = set(host_envs),
                                          tests = selection)
 
@@ -589,86 +586,82 @@ def main():
     parser = OptionParser(
         usage = "%prog [--list] <SELECTION> [options]",
         description = "Xen Test Framework enumeration and running tool",
-        )
-
-    # Python 2.4 doesn't support epilog.  Avoid the error when calling the
-    # constructor by monkeypatching it into the object instead.  It will
-    # simply be omitted from the --help text on older versions of Python.
-    parser.epilog = (
-        "\n"
-        "Overview:\n"
-        "  Running with --list will print the entire selection\n"
-        "  to the console.  Running without --list will execute\n"
-        "  all tests in the selection, printing a summary of their\n"
-        "  results at the end.\n"
-        "\n"
-        "  To determine how runner should get output from Xen, use\n"
-        '  --results-mode option. The default value is "console", \n'
-        "  which means using xenconsole program to extract output.\n"
-        '  The other supported value is "logfile", which\n'
-        "  means to get output from log file.\n"
-        "\n"
-        '  The "logfile" mode requires users to configure\n'
-        "  xenconsoled to log guest console output. This mode\n"
-        "  is useful for Xen version < 4.8. Also see --logfile-dir\n"
-        "  and --logfile-pattern options.\n"
-        "\n"
-        "Selections:\n"
-        "  A selection is zero or more of any of the following\n"
-        "  parameters: Categories, Environments and Tests.\n"
-        "  Multiple instances of the same type of parameter are\n"
-        "  unioned while the end result in intersected across\n"
-        "  types.  e.g.\n"
-        "\n"
-        "    'functional xsa'\n"
-        "       All tests in the functional and xsa categories\n"
-        "\n"
-        "    'functional xsa hvm32'\n"
-        "       All tests in the functional and xsa categories\n"
-        "       which are implemented for the hvm32 environment\n"
-        "\n"
-        "    'invlpg example'\n"
-        "       The invlpg and example tests in all implemented\n"
-        "       environments\n"
-        "\n"
-        "    'invlpg example pv'\n"
-        "       The pv environments of the invlpg and example tests\n"
-        "\n"
-        "    'pv32pae-pv-iopl'\n"
-        "       The pv32pae environment of the pv-iopl test only\n"
-        "\n"
-        "  Additionally, --host may be passed to restrict the\n"
-        "  selection to tests applicable to the current host.\n"
-        "  --all may be passed to choose all default categories\n"
-        "  without needing to explicitly name them.  --non-default\n"
-        "  is available to obtain the non-default categories.\n"
-        "\n"
-        "  The special parameter --environments may be passed to\n"
-        "  get the full list of environments.  This option does not\n"
-        "  make sense combined with a selection.\n"
-        "\n"
-        "Examples:\n"
-        "  Listing all tests implemented for hvm32 environment:\n"
-        "    ./xtf-runner --list hvm32\n"
-        "\n"
-        "  Listing all functional tests appropriate for this host:\n"
-        "    ./xtf-runner --list functional --host\n"
-        "\n"
-        "  Running all the pv-iopl tests:\n"
-        "    ./xtf-runner pv-iopl\n"
-        "      <console ouput>\n"
-        "    Combined test results:\n"
-        "    test-pv64-pv-iopl                        SUCCESS\n"
-        "    test-pv32pae-pv-iopl                     SUCCESS\n"
-        "\n"
-        "  Exit code for this script:\n"
-        "    0:    everything is ok\n"
-        "    1,2:  reserved for python interpreter\n"
-        "    3:    test(s) are skipped\n"
-        "    4:    test(s) report error\n"
-        "    5:    test(s) report failure\n"
-        "    6:    test(s) crashed\n"
-        "\n"
+        epilog = (
+            "\n"
+            "Overview:\n"
+            "  Running with --list will print the entire selection\n"
+            "  to the console.  Running without --list will execute\n"
+            "  all tests in the selection, printing a summary of their\n"
+            "  results at the end.\n"
+            "\n"
+            "  To determine how runner should get output from Xen, use\n"
+            '  --results-mode option. The default value is "console", \n'
+            "  which means using xenconsole program to extract output.\n"
+            '  The other supported value is "logfile", which\n'
+            "  means to get output from log file.\n"
+            "\n"
+            '  The "logfile" mode requires users to configure\n'
+            "  xenconsoled to log guest console output. This mode\n"
+            "  is useful for Xen version < 4.8. Also see --logfile-dir\n"
+            "  and --logfile-pattern options.\n"
+            "\n"
+            "Selections:\n"
+            "  A selection is zero or more of any of the following\n"
+            "  parameters: Categories, Environments and Tests.\n"
+            "  Multiple instances of the same type of parameter are\n"
+            "  unioned while the end result in intersected across\n"
+            "  types.  e.g.\n"
+            "\n"
+            "    'functional xsa'\n"
+            "       All tests in the functional and xsa categories\n"
+            "\n"
+            "    'functional xsa hvm32'\n"
+            "       All tests in the functional and xsa categories\n"
+            "       which are implemented for the hvm32 environment\n"
+            "\n"
+            "    'invlpg example'\n"
+            "       The invlpg and example tests in all implemented\n"
+            "       environments\n"
+            "\n"
+            "    'invlpg example pv'\n"
+            "       The pv environments of the invlpg and example tests\n"
+            "\n"
+            "    'pv32pae-pv-iopl'\n"
+            "       The pv32pae environment of the pv-iopl test only\n"
+            "\n"
+            "  Additionally, --host may be passed to restrict the\n"
+            "  selection to tests applicable to the current host.\n"
+            "  --all may be passed to choose all default categories\n"
+            "  without needing to explicitly name them.  --non-default\n"
+            "  is available to obtain the non-default categories.\n"
+            "\n"
+            "  The special parameter --environments may be passed to\n"
+            "  get the full list of environments.  This option does not\n"
+            "  make sense combined with a selection.\n"
+            "\n"
+            "Examples:\n"
+            "  Listing all tests implemented for hvm32 environment:\n"
+            "    ./xtf-runner --list hvm32\n"
+            "\n"
+            "  Listing all functional tests appropriate for this host:\n"
+            "    ./xtf-runner --list functional --host\n"
+            "\n"
+            "  Running all the pv-iopl tests:\n"
+            "    ./xtf-runner pv-iopl\n"
+            "      <console ouput>\n"
+            "    Combined test results:\n"
+            "    test-pv64-pv-iopl                        SUCCESS\n"
+            "    test-pv32pae-pv-iopl                     SUCCESS\n"
+            "\n"
+            "  Exit code for this script:\n"
+            "    0:    everything is ok\n"
+            "    1,2:  reserved for python interpreter\n"
+            "    3:    test(s) are skipped\n"
+            "    4:    test(s) report error\n"
+            "    5:    test(s) report failure\n"
+            "    6:    test(s) crashed\n"
+            "\n"
+        ),
     )
 
     parser.add_option("-l", "--list", action = "store_true",