michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import re michael@0: import socket michael@0: michael@0: from dmunit import DeviceManagerTestCase michael@0: michael@0: class PromptTestCase(DeviceManagerTestCase): michael@0: michael@0: def tearDown(self): michael@0: if self.sock: michael@0: self.sock.close() michael@0: michael@0: def runTest(self): michael@0: """This tests getting a prompt from the device. michael@0: """ michael@0: self.sock = None michael@0: ip = self.dm.host michael@0: port = self.dm.port michael@0: michael@0: promptre = re.compile('.*\$\>\x00') michael@0: data = "" michael@0: self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) michael@0: self.sock.connect((ip, int(port))) michael@0: data = self.sock.recv(1024) michael@0: print data michael@0: self.assertTrue(promptre.match(data))