|
|
71928b |
diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
|
|
|
71928b |
index 538ff05..e7f2013 100644
|
|
|
71928b |
--- a/Lib/test/libregrtest/cmdline.py
|
|
|
71928b |
+++ b/Lib/test/libregrtest/cmdline.py
|
|
|
71928b |
@@ -263,7 +263,9 @@ def _create_parser():
|
|
|
71928b |
help='only write the name of test cases that will be run'
|
|
|
71928b |
' , don\'t execute them')
|
|
|
71928b |
group.add_argument('-P', '--pgo', dest='pgo', action='store_true',
|
|
|
71928b |
- help='enable Profile Guided Optimization training')
|
|
|
71928b |
+ help='enable Profile Guided Optimization (PGO) training')
|
|
|
71928b |
+ group.add_argument('--pgo-extended', action='store_true',
|
|
|
71928b |
+ help='enable extended PGO training (slower training)')
|
|
|
71928b |
group.add_argument('--fail-env-changed', action='store_true',
|
|
|
71928b |
help='if a test file alters the environment, mark '
|
|
|
71928b |
'the test as failed')
|
|
|
71928b |
@@ -339,6 +341,8 @@ def _parse_args(args, **kwargs):
|
|
|
71928b |
parser.error("-G/--failfast needs either -v or -W")
|
|
|
71928b |
if ns.pgo and (ns.verbose or ns.verbose2 or ns.verbose3):
|
|
|
71928b |
parser.error("--pgo/-v don't go together!")
|
|
|
71928b |
+ if ns.pgo_extended:
|
|
|
71928b |
+ ns.pgo = True # pgo_extended implies pgo
|
|
|
71928b |
|
|
|
71928b |
if ns.nowindows:
|
|
|
71928b |
print("Warning: the --nowindows (-n) option is deprecated. "
|
|
|
71928b |
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
|
|
|
71928b |
index b6d05f6..524dbfa 100644
|
|
|
71928b |
--- a/Lib/test/libregrtest/main.py
|
|
|
71928b |
+++ b/Lib/test/libregrtest/main.py
|
|
|
71928b |
@@ -17,6 +17,7 @@ from test.libregrtest.runtest import (
|
|
|
71928b |
INTERRUPTED, CHILD_ERROR, TEST_DID_NOT_RUN,
|
|
|
71928b |
PROGRESS_MIN_TIME, format_test_result)
|
|
|
71928b |
from test.libregrtest.setup import setup_tests
|
|
|
71928b |
+from test.libregrtest.pgo import setup_pgo_tests
|
|
|
71928b |
from test.libregrtest.utils import removepy, count, format_duration, printlist
|
|
|
71928b |
from test import support
|
|
|
71928b |
try:
|
|
|
71928b |
@@ -214,6 +215,10 @@ class Regrtest:
|
|
|
71928b |
|
|
|
71928b |
removepy(self.tests)
|
|
|
71928b |
|
|
|
71928b |
+ if self.ns.pgo:
|
|
|
71928b |
+ # add default PGO tests if no tests are specified
|
|
|
71928b |
+ setup_pgo_tests(self.ns)
|
|
|
71928b |
+
|
|
|
71928b |
stdtests = STDTESTS[:]
|
|
|
71928b |
nottests = NOTTESTS.copy()
|
|
|
71928b |
if self.ns.exclude:
|
|
|
71928b |
@@ -601,6 +606,7 @@ class Regrtest:
|
|
|
71928b |
input("Press any key to continue...")
|
|
|
71928b |
|
|
|
71928b |
support.PGO = self.ns.pgo
|
|
|
71928b |
+ support.PGO_EXTENDED = self.ns.pgo_extended
|
|
|
71928b |
|
|
|
71928b |
setup_tests(self.ns)
|
|
|
71928b |
|
|
|
71928b |
diff --git a/Lib/test/libregrtest/pgo.py b/Lib/test/libregrtest/pgo.py
|
|
|
71928b |
new file mode 100644
|
|
|
71928b |
index 0000000..379ff05
|
|
|
71928b |
--- /dev/null
|
|
|
71928b |
+++ b/Lib/test/libregrtest/pgo.py
|
|
|
71928b |
@@ -0,0 +1,55 @@
|
|
|
71928b |
+# Set of tests run by default if --pgo is specified. The tests below were
|
|
|
71928b |
+# chosen based on the following criteria: either they exercise a commonly used
|
|
|
71928b |
+# C extension module or type, or they run some relatively typical Python code.
|
|
|
71928b |
+# Long running tests should be avoided because the PGO instrumented executable
|
|
|
71928b |
+# runs slowly.
|
|
|
71928b |
+PGO_TESTS = [
|
|
|
71928b |
+ 'test_array',
|
|
|
71928b |
+ 'test_base64',
|
|
|
71928b |
+ 'test_binascii',
|
|
|
71928b |
+ 'test_binop',
|
|
|
71928b |
+ 'test_bisect',
|
|
|
71928b |
+ 'test_bytes',
|
|
|
71928b |
+ 'test_bz2',
|
|
|
71928b |
+ 'test_cmath',
|
|
|
71928b |
+ 'test_codecs',
|
|
|
71928b |
+ 'test_collections',
|
|
|
71928b |
+ 'test_complex',
|
|
|
71928b |
+ 'test_dataclasses',
|
|
|
71928b |
+ 'test_datetime',
|
|
|
71928b |
+ 'test_decimal',
|
|
|
71928b |
+ 'test_difflib',
|
|
|
71928b |
+ 'test_embed',
|
|
|
71928b |
+ 'test_float',
|
|
|
71928b |
+ 'test_fstring',
|
|
|
71928b |
+ 'test_functools',
|
|
|
71928b |
+ 'test_generators',
|
|
|
71928b |
+ 'test_hashlib',
|
|
|
71928b |
+ 'test_heapq',
|
|
|
71928b |
+ 'test_int',
|
|
|
71928b |
+ 'test_itertools',
|
|
|
71928b |
+ 'test_json',
|
|
|
71928b |
+ 'test_long',
|
|
|
71928b |
+ 'test_lzma',
|
|
|
71928b |
+ 'test_math',
|
|
|
71928b |
+ 'test_memoryview',
|
|
|
71928b |
+ 'test_operator',
|
|
|
71928b |
+ 'test_ordered_dict',
|
|
|
71928b |
+ 'test_pickle',
|
|
|
71928b |
+ 'test_pprint',
|
|
|
71928b |
+ 'test_re',
|
|
|
71928b |
+ 'test_set',
|
|
|
71928b |
+ 'test_sqlite',
|
|
|
71928b |
+ 'test_statistics',
|
|
|
71928b |
+ 'test_struct',
|
|
|
71928b |
+ 'test_tabnanny',
|
|
|
71928b |
+ 'test_time',
|
|
|
71928b |
+ 'test_unicode',
|
|
|
71928b |
+ 'test_xml_etree',
|
|
|
71928b |
+ 'test_xml_etree_c',
|
|
|
71928b |
+]
|
|
|
71928b |
+
|
|
|
71928b |
+def setup_pgo_tests(ns):
|
|
|
71928b |
+ if not ns.args and not ns.pgo_extended:
|
|
|
71928b |
+ # run default set of tests for PGO training
|
|
|
71928b |
+ ns.args = PGO_TESTS[:]
|
|
|
71928b |
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
|
|
|
71928b |
index 764057a..468ee46 100644
|
|
|
71928b |
--- a/Lib/test/pickletester.py
|
|
|
71928b |
+++ b/Lib/test/pickletester.py
|
|
|
71928b |
@@ -2039,6 +2039,7 @@ class AbstractPickleTests(unittest.TestCase):
|
|
|
71928b |
|
|
|
71928b |
FRAME_SIZE_TARGET = 64 * 1024
|
|
|
71928b |
|
|
|
71928b |
+ @support.skip_if_pgo_task
|
|
|
71928b |
def check_frame_opcodes(self, pickled):
|
|
|
71928b |
"""
|
|
|
71928b |
Check the arguments of FRAME opcodes in a protocol 4+ pickle.
|
|
|
71928b |
@@ -2059,6 +2060,7 @@ class AbstractPickleTests(unittest.TestCase):
|
|
|
71928b |
frame_size = len(pickled) - last_pos - frame_opcode_size
|
|
|
71928b |
self.assertEqual(frame_size, last_arg)
|
|
|
71928b |
|
|
|
71928b |
+ @support.skip_if_pgo_task
|
|
|
71928b |
def test_framing_many_objects(self):
|
|
|
71928b |
obj = list(range(10**5))
|
|
|
71928b |
for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
|
|
|
71928b |
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
|
|
|
71928b |
index 66c0fed..e80a819 100644
|
|
|
71928b |
--- a/Lib/test/support/__init__.py
|
|
|
71928b |
+++ b/Lib/test/support/__init__.py
|
|
|
71928b |
@@ -953,6 +953,10 @@ SAVEDCWD = os.getcwd()
|
|
|
71928b |
# useful for PGO
|
|
|
71928b |
PGO = False
|
|
|
71928b |
|
|
|
71928b |
+# Set by libregrtest/main.py if we are running the extended (time consuming)
|
|
|
71928b |
+# PGO task. If this is True, PGO is also True.
|
|
|
71928b |
+PGO_EXTENDED = False
|
|
|
71928b |
+
|
|
|
71928b |
@contextlib.contextmanager
|
|
|
71928b |
def temp_dir(path=None, quiet=False):
|
|
|
71928b |
"""Return a context manager that creates a temporary directory.
|
|
|
71928b |
@@ -2442,6 +2446,11 @@ def skip_unless_xattr(test):
|
|
|
71928b |
msg = "no non-broken extended attribute support"
|
|
|
71928b |
return test if ok else unittest.skip(msg)(test)
|
|
|
71928b |
|
|
|
71928b |
+def skip_if_pgo_task(test):
|
|
|
71928b |
+ """Skip decorator for tests not run in (non-extended) PGO task"""
|
|
|
71928b |
+ ok = not PGO or PGO_EXTENDED
|
|
|
71928b |
+ msg = "Not run for (non-extended) PGO task"
|
|
|
71928b |
+ return test if ok else unittest.skip(msg)(test)
|
|
|
71928b |
|
|
|
71928b |
def fs_is_case_insensitive(directory):
|
|
|
71928b |
"""Detects if the file system for the specified directory is case-insensitive."""
|
|
|
71928b |
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
|
|
|
71928b |
index f340f23..ebb151c 100644
|
|
|
71928b |
--- a/Lib/test/test_bz2.py
|
|
|
71928b |
+++ b/Lib/test/test_bz2.py
|
|
|
71928b |
@@ -654,6 +654,7 @@ class BZ2CompressorTest(BaseTest):
|
|
|
71928b |
data += bz2c.flush()
|
|
|
71928b |
self.assertEqual(ext_decompress(data), self.TEXT)
|
|
|
71928b |
|
|
|
71928b |
+ @support.skip_if_pgo_task
|
|
|
71928b |
@bigmemtest(size=_4G + 100, memuse=2)
|
|
|
71928b |
def testCompress4G(self, size):
|
|
|
71928b |
# "Test BZ2Compressor.compress()/flush() with >4GiB input"
|
|
|
71928b |
@@ -712,6 +713,7 @@ class BZ2DecompressorTest(BaseTest):
|
|
|
71928b |
self.assertRaises(EOFError, bz2d.decompress, b"anything")
|
|
|
71928b |
self.assertRaises(EOFError, bz2d.decompress, b"")
|
|
|
71928b |
|
|
|
71928b |
+ @support.skip_if_pgo_task
|
|
|
71928b |
@bigmemtest(size=_4G + 100, memuse=3.3)
|
|
|
71928b |
def testDecompress4G(self, size):
|
|
|
71928b |
# "Test BZ2Decompressor.decompress() with >4GiB input"
|
|
|
71928b |
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
|
|
|
71928b |
index 9317951..8c1d016 100644
|
|
|
71928b |
--- a/Lib/test/test_itertools.py
|
|
|
71928b |
+++ b/Lib/test/test_itertools.py
|
|
|
71928b |
@@ -2023,6 +2023,7 @@ class RegressionTests(unittest.TestCase):
|
|
|
71928b |
self.assertRaises(AssertionError, list, cycle(gen1()))
|
|
|
71928b |
self.assertEqual(hist, [0,1])
|
|
|
71928b |
|
|
|
71928b |
+ @support.skip_if_pgo_task
|
|
|
71928b |
def test_long_chain_of_empty_iterables(self):
|
|
|
71928b |
# Make sure itertools.chain doesn't run into recursion limits when
|
|
|
71928b |
# dealing with long chains of empty iterables. Even with a high
|
|
|
71928b |
diff --git a/Lib/test/test_lzma.py b/Lib/test/test_lzma.py
|
|
|
71928b |
index 3dc2c1e..117de0a 100644
|
|
|
71928b |
--- a/Lib/test/test_lzma.py
|
|
|
71928b |
+++ b/Lib/test/test_lzma.py
|
|
|
71928b |
@@ -333,6 +333,7 @@ class CompressorDecompressorTestCase(unittest.TestCase):
|
|
|
71928b |
|
|
|
71928b |
# Test with inputs larger than 4GiB.
|
|
|
71928b |
|
|
|
71928b |
+ @support.skip_if_pgo_task
|
|
|
71928b |
@bigmemtest(size=_4G + 100, memuse=2)
|
|
|
71928b |
def test_compressor_bigmem(self, size):
|
|
|
71928b |
lzc = LZMACompressor()
|
|
|
71928b |
@@ -344,6 +345,7 @@ class CompressorDecompressorTestCase(unittest.TestCase):
|
|
|
71928b |
finally:
|
|
|
71928b |
ddata = None
|
|
|
71928b |
|
|
|
71928b |
+ @support.skip_if_pgo_task
|
|
|
71928b |
@bigmemtest(size=_4G + 100, memuse=3)
|
|
|
71928b |
def test_decompressor_bigmem(self, size):
|
|
|
71928b |
lzd = LZMADecompressor()
|
|
|
71928b |
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
|
|
|
71928b |
index 5347bb1..9d83217 100644
|
|
|
71928b |
--- a/Lib/test/test_regrtest.py
|
|
|
71928b |
+++ b/Lib/test/test_regrtest.py
|
|
|
71928b |
@@ -6,6 +6,7 @@ Note: test_regrtest cannot be run twice in parallel.
|
|
|
71928b |
|
|
|
71928b |
import contextlib
|
|
|
71928b |
import faulthandler
|
|
|
71928b |
+import glob
|
|
|
71928b |
import io
|
|
|
71928b |
import os.path
|
|
|
71928b |
import platform
|
|
|
71928b |
@@ -532,6 +533,31 @@ class BaseTestCase(unittest.TestCase):
|
|
|
71928b |
return proc.stdout
|
|
|
71928b |
|
|
|
71928b |
|
|
|
71928b |
+class CheckActualTests(BaseTestCase):
|
|
|
71928b |
+ """
|
|
|
71928b |
+ Check that regrtest appears to find the expected set of tests.
|
|
|
71928b |
+ """
|
|
|
71928b |
+
|
|
|
71928b |
+ def test_finds_expected_number_of_tests(self):
|
|
|
71928b |
+ args = ['-Wd', '-E', '-bb', '-m', 'test.regrtest', '--list-tests']
|
|
|
71928b |
+ output = self.run_python(args)
|
|
|
71928b |
+ rough_number_of_tests_found = len(output.splitlines())
|
|
|
71928b |
+ actual_testsuite_glob = os.path.join(os.path.dirname(__file__),
|
|
|
71928b |
+ 'test*.py')
|
|
|
71928b |
+ rough_counted_test_py_files = len(glob.glob(actual_testsuite_glob))
|
|
|
71928b |
+ # We're not trying to duplicate test finding logic in here,
|
|
|
71928b |
+ # just give a rough estimate of how many there should be and
|
|
|
71928b |
+ # be near that. This is a regression test to prevent mishaps
|
|
|
71928b |
+ # such as https://bugs.python.org/issue37667 in the future.
|
|
|
71928b |
+ # If you need to change the values in here during some
|
|
|
71928b |
+ # mythical future test suite reorganization, don't go
|
|
|
71928b |
+ # overboard with logic and keep that goal in mind.
|
|
|
71928b |
+ self.assertGreater(rough_number_of_tests_found,
|
|
|
71928b |
+ rough_counted_test_py_files*9//10,
|
|
|
71928b |
+ msg='Unexpectedly low number of tests found in:\n'
|
|
|
71928b |
+ f'{", ".join(output.splitlines())}')
|
|
|
71928b |
+
|
|
|
71928b |
+
|
|
|
71928b |
class ProgramsTestCase(BaseTestCase):
|
|
|
71928b |
"""
|
|
|
71928b |
Test various ways to run the Python test suite. Use options close
|
|
|
71928b |
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
|
|
71928b |
index b452289..cc428ac 100644
|
|
|
71928b |
--- a/Makefile.pre.in
|
|
|
71928b |
+++ b/Makefile.pre.in
|
|
|
71928b |
@@ -247,9 +247,10 @@ TCLTK_INCLUDES= @TCLTK_INCLUDES@
|
|
|
71928b |
TCLTK_LIBS= @TCLTK_LIBS@
|
|
|
71928b |
|
|
|
71928b |
# The task to run while instrumented when building the profile-opt target.
|
|
|
71928b |
-# We exclude unittests with -x that take a rediculious amount of time to
|
|
|
71928b |
-# run in the instrumented training build or do not provide much value.
|
|
|
71928b |
-PROFILE_TASK=-m test.regrtest --pgo
|
|
|
71928b |
+# To speed up profile generation, we don't run the full unit test suite
|
|
|
71928b |
+# by default. The default is "-m test --pgo". To run more tests, use
|
|
|
71928b |
+# PROFILE_TASK="-m test --pgo-extended"
|
|
|
71928b |
+PROFILE_TASK= @PROFILE_TASK@
|
|
|
71928b |
|
|
|
71928b |
# report files for gcov / lcov coverage report
|
|
|
71928b |
COVERAGE_INFO= $(abs_builddir)/coverage.info
|
|
|
71928b |
diff --git a/configure.ac b/configure.ac
|
|
|
71928b |
index c071ec3..816fc5a 100644
|
|
|
71928b |
--- a/configure.ac
|
|
|
71928b |
+++ b/configure.ac
|
|
|
71928b |
@@ -1308,6 +1308,14 @@ else
|
|
|
71928b |
DEF_MAKE_RULE="all"
|
|
|
71928b |
fi
|
|
|
71928b |
|
|
|
71928b |
+AC_ARG_VAR(PROFILE_TASK, Python args for PGO generation task)
|
|
|
71928b |
+AC_MSG_CHECKING(PROFILE_TASK)
|
|
|
71928b |
+if test -z "$PROFILE_TASK"
|
|
|
71928b |
+then
|
|
|
71928b |
+ PROFILE_TASK='-m test --pgo'
|
|
|
71928b |
+fi
|
|
|
71928b |
+AC_MSG_RESULT($PROFILE_TASK)
|
|
|
71928b |
+
|
|
|
71928b |
# Make llvm-relatec checks work on systems where llvm tools are not installed with their
|
|
|
71928b |
# normal names in the default $PATH (ie: Ubuntu). They exist under the
|
|
|
71928b |
# non-suffixed name in their versioned llvm directory.
|