OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 import os, unittest, StringIO, socket, urllib2, shutil, subprocess, logging | 3 import os, unittest, StringIO, socket, urllib2, shutil, subprocess, logging |
4 | 4 |
5 import common | 5 import common |
6 from autotest_lib.client.common_lib import utils, autotemp | 6 from autotest_lib.client.common_lib import utils, autotemp |
7 from autotest_lib.client.common_lib.test_utils import mock | 7 from autotest_lib.client.common_lib.test_utils import mock |
8 | 8 |
9 | 9 |
10 class test_read_one_line(unittest.TestCase): | 10 class test_read_one_line(unittest.TestCase): |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 | 766 |
767 try: | 767 try: |
768 result = utils.args_to_dict(['ab-c:DeF', '--SyS=DEf', 'a*=b', 'a*b', | 768 result = utils.args_to_dict(['ab-c:DeF', '--SyS=DEf', 'a*=b', 'a*b', |
769 ':VAL', '=VVV', 'WORD']) | 769 ':VAL', '=VVV', 'WORD']) |
770 self.assertEqual({}, result) | 770 self.assertEqual({}, result) |
771 finally: | 771 finally: |
772 # Restore level. | 772 # Restore level. |
773 logger.setLevel(saved_level) | 773 logger.setLevel(saved_level) |
774 | 774 |
775 | 775 |
| 776 class test_get_random_port(unittest.TestCase): |
| 777 def do_bind(self, port, socket_type, socket_proto): |
| 778 s = socket.socket(socket.AF_INET, socket_type, socket_proto) |
| 779 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
| 780 s.bind(('', port)) |
| 781 return s |
| 782 |
| 783 |
| 784 def test_get_port(self): |
| 785 for _ in xrange(100): |
| 786 p = utils.get_unused_port() |
| 787 s = self.do_bind(p, socket.SOCK_STREAM, socket.IPPROTO_TCP) |
| 788 self.assert_(s.getsockname()) |
| 789 s = self.do_bind(p, socket.SOCK_DGRAM, socket.IPPROTO_UDP) |
| 790 self.assert_(s.getsockname()) |
| 791 |
| 792 |
776 if __name__ == "__main__": | 793 if __name__ == "__main__": |
777 unittest.main() | 794 unittest.main() |
OLD | NEW |