2 from __future__
import print_function
3 import os, re, subprocess, sys
6 (
'demumble hello',
'hello\n'),
7 (
'demumble _Z4funcPci _Z1fv',
'func(char*, int)\nf()\n'),
8 (
'demumble < _Z4funcPci _Z1fv',
'func(char*, int)\nf()\n'),
9 (
'demumble ?Fx_i@@YAHP6AHH@Z@Z',
'int __cdecl Fx_i(int (__cdecl*)(int))\n'),
10 (
'demumble __Znwi',
'operator new(int)\n'),
11 (
'demumble < __Znwi',
'operator new(int)\n'),
12 (
'demumble -m hi _Z1fv ho _Z1gv',
'hi\nf()\nho\ng()\n'),
13 (
'demumble -m < hi_ho _Z1fv ho _Z1gv ?hm',
'f()\ng()\n?hm\n'),
14 (
'demumble -m < _Z1fv!_Z1gv',
'f()\ng()\n'),
15 (
'demumble -m < _Z1fv!foo_bar',
'f()\n'),
16 (
'demumble Pi',
'int*\n'),
17 (
'demumble < Pi',
'Pi\n'),
18 (
'demumble < ___Z10blocksNRVOv_block_invoke',
19 'invocation function for block in blocksNRVO()\n'),
20 (
'demumble < .____Z10blocksNRVOv_block_invoke',
21 '.invocation function for block in blocksNRVO()\n'),
22 (
'demumble -m < .____Z10blocksNRVOv_block_invoke',
23 'invocation function for block in blocksNRVO()\n'),
24 (
'demumble -- -m',
'-m\n'),
25 (
'demumble -- -h',
'-h\n'),
26 (
'demumble -h', re.compile(
'.*usage: demumble.*')),
27 (
'demumble --help', re.compile(
'.*usage: demumble.*')),
28 (
'demumble --version', re.compile(
'.*\..*')),
35 cmd[0] = os.path.join(os.path.dirname(__file__)
or '.', cmd[0])
37 p = subprocess.Popen(cmd[:cmd.index(
'<')], stdin=subprocess.PIPE,
38 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
39 universal_newlines=
True)
40 out = p.communicate(input=
'\n'.join(cmd[cmd.index(
'<') + 1:]) +
'\n')[0]
42 out = subprocess.check_output(cmd, universal_newlines=
True)
43 if (out != t[1]
if isinstance(t[1], str)
else t[1].
match(out, re.M)):
44 print(
"`%s`: Expected '%s', got '%s'" % (t[0], t[1], out))
46 print(
"passed" if status == 0
else "failed")