-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call duthost_console fixture for test_escape_character test case (#8733)
* Call duthost_console fixture for test_escape_character * Fix for test_escape_character - dut_console
- Loading branch information
1 parent
760a9eb
commit 63f7512
Showing
1 changed file
with
6 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
import pexpect | ||
import logging | ||
import time | ||
import re | ||
import pytest | ||
import six | ||
|
||
from tests.common.helpers.assertions import pytest_assert | ||
|
||
TOTAL_PACKETS = 100 | ||
packet_number = 10 | ||
logger = logging.getLogger(__name__) | ||
|
||
pytestmark = [ | ||
pytest.mark.topology('any') | ||
] | ||
|
||
|
||
def test_console_escape(): | ||
child = pexpect.spawn("ping 127.0.0.1 -c {} -i 1".format(TOTAL_PACKETS)) | ||
time.sleep(5) | ||
child.sendcontrol('C') | ||
child.expect(r"\^C") | ||
match = re.search(r'(\d) packets transmitted', six.ensure_text(child.read())) | ||
pytest_assert(int(match.group(1)) < TOTAL_PACKETS, "Escape Character does not work.") | ||
def test_console_escape(duthost_console): | ||
duthost_console.send_command("ping 127.0.0.1 -c {} -i 1".format(TOTAL_PACKETS), | ||
expect_string=r"icmp_seq={}".format(packet_number)) | ||
duthost_console.send_command("\x03", | ||
expect_string=r"{} packets transmitted".format(packet_number), max_loops=300) |