@@ -16,27 +16,36 @@ class CommandLineTest(testlib.RouterMixin, testlib.TestCase):
1616 # * 2.7 starting 3.x
1717 # * 3.x starting 2.7
1818
19- def test_valid_syntax (self ):
19+ def setUp (self ):
20+ super (CommandLineTest , self ).setUp ()
2021 options = mitogen .parent .Options (max_message_size = 123 )
2122 conn = mitogen .parent .Connection (options , self .router )
2223 conn .context = mitogen .core .Context (None , 123 )
23- args = conn .get_boot_command ()
24+ self .args = conn .get_boot_command ()
25+ self .preamble = conn .get_preamble ()
26+ self .conn = conn
27+
28+ def test_valid_syntax (self ):
29+ """Test valid syntax
30+
31+ The boot command should write an ECO marker to stdout, read the
32+ preamble from stdin, then execute it.
33+
34+ This test attaches /dev/zero to stdin to create a specific failure
2435
25- # The boot command should write an ECO marker to stdout, read the
26- # preamble from stdin, then execute it.
36+ 1. Fork child reads <compressed preamble size> bytes of NUL (`b'\0 '`)
37+ 2. Fork child crashes (trying to decompress the junk data)
38+ 3. Fork child's file descriptors (write pipes) are closed by the OS
39+ 4. Fork parent does `dup(<read pipe>, <stdin>)` and `exec(<python>)`
40+ 5. Python reads `b''` (i.e. EOF) from stdin (a closed pipe)
41+ 6. Python runs `''` (a valid script) and exits with success
2742
28- # This test attaches /dev/zero to stdin to create a specific failure
29- # 1. Fork child reads <compressed preamble size> bytes of NUL (`b'\0'`)
30- # 2. Fork child crashes (trying to decompress the junk data)
31- # 3. Fork child's file descriptors (write pipes) are closed by the OS
32- # 4. Fork parent does `dup(<read pipe>, <stdin>)` and `exec(<python>)`
33- # 5. Python reads `b''` (i.e. EOF) from stdin (a closed pipe)
34- # 6. Python runs `''` (a valid script) and exits with success
43+ """
3544
3645 fp = open ("/dev/zero" , "r" )
3746 try :
3847 proc = subprocess .Popen (
39- args ,
48+ self . args ,
4049 stdin = fp ,
4150 stdout = subprocess .PIPE ,
4251 stderr = subprocess .PIPE ,
0 commit comments