|
18 | 18 | __author__ = "Orsiris de Jong" |
19 | 19 | __copyright__ = "Copyright (C) 2015-2025 Orsiris de Jong" |
20 | 20 | __licence__ = "BSD 3 Clause" |
21 | | -__build__ = "2025041801" |
| 21 | +__build__ = "2025090901" |
22 | 22 |
|
23 | 23 |
|
24 | 24 | import sys |
@@ -73,13 +73,17 @@ def timestamp(date): |
73 | 73 | PING_FAILURE = "ping 0.0.0.0 -n 2 1>&2" |
74 | 74 |
|
75 | 75 | PRINT_FILE_CMD = "type {}".format(TEST_FILENAME) |
| 76 | + # On widows, we cannot print binary files to console, type would transliterate it into text |
| 77 | + # This is a dummy test on windows |
| 78 | + PRINT_BINARY_FILE_CMD = "type C:\\Windows\\System32\\cmd.exe" |
76 | 79 | else: |
77 | 80 | ENCODING = "utf-8" |
78 | 81 | PING_CMD = ["ping", "-c", "4", "127.0.0.1"] |
79 | 82 | PING_CMD_10S = ["ping", "-c", "10", "127.0.0.1"] |
80 | 83 | PING_CMD_REDIR = "ping -c 4 127.0.0.1 1>&2" |
81 | 84 | PING_CMD_AND_FAILURE = "ping -c 2 0.0.0.0 1>&2; ping -c 2 127.0.0.1" |
82 | 85 | PRINT_FILE_CMD = "cat {}".format(TEST_FILENAME) |
| 86 | + PRINT_BINARY_FILE_CMD = "cat /bin/sh" |
83 | 87 | PING_FAILURE = "ping -c 2 0.0.0.0 1>&2" |
84 | 88 |
|
85 | 89 |
|
@@ -161,6 +165,18 @@ def test_standard_ping_with_encoding_disabled(): |
161 | 165 | assert isinstance(output, bytes), "Output should be binary." |
162 | 166 |
|
163 | 167 |
|
| 168 | +def test_direct_binary_output_to_stdout(): |
| 169 | + """ |
| 170 | + Without encoding disabled, we should have binary output |
| 171 | + """ |
| 172 | + for method in methods: |
| 173 | + exit_code, output = command_runner(PRINT_BINARY_FILE_CMD, encoding=False, method=method) |
| 174 | + print(output) |
| 175 | + assert ( |
| 176 | + exit_code == 0 |
| 177 | + ), "Exit code should be 0 for ping command with method {}".format(method) |
| 178 | + assert isinstance(output, bytes), "Output should be binary." |
| 179 | + |
164 | 180 | def test_timeout(): |
165 | 181 | """ |
166 | 182 | Test command_runner with a timeout |
|
0 commit comments