Skip to content

Commit 59c4930

Browse files
committed
qa: Enable feature_init.py on Windows
1 parent ee68b05 commit 59c4930

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

test/functional/feature_init.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Tests related to node initialization."""
66
from pathlib import Path
7+
import os
78
import platform
89
import shutil
10+
import signal
11+
import subprocess
912

10-
from test_framework.test_framework import BitcoinTestFramework, SkipTest
13+
from test_framework.test_framework import BitcoinTestFramework
1114
from test_framework.test_node import (
1215
BITCOIN_PID_FILENAME_DEFAULT,
1316
ErrorMatch,
@@ -33,20 +36,17 @@ def init_stress_test(self):
3336
- test terminating initialization after seeing a certain log line.
3437
- test removing certain essential files to test startup error paths.
3538
"""
36-
# TODO: skip Windows for now since it isn't clear how to SIGTERM.
37-
#
38-
# Windows doesn't support `process.terminate()`.
39-
# and other approaches (like below) don't work:
40-
#
41-
# os.kill(node.process.pid, signal.CTRL_C_EVENT)
42-
if platform.system() == 'Windows':
43-
raise SkipTest("can't SIGTERM on Windows")
44-
4539
self.stop_node(0)
4640
node = self.nodes[0]
4741

4842
def sigterm_node():
49-
node.process.terminate()
43+
if platform.system() == 'Windows':
44+
# Don't call Python's terminate() since it calls
45+
# TerminateProcess(), which unlike SIGTERM doesn't allow
46+
# bitcoind to perform any shutdown logic.
47+
os.kill(node.process.pid, signal.CTRL_BREAK_EVENT)
48+
else:
49+
node.process.terminate()
5050
node.process.wait()
5151

5252
def start_expecting_error(err_fragment):
@@ -86,10 +86,16 @@ def check_clean_start():
8686
if self.is_wallet_compiled():
8787
lines_to_terminate_after.append(b'Verifying wallet')
8888

89+
args = ['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1']
8990
for terminate_line in lines_to_terminate_after:
9091
self.log.info(f"Starting node and will exit after line {terminate_line}")
9192
with node.busy_wait_for_debug_log([terminate_line]):
92-
node.start(extra_args=['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1'])
93+
if platform.system() == 'Windows':
94+
# CREATE_NEW_PROCESS_GROUP is required in order to be able
95+
# to terminate the child without terminating the test.
96+
node.start(extra_args=args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
97+
else:
98+
node.start(extra_args=args)
9399
self.log.debug("Terminating node after terminate line was found")
94100
sigterm_node()
95101

0 commit comments

Comments
 (0)