From 6af57f19dbd67ae96fa6feae9a248dabac6344d3 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 13 Apr 2020 12:38:56 +0100 Subject: [PATCH 1/7] bpo-40214: Reenable test and clear PATH to avoid false failures due to environment --- Lib/ctypes/test/test_loading.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py index a62044e370af69f..bc3d03196671bb9 100644 --- a/Lib/ctypes/test/test_loading.py +++ b/Lib/ctypes/test/test_loading.py @@ -134,13 +134,17 @@ def test_load_dll_with_flags(self): shutil.copy(src, target) shutil.copy(os.path.join(os.path.dirname(src), "sqlite3" + ext), os.path.join(tmp, "sqlite3" + ext)) + env = { + **os.environ, + "PATH": os.path.expandvars(r"%SystemRoot%\System32;%SystemRoot%"), + } def should_pass(command): with self.subTest(command): subprocess.check_output( [sys.executable, "-c", "from ctypes import *; import nt;" + command], - cwd=tmp + cwd=tmp, env=env, ) def should_fail(command): @@ -149,7 +153,7 @@ def should_fail(command): subprocess.check_output( [sys.executable, "-c", "from ctypes import *; import nt;" + command], - cwd=tmp, stderr=subprocess.STDOUT, + cwd=tmp, env=env, stderr=subprocess.STDOUT, ) # Default load should not find this in CWD @@ -158,11 +162,8 @@ def should_fail(command): # Relative path (but not just filename) should succeed should_pass("WinDLL('./_sqlite3.dll')") - # XXX: This test has started failing on Azure Pipelines CI. See - # bpo-40214 for more information. - if 0: - # Insecure load flags should succeed - should_pass("WinDLL('_sqlite3.dll', winmode=0)") + # Insecure load flags should succeed + should_pass("WinDLL('_sqlite3.dll', winmode=0)") # Full path load without DLL_LOAD_DIR shouldn't find dependency should_fail("WinDLL(nt._getfullpathname('_sqlite3.dll'), " + From 0ac1b0bc5b123bb5578e6e09fd322bce260490dd Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 13 Apr 2020 15:46:35 +0100 Subject: [PATCH 2/7] Try with no references --- Lib/ctypes/test/test_loading.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py index bc3d03196671bb9..35e1f0311c44927 100644 --- a/Lib/ctypes/test/test_loading.py +++ b/Lib/ctypes/test/test_loading.py @@ -163,6 +163,7 @@ def should_fail(command): should_pass("WinDLL('./_sqlite3.dll')") # Insecure load flags should succeed + should_pass("WinDLL('_sqlite3.dll', winmode=1)") should_pass("WinDLL('_sqlite3.dll', winmode=0)") # Full path load without DLL_LOAD_DIR shouldn't find dependency From 6a262247253a1b5efbd1734770c9d6b99b7ec9f9 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 13 Apr 2020 16:45:21 +0100 Subject: [PATCH 3/7] Add process monitor logging and run fewer tests --- .azure-pipelines/pr.yml | 18 +++++++++--------- .azure-pipelines/win32.pmc | Bin 0 -> 2572 bytes .azure-pipelines/windows-steps.yml | 12 +++++++++++- 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 .azure-pipelines/win32.pmc diff --git a/.azure-pipelines/pr.yml b/.azure-pipelines/pr.yml index 65f23eb62ee0952..0baee753e5828ef 100644 --- a/.azure-pipelines/pr.yml +++ b/.azure-pipelines/pr.yml @@ -53,7 +53,7 @@ jobs: - job: Ubuntu_PR_Tests displayName: Ubuntu PR Tests dependsOn: Prebuild - condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true')) + condition: false # and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true')) pool: vmImage: ubuntu-16.04 @@ -137,19 +137,19 @@ jobs: strategy: matrix: - win32: - arch: win32 - buildOpt: - testRunTitle: '$(System.PullRequest.TargetBranch)-win32' - testRunPlatform: win32 + #win32: + # arch: win32 + # buildOpt: + # testRunTitle: '$(System.PullRequest.TargetBranch)-win32' + # testRunPlatform: win32 win64: arch: amd64 buildOpt: '-p x64' testRunTitle: '$(System.PullRequest.TargetBranch)-win64' testRunPlatform: win64 - winarm64: - arch: arm64 - buildOpt: '-p arm64' + #winarm64: + # arch: arm64 + # buildOpt: '-p arm64' maxParallel: 4 steps: diff --git a/.azure-pipelines/win32.pmc b/.azure-pipelines/win32.pmc new file mode 100644 index 0000000000000000000000000000000000000000..f5796692bcef883355103a8e54b9cc3607cb6f6b GIT binary patch literal 2572 zcmd^>&uSA<6vj{ekBEr45OI-3kRp;oDr-1hh@sv^Hr%CTSXQ(UrOq zaqYr)aO(s34n9o%efQ4IjA_~mf*VgbGk5NM_nhyZKX>xg%&wprbRR8R%No|RrtMh7 z^R(4$68(YJc>dRN2Z!P}iJn2z{50;tv&;N>G&|w3S;odVjV;-#wVD3-#jJRlLf66%GT(poL#q7oSzj zG2dkEXf-TgQQjNzy=(LK2>X(gu?2_SKRB?r;6oQw7<<0+u=CY*K?YOuiRubcA|e^o z$DqM@7C!ax`o#MO5b`a)@?F5Ie%tJLl?ZLKr=xg$KgEJr{+34$JK}L0Rj1{N{w@r5 z$jUn75-e&id%Scgp>Lrc-6K;ivRHLlRTX#{wX2*(4%;Euvsi4qj2mZ+?{nEz56iBv z5nnl~#Sm9jm2h`sob1SIhZ8~7v<3HdBBzS$GU|Ynj8;XS_kDIbVD(e%uds)C^RuVq-PTZNmr&PB(j!Z2}}OS(^aj71P9!u!-!aj5dmVQLReWGq;q_Hp1F7|26S z#inHIGj)vZn}>+pqh|hafhTjq0!5?j>PL0fO!nu#FAA7T^djZ6WUpwW$6OQ9M`#F| zXKOlN7pcWGNMEQ!pp1hhmh>q*t4D>XO~&i+31@E3=H9s!m879EOqa! z0O>A?@qYl0u;NeMu~s~rf@`6oqdhi^-dP#4RoCxhcjiIQNKX-aIyMr~zRu~ Date: Mon, 13 Apr 2020 16:53:24 +0100 Subject: [PATCH 4/7] Always upload logged data --- .azure-pipelines/windows-steps.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.azure-pipelines/windows-steps.yml b/.azure-pipelines/windows-steps.yml index 8b5ff4dbb81a120..709edaf47d5c991 100644 --- a/.azure-pipelines/windows-steps.yml +++ b/.azure-pipelines/windows-steps.yml @@ -33,9 +33,11 @@ steps: PREFIX: $(Py_OutDir)\$(arch) - powershell: .\procmon.exe /Terminate + condition: true - publish: procmonlog artifact: procmon + condition: true - task: PublishTestResults@2 displayName: 'Publish Test Results' From fce2f7f498fcc1ab2bfeb755f9734af1955c1187 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 13 Apr 2020 17:17:22 +0100 Subject: [PATCH 5/7] Remove PATH fix --- Lib/ctypes/test/test_loading.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py index 35e1f0311c44927..bdecc65fa0e11ab 100644 --- a/Lib/ctypes/test/test_loading.py +++ b/Lib/ctypes/test/test_loading.py @@ -134,17 +134,13 @@ def test_load_dll_with_flags(self): shutil.copy(src, target) shutil.copy(os.path.join(os.path.dirname(src), "sqlite3" + ext), os.path.join(tmp, "sqlite3" + ext)) - env = { - **os.environ, - "PATH": os.path.expandvars(r"%SystemRoot%\System32;%SystemRoot%"), - } def should_pass(command): with self.subTest(command): subprocess.check_output( [sys.executable, "-c", "from ctypes import *; import nt;" + command], - cwd=tmp, env=env, + cwd=tmp, ) def should_fail(command): @@ -153,7 +149,7 @@ def should_fail(command): subprocess.check_output( [sys.executable, "-c", "from ctypes import *; import nt;" + command], - cwd=tmp, env=env, stderr=subprocess.STDOUT, + cwd=tmp, stderr=subprocess.STDOUT, ) # Default load should not find this in CWD From 6382b3644f08e2063a46389493477ee9dff60d07 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 13 Apr 2020 18:37:29 +0100 Subject: [PATCH 6/7] Move temp directory --- Lib/ctypes/test/test_loading.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py index bdecc65fa0e11ab..9350c5d4049d989 100644 --- a/Lib/ctypes/test/test_loading.py +++ b/Lib/ctypes/test/test_loading.py @@ -125,7 +125,7 @@ def test_load_dll_with_flags(self): else: ext = ".dll" - with test.support.temp_dir() as tmp: + with test.support.temp_dir("ctypes-test-dir") as tmp: # We copy two files and load _sqlite3.dll (formerly .pyd), # which has a dependency on sqlite3.dll. Then we test # loading it in subprocesses to avoid it starting in memory @@ -159,7 +159,6 @@ def should_fail(command): should_pass("WinDLL('./_sqlite3.dll')") # Insecure load flags should succeed - should_pass("WinDLL('_sqlite3.dll', winmode=1)") should_pass("WinDLL('_sqlite3.dll', winmode=0)") # Full path load without DLL_LOAD_DIR shouldn't find dependency From 8c77db1cf515b97d4b453b5807107ba9fae06b61 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 13 Apr 2020 18:50:39 +0100 Subject: [PATCH 7/7] Add additional file listing --- Lib/ctypes/test/test_loading.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py index 9350c5d4049d989..5fef39e3ce44d2e 100644 --- a/Lib/ctypes/test/test_loading.py +++ b/Lib/ctypes/test/test_loading.py @@ -125,7 +125,7 @@ def test_load_dll_with_flags(self): else: ext = ".dll" - with test.support.temp_dir("ctypes-test-dir") as tmp: + with test.support.temp_dir() as tmp: # We copy two files and load _sqlite3.dll (formerly .pyd), # which has a dependency on sqlite3.dll. Then we test # loading it in subprocesses to avoid it starting in memory @@ -135,8 +135,13 @@ def test_load_dll_with_flags(self): shutil.copy(os.path.join(os.path.dirname(src), "sqlite3" + ext), os.path.join(tmp, "sqlite3" + ext)) + if test.support.verbose: + print("PRE TEST", tmp, os.listdir(tmp)) + def should_pass(command): with self.subTest(command): + if test.support.verbose: + print(command, tmp, os.listdir(tmp)) subprocess.check_output( [sys.executable, "-c", "from ctypes import *; import nt;" + command], @@ -145,6 +150,8 @@ def should_pass(command): def should_fail(command): with self.subTest(command): + if test.support.verbose: + print(command, tmp, os.listdir(tmp)) with self.assertRaises(subprocess.CalledProcessError): subprocess.check_output( [sys.executable, "-c",