Created
January 23, 2014 02:33
-
-
Save rozap/8571817 to your computer and use it in GitHub Desktop.
hehehe
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
import sys | |
import telnetlib | |
import re | |
HOST = "localhost" | |
tn = telnetlib.Telnet(HOST, 8000) | |
def _(msg, expected): | |
tn.write(msg + '\n') | |
result = tn.read_until(expected, .1) | |
p = re.compile(expected) | |
if not p.match(result): | |
raise Exception("Expected %s but received %s" % (expected, result)) | |
print "%s -> %s : %s" % (msg, expected, result) | |
def main(): | |
_("1234", "10") | |
_("12345", "15") | |
_("12345load12", "1513") | |
_("12345lod12", "15-13") | |
_("123f", "6-1") | |
_("12345uptime232", "15\d{8,12}7") | |
_("load100000", "11") | |
_("10101upz10101", "3-13") | |
_("LOAD", "-1") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment