Merge bitcoin/bitcoin#32021: qa: Enable feature_init.py on Windows

59c4930394 qa: Enable feature_init.py on Windows (Hodlinator)

Pull request description:

  Windows has been skipped since feature_init.py was added in #23289. Possibly due to poorer support on older Python versions, or attempts to use `CTRL_C_EVENT` (which didn't work in my testing either) instead of `CTRL_BREAK_EVENT`.

ACKs for top commit:
  maflcko:
    lgtm ACK 59c4930394
  BrandonOdiwuor:
    Code Review ACK 59c4930394
  hebasto:
    ACK 59c4930394, I have reviewed the code and it looks OK.

Tree-SHA512: 4f3649b41bcba2e8d03b8dcb1a7a6882edafb2c456db4b0768fc86018e9e9ed7171cb3d3c99e74b4ef38a3fcf3ab5d2f1865bbd49d791f1ce0a246806634e1a7
This commit is contained in:
Hennadii Stepanov 2025-03-12 11:26:40 +00:00
commit 7bb4c82d8b
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -4,10 +4,13 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Tests related to node initialization.""" """Tests related to node initialization."""
from pathlib import Path from pathlib import Path
import os
import platform import platform
import shutil import shutil
import signal
import subprocess
from test_framework.test_framework import BitcoinTestFramework, SkipTest from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import ( from test_framework.test_node import (
BITCOIN_PID_FILENAME_DEFAULT, BITCOIN_PID_FILENAME_DEFAULT,
ErrorMatch, ErrorMatch,
@ -33,20 +36,17 @@ class InitTest(BitcoinTestFramework):
- test terminating initialization after seeing a certain log line. - test terminating initialization after seeing a certain log line.
- test removing certain essential files to test startup error paths. - test removing certain essential files to test startup error paths.
""" """
# TODO: skip Windows for now since it isn't clear how to SIGTERM.
#
# Windows doesn't support `process.terminate()`.
# and other approaches (like below) don't work:
#
# os.kill(node.process.pid, signal.CTRL_C_EVENT)
if platform.system() == 'Windows':
raise SkipTest("can't SIGTERM on Windows")
self.stop_node(0) self.stop_node(0)
node = self.nodes[0] node = self.nodes[0]
def sigterm_node(): def sigterm_node():
node.process.terminate() if platform.system() == 'Windows':
# Don't call Python's terminate() since it calls
# TerminateProcess(), which unlike SIGTERM doesn't allow
# bitcoind to perform any shutdown logic.
os.kill(node.process.pid, signal.CTRL_BREAK_EVENT)
else:
node.process.terminate()
node.process.wait() node.process.wait()
def start_expecting_error(err_fragment): def start_expecting_error(err_fragment):
@ -86,10 +86,16 @@ class InitTest(BitcoinTestFramework):
if self.is_wallet_compiled(): if self.is_wallet_compiled():
lines_to_terminate_after.append(b'Verifying wallet') lines_to_terminate_after.append(b'Verifying wallet')
args = ['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1']
for terminate_line in lines_to_terminate_after: for terminate_line in lines_to_terminate_after:
self.log.info(f"Starting node and will exit after line {terminate_line}") self.log.info(f"Starting node and will exit after line {terminate_line}")
with node.busy_wait_for_debug_log([terminate_line]): with node.busy_wait_for_debug_log([terminate_line]):
node.start(extra_args=['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1']) if platform.system() == 'Windows':
# CREATE_NEW_PROCESS_GROUP is required in order to be able
# to terminate the child without terminating the test.
node.start(extra_args=args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
else:
node.start(extra_args=args)
self.log.debug("Terminating node after terminate line was found") self.log.debug("Terminating node after terminate line was found")
sigterm_node() sigterm_node()