Files
bitcoin/test/functional/feature_posix_fs_permissions.py
Lőrinc 3fd68a95e6 scripted-diff: replace remaining Python test equality asserts
Some Python functional tests still use plain `assert x == y`.
The earlier commits convert the ambiguous assert patterns by hand, so this commit can rewrite the remaining safe cases mechanically.
The verify script excludes `wallet_bumpfee.py`, `test_framework/netutil.py`, and `test_framework/authproxy.py`, which still contain assert forms that the plain line-based substitution would misidentify.

-BEGIN VERIFY SCRIPT-
perl -pi -e 's/^(\s*)assert (.+?) == ([^,#]+?)$/\1assert_equal(\2, \3)/' $(git ls-files -- 'test/functional' \
':(exclude)test/functional/wallet_bumpfee.py' ':(exclude)test/functional/test_framework/netutil.py' ':(exclude)test/functional/test_framework/authproxy.py')
-END VERIFY SCRIPT-
2026-04-07 16:25:22 +03:00

45 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (c) 2022-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test file system permissions for POSIX platforms.
"""
import os
import stat
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
class PosixFsPermissionsTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
def skip_test_if_missing_module(self):
self.skip_if_platform_not_posix()
def check_directory_permissions(self, dir):
mode = os.lstat(dir).st_mode
self.log.info(f"{stat.filemode(mode)} {dir}")
assert_equal(mode, (stat.S_IFDIR | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR))
def check_file_permissions(self, file):
mode = os.lstat(file).st_mode
self.log.info(f"{stat.filemode(mode)} {file}")
assert_equal(mode, (stat.S_IFREG | stat.S_IRUSR | stat.S_IWUSR))
def run_test(self):
self.stop_node(0)
datadir = self.nodes[0].chain_path
self.check_directory_permissions(datadir)
walletsdir = self.nodes[0].wallets_path
self.check_directory_permissions(walletsdir)
debuglog = self.nodes[0].debug_log_path
self.check_file_permissions(debuglog)
if __name__ == '__main__':
PosixFsPermissionsTest(__file__).main()