3
3
"""
4
4
5
5
from textwrap import dedent
6
+ from lldbsuite .test import lldbutil
6
7
from lldbsuite .test .lldbtest import TestBase
7
8
8
9
@@ -11,28 +12,29 @@ class ProcessLaunchTestCase(TestBase):
11
12
12
13
def setup (self ):
13
14
self .build ()
14
- exe = self .getBuildArtifact ("a.out" )
15
- self .runCmd ("file " + exe )
16
- return (exe , self .getBuildArtifact ("stdio.log" ))
15
+ self .runCmd ("file " + self .getBuildArtifact ("a.out" ))
16
+ exe = lldbutil .append_to_process_working_directory (self , "a.out" )
17
+ outfile = lldbutil .append_to_process_working_directory (self , "stdio.log" )
18
+ return (exe , outfile )
17
19
18
20
def test_process_launch_no_args (self ):
19
21
# When there are no extra arguments we just have 0, the program name.
20
22
exe , outfile = self .setup ()
21
23
self .runCmd ("platform process launch --stdout {} -s" .format (outfile ))
22
24
self .runCmd ("continue" )
23
25
24
- with open ( outfile ) as f :
25
- self .assertEqual (
26
- dedent (
27
- """\
28
- Got 1 argument(s).
29
- [0]: {}
30
- """ .format (
31
- exe
32
- )
33
- ),
34
- f . read () ,
35
- )
26
+ stdio_log = lldbutil . read_file_on_target ( self , outfile )
27
+ self .assertEqual (
28
+ dedent (
29
+ """\
30
+ Got 1 argument(s).
31
+ [0]: {}
32
+ """ .format (
33
+ exe
34
+ )
35
+ ),
36
+ stdio_log ,
37
+ )
36
38
37
39
def test_process_launch_command_args (self ):
38
40
exe , outfile = self .setup ()
@@ -41,21 +43,21 @@ def test_process_launch_command_args(self):
41
43
self .runCmd ("platform process launch --stdout {} -s -- A B C" .format (outfile ))
42
44
self .runCmd ("continue" )
43
45
44
- with open ( outfile ) as f :
45
- self .assertEqual (
46
- dedent (
47
- """\
48
- Got 4 argument(s).
49
- [0]: {}
50
- [1]: A
51
- [2]: B
52
- [3]: C
53
- """ .format (
54
- exe
55
- )
56
- ),
57
- f . read () ,
58
- )
46
+ stdio_log = lldbutil . read_file_on_target ( self , outfile )
47
+ self .assertEqual (
48
+ dedent (
49
+ """\
50
+ Got 4 argument(s).
51
+ [0]: {}
52
+ [1]: A
53
+ [2]: B
54
+ [3]: C
55
+ """ .format (
56
+ exe
57
+ )
58
+ ),
59
+ stdio_log ,
60
+ )
59
61
60
62
def test_process_launch_target_args (self ):
61
63
exe , outfile = self .setup ()
@@ -64,17 +66,17 @@ def test_process_launch_target_args(self):
64
66
self .runCmd ("platform process launch --stdout {} -s" .format (outfile ))
65
67
self .runCmd ("continue" )
66
68
67
- with open ( outfile ) as f :
68
- self .assertEqual (
69
- dedent (
70
- """\
71
- Got 3 argument(s).
72
- [0]: {}
73
- [1]: D
74
- [2]: E
75
- """ .format (
76
- exe
77
- )
78
- ),
79
- f . read () ,
80
- )
69
+ stdio_log = lldbutil . read_file_on_target ( self , outfile )
70
+ self .assertEqual (
71
+ dedent (
72
+ """\
73
+ Got 3 argument(s).
74
+ [0]: {}
75
+ [1]: D
76
+ [2]: E
77
+ """ .format (
78
+ exe
79
+ )
80
+ ),
81
+ stdio_log ,
82
+ )
0 commit comments