• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import os, re, sys
2
3from autotest_lib.client.bin import test
4from autotest_lib.client.common_lib import utils
5
6
7class ipv6connect(test.test):
8    version = 1
9
10    preserve_srcdir = True
11
12    def setup(self, src='ipv6connect.c'):
13        os.chdir(self.srcdir)
14        utils.system('gcc ipv6connect.c -o ipv6connect -lpthread -static -s')
15
16
17    def initialize(self):
18        self.job.require_gcc()
19        self.results = []
20
21
22    def run_once(self, dir=None, nprocs=None, args=''):
23        (lower, upper) = utils.get_ip_local_port_range()
24        utils.set_ip_local_port_range(4096, 65535)
25        try:
26            result = utils.run(os.path.join(self.srcdir, 'ipv6connect'),
27                               None, False,
28                               stdout_tee=sys.stdout, stderr_tee=sys.stderr)
29        finally:
30            utils.set_ip_local_port_range(lower, upper)
31        self.results.append(result.stderr)
32
33
34    def postprocess(self):
35        pattern = re.compile(r'\nTotal time = ([0-9.]+)s\n')
36        for duration in pattern.findall('\n'.join(self.results)):
37            self.write_perf_keyval({'time': duration})
38