new platform global constant
This commit is contained in:
parent
f8e12ec6c7
commit
ab41b78863
43 changed files with 154 additions and 129 deletions
|
|
@ -30,7 +30,7 @@ def create_shm_dir(data_dir, trash_dir):
|
|||
# under '/dev/shm' and put datadir and tmpdirs here.
|
||||
import shutil
|
||||
from subprocess import run
|
||||
if sys.platform in ('win32', 'darwin'):
|
||||
if gc.platform in ('win32', 'darwin'):
|
||||
for tdir in (data_dir, trash_dir):
|
||||
try:
|
||||
os.listdir(tdir)
|
||||
|
|
@ -81,7 +81,7 @@ try:
|
|||
except ImportError:
|
||||
from test.include.test_init import repo_root
|
||||
|
||||
from mmgen.cfg import Config
|
||||
from mmgen.cfg import Config, gc
|
||||
from mmgen.color import red, yellow, green, blue, init_color
|
||||
from mmgen.util import msg, Msg, rmsg, die
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ cfg.skipping_deps = cfg.resuming or 'skip_deps' in po.user_opts
|
|||
|
||||
cmd_args = cfg._args
|
||||
|
||||
if cfg.pexpect_spawn and sys.platform == 'win32':
|
||||
if cfg.pexpect_spawn and gc.platform == 'win32':
|
||||
die(1, '--pexpect-spawn option not supported on Windows platform, exiting')
|
||||
|
||||
if cfg.daemon_id and cfg.daemon_id in cfg.blacklisted_daemons.split():
|
||||
|
|
@ -240,7 +240,7 @@ if cfg.skipping_deps:
|
|||
from test.cmdtest_d.include.cfg import cfgs
|
||||
|
||||
def create_tmp_dirs(shm_dir):
|
||||
if sys.platform in ('win32', 'darwin'):
|
||||
if gc.platform in ('win32', 'darwin'):
|
||||
for cfg in sorted(cfgs):
|
||||
mk_tmpdir(cfgs[cfg]['tmpdir'])
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import sys, os, time, shutil, atexit
|
|||
from subprocess import run, DEVNULL
|
||||
from pathlib import Path
|
||||
|
||||
from mmgen.cfg import Config
|
||||
from mmgen.cfg import Config, gc
|
||||
from mmgen.color import red, blue, yellow, cyan, orange, purple, gray
|
||||
from mmgen.util import msg, suf, die, indent, fmt
|
||||
from mmgen.led import LEDControl
|
||||
|
|
@ -71,13 +71,13 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
self._create_autosign_instances(create_dirs=not cfg.skipping_deps)
|
||||
self.fs_image_path = Path(self.tmpdir).absolute() / 'removable_device_image'
|
||||
|
||||
if sys.platform == 'linux':
|
||||
if gc.platform == 'linux':
|
||||
self.txdev = VirtBlockDevice(self.fs_image_path, '10M')
|
||||
|
||||
if not (cfg.skipping_deps or self.live):
|
||||
self._create_removable_device()
|
||||
|
||||
if sys.platform == 'darwin' and not cfg.no_daemon_stop:
|
||||
if gc.platform == 'darwin' and not cfg.no_daemon_stop:
|
||||
atexit.register(self._macOS_eject_disk, self.asi.dev_label)
|
||||
|
||||
self.opts = ['--coins='+','.join(self.coins)]
|
||||
|
|
@ -99,7 +99,7 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
del self.txdev
|
||||
|
||||
if not self.cfg.no_daemon_stop:
|
||||
if sys.platform == 'darwin':
|
||||
if gc.platform == 'darwin':
|
||||
for label in (self.asi.dev_label, self.asi.macos_ramdisk.label):
|
||||
self._macOS_eject_disk(label)
|
||||
|
||||
|
|
@ -123,10 +123,10 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
for k in ('mountpoint', 'shm_dir', 'wallet_dir'):
|
||||
if subdir == 'online' and k in ('shm_dir', 'wallet_dir'):
|
||||
continue
|
||||
if sys.platform == 'darwin' and k != 'mountpoint':
|
||||
if gc.platform == 'darwin' and k != 'mountpoint':
|
||||
continue
|
||||
getattr(asi, k).mkdir(parents=True, exist_ok=True)
|
||||
if sys.platform == 'darwin' and k == 'mountpoint':
|
||||
if gc.platform == 'darwin' and k == 'mountpoint':
|
||||
asi.mountpoint.rmdir()
|
||||
continue
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
raise
|
||||
|
||||
def _create_removable_device(self):
|
||||
match sys.platform:
|
||||
match gc.platform:
|
||||
case 'linux':
|
||||
self.txdev.create()
|
||||
self.txdev.attach(silent=True)
|
||||
|
|
@ -211,7 +211,7 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
mn_desc = mn_type or 'default'
|
||||
mn_type = mn_type or 'mmgen'
|
||||
|
||||
if sys.platform == 'darwin' and not self.cfg.no_daemon_stop:
|
||||
if gc.platform == 'darwin' and not self.cfg.no_daemon_stop:
|
||||
self._macOS_eject_disk(self.asi.macos_ramdisk.label)
|
||||
|
||||
self.insert_device()
|
||||
|
|
@ -257,7 +257,7 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
t.read()
|
||||
self.remove_device()
|
||||
|
||||
if sys.platform == 'darwin' and not self.cfg.no_daemon_stop:
|
||||
if gc.platform == 'darwin' and not self.cfg.no_daemon_stop:
|
||||
atexit.register(self._macOS_eject_disk, self.asi.macos_ramdisk.label)
|
||||
|
||||
return t
|
||||
|
|
@ -267,7 +267,7 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
return
|
||||
loc = getattr(self, asi)
|
||||
|
||||
match sys.platform:
|
||||
match gc.platform:
|
||||
case 'linux':
|
||||
self._set_e2label(loc.dev_label)
|
||||
self.txdev.attach()
|
||||
|
|
@ -284,7 +284,7 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
if self.live:
|
||||
return
|
||||
loc = getattr(self, asi)
|
||||
match sys.platform:
|
||||
match gc.platform:
|
||||
case 'linux':
|
||||
self.txdev.detach()
|
||||
for _ in range(20):
|
||||
|
|
@ -407,7 +407,7 @@ class CmdTestAutosignClean(CmdTestAutosignBase):
|
|||
t = self.spawn('mmgen-autosign', [f'--coins={coins}', 'clean'], no_msg=True)
|
||||
out = t.read()
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
if gc.platform == 'darwin':
|
||||
self.insert_device()
|
||||
|
||||
silence()
|
||||
|
|
@ -718,7 +718,7 @@ class CmdTestAutosign(CmdTestAutosignBase):
|
|||
for fn in (db.control, db.trigger):
|
||||
run(f'sudo rm -f {fn}'.split(), check=True)
|
||||
LEDControl.create_dummy_control_files()
|
||||
usrgrp = {'linux': 'root:root', 'darwin': 'root:wheel'}[sys.platform]
|
||||
usrgrp = {'linux': 'root:root', 'darwin': 'root:wheel'}[gc.platform]
|
||||
for fn in (db.control, db.trigger): # trigger the auto-chmod feature
|
||||
run(f'sudo chmod 644 {fn}'.split(), check=True)
|
||||
run(f'sudo chown {usrgrp} {fn}'.split(), check=True)
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@
|
|||
test.cmdtest_d.base: Base class for the cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import msg
|
||||
from mmgen.color import gray, purple, yellow
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ class CmdTestBase:
|
|||
msg(f'{fn}: file does not exist or could not be deleted')
|
||||
|
||||
def skip_for_platform(self, name, extra_msg=None):
|
||||
if sys.platform == name:
|
||||
if gc.platform == name:
|
||||
msg(gray('Skipping test {!r} for {} platform{}'.format(
|
||||
self.test_name,
|
||||
name,
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@
|
|||
test.cmdtest_d.cfgfile: CfgFile tests for the MMGen cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, os, time, shutil
|
||||
import os, time, shutil
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.color import yellow
|
||||
from mmgen.cfgfile import CfgFileSampleSys, CfgFileSampleUsr, cfg_file_sample
|
||||
|
||||
|
|
@ -180,7 +181,7 @@ class CmdTestCfgFile(CmdTestBase):
|
|||
self.write_to_cfgfile('usr', ['foo true', 'bar false'])
|
||||
t = self.old_sample_common(
|
||||
old_set = True,
|
||||
pexpect_spawn = not sys.platform == 'win32')
|
||||
pexpect_spawn = not gc.platform == 'win32')
|
||||
t.expect('unrecognized option')
|
||||
return t
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,13 @@
|
|||
test.cmdtest_d.ethdev: Ethdev tests for the cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, time, os, re, shutil, asyncio, json
|
||||
import time, os, re, shutil, asyncio, json
|
||||
from decimal import Decimal
|
||||
from collections import namedtuple
|
||||
from subprocess import run, PIPE, DEVNULL
|
||||
from pathlib import Path
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.color import red, yellow, blue, cyan, orange, set_vt100
|
||||
from mmgen.util import msg, msg_r, rmsg, die
|
||||
from mmgen.proto.eth.util import compute_contract_addr
|
||||
|
|
@ -1701,7 +1702,7 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
|
|||
def edit_comment1(self):
|
||||
return self.edit_comment(out_num=del_addrs[0], comment_text=tw_comment_zh[:3])
|
||||
def edit_comment2(self):
|
||||
spawn = not sys.platform == 'win32'
|
||||
spawn = not gc.platform == 'win32'
|
||||
return self.edit_comment(
|
||||
out_num = del_addrs[0],
|
||||
comment_text = tw_comment_zh[3:],
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
test.cmdtest_d.help: helpscreen test group for the cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, os, time
|
||||
import os, time
|
||||
|
||||
from mmgen.util import ymsg
|
||||
from mmgen.cfg import gc
|
||||
|
|
@ -103,7 +103,7 @@ class CmdTestHelp(CmdTestBase):
|
|||
scripts = [scripts]
|
||||
for script in scripts:
|
||||
d = gc.cmd_caps_data[script]
|
||||
if sys.platform == 'win32' and 'w' not in d.platforms:
|
||||
if gc.platform == 'win32' and 'w' not in d.platforms:
|
||||
yield script
|
||||
elif not (d.use_coin_opt or self.proto.coin.lower() == 'btc'):
|
||||
yield script
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ test.cmdtest_d.include.common: Shared routines and data for the cmdtest.py test
|
|||
|
||||
import sys, os
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.color import green, blue, gray
|
||||
from mmgen.util import msg
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ from mmgen.obj import MMGenTxComment, TwComment
|
|||
tx_comment_jp = text_jp
|
||||
tx_comment_zh = text_zh
|
||||
|
||||
lcg = ascii_cyr_gr if sys.platform == 'win32' else lat_cyr_gr # MSYS2 popen_spawn issue
|
||||
lcg = ascii_cyr_gr if gc.platform == 'win32' else lat_cyr_gr # MSYS2 popen_spawn issue
|
||||
tx_comment_lat_cyr_gr = lcg[:MMGenTxComment.max_len] # 72 chars
|
||||
|
||||
tw_comment_zh = text_zh[:TwComment.max_screen_width // 2]
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@
|
|||
test.cmdtest_d.include.proxy: SSH SOCKS proxy runner for the cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, atexit
|
||||
import atexit
|
||||
from subprocess import run, PIPE
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import msg, die, fmt
|
||||
from mmgen.util2 import port_in_use
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ class TestProxy:
|
|||
"""
|
||||
|
||||
def kill_proxy(self, args):
|
||||
if sys.platform in ('linux', 'darwin'):
|
||||
if gc.platform in ('linux', 'darwin'):
|
||||
omsg(f'Stopping SSH SOCKS server at localhost:{self.port}')
|
||||
cmd = ['pkill', '-f', ' '.join(args)]
|
||||
run(cmd)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class CmdTestRunner:
|
|||
omsg(f'INFO → Writing coverage files to {coverdir!r}')
|
||||
self.pre_args = ['python3', '-m', 'trace', '--count', '--coverdir='+coverdir, '--file='+accfile]
|
||||
else:
|
||||
self.pre_args = ['python3'] if sys.platform == 'win32' else []
|
||||
self.pre_args = ['python3'] if gc.platform == 'win32' else []
|
||||
|
||||
if self.cfg.pexpect_spawn:
|
||||
omsg('INFO → Using pexpect.spawn() for real terminal emulation')
|
||||
|
|
@ -190,7 +190,7 @@ class CmdTestRunner:
|
|||
clr1, clr2 = (nocolor, nocolor) if self.cfg.print_cmdline else (green, cyan)
|
||||
omsg(
|
||||
clr1('Executing: ') +
|
||||
clr2(repr(cmd_disp) if sys.platform == 'win32' else cmd_disp)
|
||||
clr2(repr(cmd_disp) if gc.platform == 'win32' else cmd_disp)
|
||||
)
|
||||
else:
|
||||
omsg_r('{a}Testing {b}: {c}'.format(
|
||||
|
|
@ -242,8 +242,8 @@ class CmdTestRunner:
|
|||
|
||||
ct_cls = self.gm.load_mod(gname)
|
||||
|
||||
if sys.platform in ct_cls.platform_skip:
|
||||
omsg(gray(f'INFO → skipping test {gname!r} for platform {sys.platform!r}'))
|
||||
if gc.platform in ct_cls.platform_skip:
|
||||
omsg(gray(f'INFO → skipping test {gname!r} for platform {gc.platform!r}'))
|
||||
return None
|
||||
|
||||
for k in ('segwit', 'segwit_random', 'bech32'):
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
test.cmdtest_d.input: user input tests for the MMGen cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import fmt, capfirst, remove_whitespace
|
||||
|
|
@ -28,7 +28,7 @@ from .include.common import Ctrl_U, ref_dir
|
|||
from .base import CmdTestBase
|
||||
from .include.input import stealth_mnemonic_entry, user_dieroll_entry
|
||||
|
||||
hold_protect_delay = 2 if sys.platform == 'darwin' else None
|
||||
hold_protect_delay = 2 if gc.platform == 'darwin' else None
|
||||
|
||||
class CmdTestInput(CmdTestBase):
|
||||
'user input'
|
||||
|
|
@ -236,7 +236,7 @@ class CmdTestInput(CmdTestBase):
|
|||
return t
|
||||
|
||||
def _input_func(self, func_name, arg_dfls, func_args, text, expect, term, delay=None):
|
||||
if term and sys.platform == 'win32':
|
||||
if term and gc.platform == 'win32':
|
||||
return ('skip_warn', 'pexpect_spawn not supported on Windows platform')
|
||||
func_args = dict(zip(arg_dfls.keys(), func_args))
|
||||
t = self.spawn(
|
||||
|
|
@ -285,7 +285,7 @@ class CmdTestInput(CmdTestBase):
|
|||
return self._get_char(['prompt> ', '', True, 5], 'x', 'x', False)
|
||||
|
||||
def get_char2(self):
|
||||
expect = 'x' if sys.platform == 'win32' else 'xxxxx'
|
||||
expect = 'x' if gc.platform == 'win32' else 'xxxxx'
|
||||
return self._get_char(['prompt> ', '', True, 5], 'xxxxx', expect, False)
|
||||
|
||||
def get_char3(self):
|
||||
|
|
@ -383,7 +383,7 @@ class CmdTestInput(CmdTestBase):
|
|||
hold_protect_delay)
|
||||
|
||||
def _password_entry(self, prompt, opts=[], term=False):
|
||||
if term and sys.platform == 'win32':
|
||||
if term and gc.platform == 'win32':
|
||||
return ('skip_warn', 'pexpect_spawn not supported on Windows platform')
|
||||
t = self.spawn('test/misc/input_func.py', opts + ['passphrase'], cmd_dir='.', pexpect_spawn=term)
|
||||
imsg(f'Terminal: {term}')
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ test.cmdtest_d.misc: Miscellaneous test groups for the cmdtest.py test suite
|
|||
|
||||
import sys, re
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import die
|
||||
|
||||
from ..include.common import start_test_daemons, stop_test_daemons, imsg
|
||||
|
|
@ -208,7 +209,7 @@ class CmdTestOutput(CmdTestBase):
|
|||
|
||||
def oneshot_warning(self, pexpect_spawn=None):
|
||||
t = self.spawn('test/misc/oneshot_warning.py', cmd_dir='.', pexpect_spawn=pexpect_spawn)
|
||||
nl = '\r\n' if sys.platform == 'win32' or t.pexpect_spawn else '\n'
|
||||
nl = '\r\n' if gc.platform == 'win32' or t.pexpect_spawn else '\n'
|
||||
for s in (
|
||||
f'pw{nl}wg1',
|
||||
'foo is experimental',
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@
|
|||
test.cmdtest_d.tool: tool tests for the MMGen cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import suf
|
||||
from mmgen.color import cyan
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ class CmdTestTool(CmdTestMain, CmdTestBase):
|
|||
vmsg(f'Incog ID: {cyan(i_id)}')
|
||||
t = self.spawn('mmgen-tool', ['-d', self.tmpdir, 'find_incog_data', f1, i_id])
|
||||
o = t.expect_getend(f'Incog data for ID {i_id} found at offset ')
|
||||
if not sys.platform == 'win32':
|
||||
if not gc.platform == 'win32':
|
||||
os.unlink(f1) # causes problems with MSYS2
|
||||
cmp_or_die(hincog_offset, int(o))
|
||||
return t
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@
|
|||
test.cmdtest_d.wallet: Wallet conversion tests for the cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import msg, capfirst, get_extension
|
||||
from mmgen.wallet import get_wallet_cls
|
||||
|
||||
|
|
@ -174,7 +175,7 @@ class CmdTestWalletConv(CmdTestBase, CmdTestShared):
|
|||
|
||||
b = VirtBlockDevice(os.path.join(self.tmpdir, 'hincog_blkdev_img'), '1K')
|
||||
b.create()
|
||||
b.attach(dev_mode='0666' if sys.platform == 'linux' else None)
|
||||
b.attach(dev_mode='0666' if gc.platform == 'linux' else None)
|
||||
self.ref_hincog_conv_out(ic_f=b.dev)
|
||||
b.detach()
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,11 @@
|
|||
test.cmdtest_d.xmrwallet: xmrwallet tests for the cmdtest.py test suite
|
||||
"""
|
||||
|
||||
import sys, os, time, re, atexit, asyncio, shutil
|
||||
import os, time, re, atexit, asyncio, shutil
|
||||
from subprocess import run, PIPE
|
||||
from collections import namedtuple
|
||||
|
||||
from mmgen.cfg import gc
|
||||
from mmgen.util import capfirst, is_int, die, suf, list_gen
|
||||
from mmgen.obj import MMGenRange
|
||||
from mmgen.amt import XMRAmt
|
||||
|
|
@ -798,7 +799,7 @@ class CmdTestXMRWallet(CmdTestBase):
|
|||
h = await self._get_height()
|
||||
imsg_r(f'Chain height: {h} ')
|
||||
|
||||
max_iterations, min_height = (300, 64) if sys.platform == 'win32' else (50, 300)
|
||||
max_iterations, min_height = (300, 64) if gc.platform == 'win32' else (50, 300)
|
||||
verbose = False
|
||||
|
||||
for count in range(max_iterations):
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
test.daemontest_d.rpc: RPC unit test for the MMGen suite
|
||||
"""
|
||||
|
||||
import sys, os, asyncio
|
||||
import os, asyncio
|
||||
|
||||
from mmgen.cfg import Config
|
||||
from mmgen.cfg import Config, gc
|
||||
from mmgen.color import yellow, cyan
|
||||
from mmgen.util import msg, gmsg, make_timestr, pp_fmt, die, async_run
|
||||
from mmgen.protocol import init_proto
|
||||
|
|
@ -149,7 +149,7 @@ def run_test(network_ids, test_cf_auth=False, daemon_ids=None, cfg_override=None
|
|||
d.stop()
|
||||
d.remove_datadir()
|
||||
|
||||
if test_cf_auth and sys.platform != 'win32':
|
||||
if test_cf_auth and gc.platform != 'win32':
|
||||
asyncio.run(cfg_file_auth_test(cfg, d))
|
||||
asyncio.run(cfg_file_auth_test(cfg, d, bad_auth=True))
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ class unit_tests:
|
|||
password = 'foo',
|
||||
seed = xmrseed().fromhex('beadface'*8, tostr=True))
|
||||
|
||||
if sys.platform == 'win32':
|
||||
if gc.platform == 'win32':
|
||||
wd.stop()
|
||||
wd.start()
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from subprocess import run, PIPE, DEVNULL
|
|||
from pathlib import Path
|
||||
from collections import namedtuple
|
||||
|
||||
from mmgen.cfg import gv
|
||||
from mmgen.cfg import gv, gc
|
||||
from mmgen.color import yellow, green, orange
|
||||
from mmgen.util import msg, msg_r, Msg, Msg_r, gmsg, die, suf, fmt_list
|
||||
from mmgen.fileutil import write_data_to_file, get_data_from_file
|
||||
|
|
@ -383,7 +383,7 @@ def create_addrpairs(proto, mmtype, num):
|
|||
for m in range(num)]
|
||||
|
||||
def VirtBlockDevice(img_path, size):
|
||||
match sys.platform:
|
||||
match gc.platform:
|
||||
case 'linux':
|
||||
return VirtBlockDeviceLinux(img_path, size)
|
||||
case 'darwin':
|
||||
|
|
|
|||
|
|
@ -243,10 +243,10 @@ def run_test(test, subtest=None):
|
|||
if cfg.fast and _subtest in fast_skip:
|
||||
subtest_skip_msg(_subtest, '[--fast]')
|
||||
continue
|
||||
if sys.platform == 'win32' and _subtest in win_skip:
|
||||
if gc.platform == 'win32' and _subtest in win_skip:
|
||||
subtest_skip_msg(_subtest, 'for Windows platform')
|
||||
continue
|
||||
if sys.platform == 'darwin' and _subtest in mac_skip:
|
||||
if gc.platform == 'darwin' and _subtest in mac_skip:
|
||||
subtest_skip_msg(_subtest, 'for macOS platform')
|
||||
continue
|
||||
if platform.machine() == 'aarch64' and _subtest in arm_skip:
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ commands = [
|
|||
'get_char_one_raw',
|
||||
]
|
||||
|
||||
match sys.platform:
|
||||
match gc.platform:
|
||||
case 'linux' | 'darwin':
|
||||
commands.extend([
|
||||
'get_char',
|
||||
|
|
@ -42,7 +42,7 @@ opts_data = {
|
|||
-h, --help Print this help message
|
||||
""",
|
||||
'notes': f"""
|
||||
available commands for platform {sys.platform!r}:
|
||||
available commands for platform {gc.platform!r}:
|
||||
{fmt_list(commands, fmt='col', indent=' ')}
|
||||
"""
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ def _tt_get_char(raw=False, one_char=False, immed_chars=''):
|
|||
if one_char else
|
||||
'echoed as a FULL CONTROL SEQUENCE.'
|
||||
)
|
||||
if sys.platform == 'win32':
|
||||
if gc.platform == 'win32':
|
||||
if raw:
|
||||
m3 = 'The Escape and F1-F12 keys will be returned as two-character strings.'
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ test/scrambletest.py: seed scrambling and addrlist data generation tests for all
|
|||
supported coins + passwords
|
||||
"""
|
||||
|
||||
import sys, os, time
|
||||
import os, time
|
||||
from subprocess import run, PIPE
|
||||
from collections import namedtuple
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ except ImportError:
|
|||
from test.include import test_init
|
||||
|
||||
from mmgen.main import launch
|
||||
from mmgen.cfg import Config
|
||||
from mmgen.cfg import Config, gc
|
||||
from mmgen.util import msg, msg_r, bmsg, die, list_gen
|
||||
from mmgen.color import gray, green
|
||||
from test.include.common import set_globals, init_coverage, end_msg
|
||||
|
|
@ -136,7 +136,7 @@ def make_coin_test_data():
|
|||
bmsg('Testing address scramble strings and list IDs')
|
||||
coin_data = bitcoin_data | ({} if cfg.no_altcoin else altcoin_data)
|
||||
for id_str, test_data in coin_data.items():
|
||||
if id_str == 'zec_zcash_z' and sys.platform == 'win32':
|
||||
if id_str == 'zec_zcash_z' and gc.platform == 'win32':
|
||||
msg(gray("Skipping 'zec_zcash_z' test for Windows platform"))
|
||||
continue
|
||||
coin, mmtype = id_str.split('_', 1) if '_' in id_str else (id_str, None)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ try:
|
|||
except ImportError:
|
||||
from test.include.test_init import repo_root
|
||||
|
||||
from mmgen.cfg import Config
|
||||
from mmgen.cfg import Config, gc
|
||||
from mmgen.color import red, yellow, green, blue, cyan
|
||||
from mmgen.util import msg, msg_r, Msg, die
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ spawn_cmd = [
|
|||
if cfg.coverage:
|
||||
d, f = init_coverage()
|
||||
spawn_cmd = ['python3', '-m', 'trace', '--count', '--coverdir='+d, '--file='+f] + spawn_cmd
|
||||
elif sys.platform == 'win32':
|
||||
elif gc.platform == 'win32':
|
||||
spawn_cmd = ['python3'] + spawn_cmd
|
||||
|
||||
add_spawn_args = ['--data-dir='+tcfg['tmpdir']] + ['--{}{}'.format(
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ except ImportError:
|
|||
from test.include.common import set_globals, end_msg, init_coverage
|
||||
|
||||
from mmgen import main_tool
|
||||
from mmgen.cfg import Config
|
||||
from mmgen.cfg import Config, gc
|
||||
from mmgen.color import green, blue, purple, cyan, gray
|
||||
from mmgen.util import msg, msg_r, Msg, die, isAsync
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ def run_test(cls, gid, cmd_name):
|
|||
elif cfg.fork:
|
||||
cmd_out = fork_cmd(cmd_name, args, opts, stdin_input)
|
||||
else:
|
||||
if stdin_input and sys.platform == 'win32':
|
||||
if stdin_input and gc.platform == 'win32':
|
||||
msg(gray('Skipping for MSWin - no os.fork()'))
|
||||
continue
|
||||
method = getattr(cls(cfg, cmdname=cmd_name, proto=proto, mmtype=mmtype), cmd_name)
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@
|
|||
test.tooltest2_d.data: Test vectors for the ‘mmgen-tool’ utility
|
||||
"""
|
||||
|
||||
import sys
|
||||
from decimal import Decimal
|
||||
|
||||
from mmgen.cfg import gc
|
||||
|
||||
from mmgen.key import is_wif
|
||||
from mmgen.addr import is_coin_addr
|
||||
from mmgen.util import is_hex_str
|
||||
|
|
@ -47,7 +48,7 @@ def md5_hash_strip(s):
|
|||
s = s.replace(NL, '\n') # fix DOS newlines
|
||||
return md5_hash(s.strip())
|
||||
|
||||
NL = ('\n', '\r\n')[sys.platform=='win32']
|
||||
NL = ('\n', '\r\n')[gc.platform=='win32']
|
||||
|
||||
sample_text_hexdump = (
|
||||
'000000: 5468 6520 5469 6d65 7320 3033 2f4a 616e{n}' +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue