testing/mozbase/mozdevice/sut_tests/test_prompt.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/mozbase/mozdevice/sut_tests/test_prompt.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +import re
     1.9 +import socket
    1.10 +
    1.11 +from dmunit import DeviceManagerTestCase
    1.12 +
    1.13 +class PromptTestCase(DeviceManagerTestCase):
    1.14 +
    1.15 +    def tearDown(self):
    1.16 +        if self.sock:
    1.17 +            self.sock.close()
    1.18 +
    1.19 +    def runTest(self):
    1.20 +        """This tests getting a prompt from the device.
    1.21 +        """
    1.22 +        self.sock = None
    1.23 +        ip = self.dm.host
    1.24 +        port = self.dm.port
    1.25 +
    1.26 +        promptre = re.compile('.*\$\>\x00')
    1.27 +        data = ""
    1.28 +        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    1.29 +        self.sock.connect((ip, int(port)))
    1.30 +        data = self.sock.recv(1024)
    1.31 +        print data
    1.32 +        self.assertTrue(promptre.match(data))

mercurial