|
10 | 10 | test("timeout=0 equals get_n_chars/3", ( |
11 | 11 | atom_chars('/bin/echo', Echo), |
12 | 12 | atom_chars('ABCDEFGHIJ', Content), |
13 | | - setup_call_cleanup( |
14 | | - process_create(Echo, [Content], [stdout(pipe(Out1))]), |
15 | | - setup_call_cleanup( |
16 | | - process_create(Echo, [Content], [stdout(pipe(Out2))]), |
| 13 | + iso_ext:setup_call_cleanup( |
| 14 | + process:process_create(Echo, [Content], [stdout(pipe(Out1))]), |
| 15 | + iso_ext:setup_call_cleanup( |
| 16 | + process:process_create(Echo, [Content], [stdout(pipe(Out2))]), |
17 | 17 | ( |
18 | | - get_n_chars(Out1, 5, Chars1), |
19 | | - get_n_chars(Out2, 5, Chars2, 0), |
| 18 | + charsio:get_n_chars(Out1, 5, Chars1), |
| 19 | + charsio:get_n_chars(Out2, 5, Chars2, 0), |
20 | 20 | Chars1 = Chars2 |
21 | 21 | ), |
22 | 22 | close(Out2) |
|
29 | 29 | test("variable N with timeout=0", ( |
30 | 30 | atom_chars('/bin/echo', Echo), |
31 | 31 | atom_chars('Testing', Content), |
32 | | - setup_call_cleanup( |
33 | | - process_create(Echo, [Content], [stdout(pipe(Out1))]), |
34 | | - setup_call_cleanup( |
35 | | - process_create(Echo, [Content], [stdout(pipe(Out2))]), |
| 32 | + iso_ext:setup_call_cleanup( |
| 33 | + process:process_create(Echo, [Content], [stdout(pipe(Out1))]), |
| 34 | + iso_ext:setup_call_cleanup( |
| 35 | + process:process_create(Echo, [Content], [stdout(pipe(Out2))]), |
36 | 36 | ( |
37 | | - get_n_chars(Out1, N1, Chars1), |
38 | | - get_n_chars(Out2, N2, Chars2, 0), |
| 37 | + charsio:get_n_chars(Out1, N1, Chars1), |
| 38 | + charsio:get_n_chars(Out2, N2, Chars2, 0), |
39 | 39 | N1 = N2, |
40 | 40 | Chars1 = Chars2, |
41 | 41 | N1 = 8, |
|
51 | 51 | test("negative timeout equals no timeout", ( |
52 | 52 | atom_chars('/bin/echo', Echo), |
53 | 53 | atom_chars('NegativeTest', Content), |
54 | | - setup_call_cleanup( |
55 | | - process_create(Echo, [Content], [stdout(pipe(Out1))]), |
56 | | - setup_call_cleanup( |
57 | | - process_create(Echo, [Content], [stdout(pipe(Out2))]), |
| 54 | + iso_ext:setup_call_cleanup( |
| 55 | + process:process_create(Echo, [Content], [stdout(pipe(Out1))]), |
| 56 | + iso_ext:setup_call_cleanup( |
| 57 | + process:process_create(Echo, [Content], [stdout(pipe(Out2))]), |
58 | 58 | ( |
59 | | - get_n_chars(Out1, N1, Chars1), |
60 | | - get_n_chars(Out2, N2, Chars2, -100), |
| 59 | + charsio:get_n_chars(Out1, N1, Chars1), |
| 60 | + charsio:get_n_chars(Out2, N2, Chars2, -100), |
61 | 61 | N1 = N2, |
62 | 62 | Chars1 = Chars2 |
63 | 63 | ), |
|
72 | 72 | atom_chars('/usr/bin/python3', Py), |
73 | 73 | atom_chars('-c', C), |
74 | 74 | atom_chars('import sys,time; [print(c,end="",flush=True) or time.sleep(1) for c in "ABCDEFGH"]', Cmd), |
75 | | - setup_call_cleanup( |
76 | | - process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
| 75 | + iso_ext:setup_call_cleanup( |
| 76 | + process:process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
77 | 77 | ( |
78 | | - get_n_chars(Out, N, _Chars, 2500), |
| 78 | + charsio:get_n_chars(Out, N, _Chars, 2500), |
79 | 79 | N >= 2, |
80 | 80 | N =< 3 |
81 | 81 | ), |
|
87 | 87 | test("infinity atom means no timeout", ( |
88 | 88 | atom_chars('/bin/echo', Echo), |
89 | 89 | atom_chars('InfinityTest', Content), |
90 | | - setup_call_cleanup( |
91 | | - process_create(Echo, [Content], [stdout(pipe(Out))]), |
| 90 | + iso_ext:setup_call_cleanup( |
| 91 | + process:process_create(Echo, [Content], [stdout(pipe(Out))]), |
92 | 92 | ( |
93 | | - get_n_chars(Out, N, _Chars, infinity), |
| 93 | + charsio:get_n_chars(Out, N, _Chars, infinity), |
94 | 94 | N > 0 |
95 | 95 | ), |
96 | 96 | close(Out) |
|
102 | 102 | atom_chars('/usr/bin/python3', Py), |
103 | 103 | atom_chars('-c', C), |
104 | 104 | atom_chars('import sys,time; print("A",end="",flush=True); time.sleep(2); print("B",end="",flush=True)', Cmd), |
105 | | - setup_call_cleanup( |
106 | | - process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
| 105 | + iso_ext:setup_call_cleanup( |
| 106 | + process:process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
107 | 107 | ( |
108 | | - get_n_chars(Out, N1, Chars1, 100), |
109 | | - get_n_chars(Out, N2, Chars2, 3000), |
| 108 | + charsio:get_n_chars(Out, N1, Chars1, 100), |
| 109 | + charsio:get_n_chars(Out, N2, Chars2, 3000), |
110 | 110 | N1 = 1, |
111 | 111 | Chars1 = "A", |
112 | 112 | N2 = 1, |
|
121 | 121 | atom_chars('/usr/bin/python3', Py), |
122 | 122 | atom_chars('-c', C), |
123 | 123 | atom_chars('import sys,time; print("ABC",end="",flush=True); time.sleep(5); print("DEF",end="",flush=True)', Cmd), |
124 | | - setup_call_cleanup( |
125 | | - process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
| 124 | + iso_ext:setup_call_cleanup( |
| 125 | + process:process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
126 | 126 | ( |
127 | | - get_n_chars(Out, N1, Chars1, 1000), |
128 | | - get_n_chars(Out, N2, Chars2, 6000), |
| 127 | + charsio:get_n_chars(Out, N1, Chars1, 1000), |
| 128 | + charsio:get_n_chars(Out, N2, Chars2, 6000), |
129 | 129 | N1 = 3, |
130 | 130 | Chars1 = "ABC", |
131 | 131 | N2 = 3, |
|
139 | 139 | test("multiple reads with timeout=0", ( |
140 | 140 | atom_chars('/bin/echo', Echo), |
141 | 141 | atom_chars('ABCDEFGHIJKLMNOP', Content), |
142 | | - setup_call_cleanup( |
143 | | - process_create(Echo, [Content], [stdout(pipe(Out))]), |
| 142 | + iso_ext:setup_call_cleanup( |
| 143 | + process:process_create(Echo, [Content], [stdout(pipe(Out))]), |
144 | 144 | ( |
145 | | - get_n_chars(Out, 4, Chars1, 0), |
146 | | - get_n_chars(Out, 4, Chars2, 0), |
147 | | - get_n_chars(Out, 4, Chars3, 0), |
| 145 | + charsio:get_n_chars(Out, 4, Chars1, 0), |
| 146 | + charsio:get_n_chars(Out, 4, Chars2, 0), |
| 147 | + charsio:get_n_chars(Out, 4, Chars3, 0), |
148 | 148 | Chars1 = "ABCD", |
149 | 149 | Chars2 = "EFGH", |
150 | 150 | Chars3 = "IJKL" |
|
157 | 157 | test("read more than available with timeout=0", ( |
158 | 158 | atom_chars('/bin/echo', Echo), |
159 | 159 | atom_chars('Short', Content), |
160 | | - setup_call_cleanup( |
161 | | - process_create(Echo, [Content], [stdout(pipe(Out))]), |
| 160 | + iso_ext:setup_call_cleanup( |
| 161 | + process:process_create(Echo, [Content], [stdout(pipe(Out))]), |
162 | 162 | ( |
163 | | - get_n_chars(Out, N, _Chars, 0), |
| 163 | + charsio:get_n_chars(Out, N, _Chars, 0), |
164 | 164 | N >= 5, |
165 | 165 | N =< 7 |
166 | 166 | ), |
|
173 | 173 | atom_chars('/usr/bin/python3', Py), |
174 | 174 | atom_chars('-c', C), |
175 | 175 | atom_chars('import sys,time; [print(c,end="",flush=True) or time.sleep(0.5) for c in "ABCD"]', Cmd), |
176 | | - setup_call_cleanup( |
177 | | - process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
| 176 | + iso_ext:setup_call_cleanup( |
| 177 | + process:process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
178 | 178 | ( |
179 | | - get_n_chars(Out, N, Chars, 1300), |
180 | | - length(Chars, ActualLength), |
| 179 | + charsio:get_n_chars(Out, N, Chars, 1300), |
| 180 | + lists:length(Chars, ActualLength), |
181 | 181 | N = ActualLength |
182 | 182 | ), |
183 | 183 | close(Out) |
|
191 | 191 | atom_chars('-c', C), |
192 | 192 | % Send 💜 (F0 9F 92 9C) one byte at a time with delays |
193 | 193 | atom_chars('import sys,time; sys.stdout.buffer.write(b\"\\xf0\"); sys.stdout.buffer.flush(); time.sleep(0.1); sys.stdout.buffer.write(b\"\\x9f\\x92\\x9c\"); sys.stdout.buffer.flush(); time.sleep(0.1); sys.stdout.buffer.write(b\"AB\"); sys.stdout.buffer.flush()', Cmd), |
194 | | - setup_call_cleanup( |
195 | | - process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
| 194 | + iso_ext:setup_call_cleanup( |
| 195 | + process:process_create(Py, [C, Cmd], [stdout(pipe(Out))]), |
196 | 196 | ( |
197 | 197 | % First read: timeout after first byte (incomplete UTF-8) |
198 | | - get_n_chars(Out, N1, _Chars1, 50), |
| 198 | + charsio:get_n_chars(Out, N1, _Chars1, 50), |
199 | 199 | % Second read: should complete the emoji and get more |
200 | | - get_n_chars(Out, N2, _Chars2, 500), |
| 200 | + charsio:get_n_chars(Out, N2, _Chars2, 500), |
201 | 201 | % Verify lossless property: total should be 3 chars (💜 + A + B) |
202 | 202 | TotalChars is N1 + N2, |
203 | 203 | TotalChars = 3 |
|
0 commit comments