示例#1
0
    def runTest(self, client=lan, server=wan):
        mpstat_present = self.mpstat_ok()

        # this is running an arbitrary time, we will ctrl-c and get results
        self.run_iperf_server(server, opts=self.server_opts_forward())
        if mpstat_present:
            board.sendline('mpstat -P ALL 10000 1')
            board.expect('Linux')
        self.run_iperf(client, opts=opts)
        rate = self.parse_iperf(client)

        if mpstat_present:
            board.sendcontrol('c')
            board.expect('Average.*idle\r\nAverage:\s+all(\s+[0-9]+.[0-9]+){10}\r\n')
            idle_cpu = float(board.match.group(1))
            avg_cpu = 100 - float(idle_cpu)
            self.logged['avg_cpu'] = float(avg_cpu)
        else:
            avg_cpu = "N/A"

        self.kill_iperf(server)
        msg = '%s (%s Mbps, CPU=%s)' % (self.__doc__, rate, avg_cpu)
        lib.common.test_msg("\n%s" % msg)

        self.logged['rate'] = float(rate)
        self.result_message = msg
示例#2
0
    def runTest(self, node1=lan, node2=wan):
        mpstat_present = self.mpstat_ok()

        self.run_iperf_server(node1, opts=self.server_opts_reverse(node1))
        self.run_iperf_server(node2, opts=self.server_opts_forward())
        # this is running an arbitrary time, we will ctrl-c and get results
        if mpstat_present:
            board.sendline('mpstat -P ALL 10000 1')
            board.expect('Linux')
        self.run_iperf(node2, opts=opts, target=self.reverse_ip())
        self.run_iperf(node1, opts=opts)
        rate = 0.0
        rate += float(self.parse_iperf(node1))
        rate += float(self.parse_iperf(node2))
        if mpstat_present:
            board.sendcontrol('c')
            board.expect('Average.*idle\r\nAverage:\s+all(\s+[0-9]+.[0-9]+){10}\r\n')
            idle_cpu = float(board.match.group(1))
            avg_cpu = 100 - float(idle_cpu)
            self.logged['avg_cpu'] = float(avg_cpu)
        else:
            avg_cpu = "N/A"

        self.kill_iperf(node1)
        self.kill_iperf(node2)
        msg = 'iPerf bidir  WAN to LAN (%s Mbps, CPU=%s)' % (rate, avg_cpu)
        lib.common.test_msg("\n%s" % msg)

        self.logged['rate'] = float(rate)
        self.result_message = msg
示例#3
0
 def runTest(self):
     wlan_iface = lib.wifi.wifi_interface(board)
     lib.wifi.enable_wifi(board)
     lib.wifi.wait_wifi_up(board, wlan_iface=wlan_iface)
     board.sendline('\nifconfig')
     board.expect('HWaddr')
     board.expect(prompt)
 def runTest(self):
     num_conn = 5000
     # Wan device: Create small file in web dir
     fname = "small.txt"
     cmd = "\nhead -c 10000 /dev/urandom > /var/www/%s" % fname
     wan.sendline(cmd)
     wan.expect(prompt)
     # Lan Device: download small file a lot
     concurrency = 25
     url = "http://192.168.0.1/%s" % fname
     # Start CPU monitor
     board.sendline("\nmpstat -P ALL 10000 1")
     # Lan Device: download small file a lot
     lan.sendline("\nab -dn %s -c %s %s" % (num_conn, concurrency, url))
     lan.expect("Benchmarking", timeout=5)
     lan.expect("Requests per second:\s+(\d+)")
     reqs_per_sec = int(lan.match.group(1))
     lan.expect(prompt)
     # Stop CPU monitor
     board.sendcontrol("c")
     board.expect("Average:\s+all(\s+[0-9]+.[0-9]+){10}\r\n")
     idle_cpu = float(board.match.group(1))
     avg_cpu = 100 - float(idle_cpu)
     board.expect(prompt)
     msg = "ApacheBench measured %s connections/second, CPU use = %s%%." % (reqs_per_sec, avg_cpu)
     self.result_message = msg
     time.sleep(5)  # Give router a few seconds to recover
示例#5
0
文件: oe.py 项目: fasolens/boardfarm
    def runTest(self):
        board.sendline('cat /etc/os-release')
        # PRETTY_NAME=RDK (A Yocto Project 1.6 based Distro) 2.0 (krogoth)
        board.expect('PRETTY_NAME=([^\s]*) \(A Yocto Project (?:[^\s]*?)\s?based Distro\) ([^\s]*) \(([^\)]*)\)')

        index = 1
        bsp_type = board.match.group(index)
        index += 1
        if len(board.match.groups()) == 4:
            oe_version = board.match.group(index)
            index += 1
        else:
            oe_version = "Unknown"
        bsp_version = board.match.group(index)
        index += 1
        oe_version_string = board.match.group(index)
        index += 1

        board.expect(prompt)

        print("#########################################")
        print("bsp-type = %s" % bsp_type)
        print("oe-version = %s" % oe_version)
        print("bsp-version = %s" % bsp_version)
        print("oe-version-string = %s" % oe_version_string)
        print("#########################################")

        self.result_message="BSP = %s, BSP version = %s, OE version = %s, OE version string = %s" % \
                (bsp_type, bsp_version, oe_version, oe_version_string)
        self.logged['bsp-type'] = bsp_type
        self.logged['oe-version'] =  oe_version
        self.logged['bsp-version'] =  bsp_version
        self.logged['oe-version-string'] = oe_version_string
示例#6
0
 def runTest(self):
     wlan_iface = lib.wifi.wifi_interface(board)
     lib.wifi.enable_wifi(board)
     lib.wifi.wait_wifi_up(board, wlan_iface=wlan_iface)
     board.sendline("\nifconfig")
     board.expect("HWaddr")
     board.expect(prompt)
示例#7
0
文件: opkg.py 项目: mtusnio/boardfarm
 def runTest(self):
     board.sendline('\nopkg list-installed | grep qos-scripts')
     try:
         board.expect('qos-scripts - ', timeout=4)
     except:
         return   # pass if not installed
     assert False # fail if installed
示例#8
0
    def runTest(self):
        board.sendline('cat /etc/os-release')
        # PRETTY_NAME=RDK (A Yocto Project 1.6 based Distro) 2.0 (krogoth)
        if 0 == board.expect(["cat: can't open '/etc/os-release': No such file or directory", 'PRETTY_NAME=([^\s]*) \(A Yocto Project (?:[^\s]*?)\s?based Distro\) ([^\s]*) \(([^\)]*)\)']):
            self.skipTest("Skipping, not not an OE based distro")

        index = 1
        bsp_type = board.match.group(index)
        index += 1
        if len(board.match.groups()) == 4:
            oe_version = board.match.group(index)
            index += 1
        else:
            oe_version = "Unknown"
        bsp_version = board.match.group(index)
        index += 1
        oe_version_string = board.match.group(index)
        index += 1

        board.expect(prompt)

        print("#########################################")
        print("bsp-type = %s" % bsp_type)
        print("oe-version = %s" % oe_version)
        print("bsp-version = %s" % bsp_version)
        print("oe-version-string = %s" % oe_version_string)
        print("#########################################")

        self.result_message="BSP = %s, BSP version = %s, OE version = %s, OE version string = %s" % \
                (bsp_type, bsp_version, oe_version, oe_version_string)
        self.logged['bsp-type'] = bsp_type
        self.logged['oe-version'] =  oe_version
        self.logged['bsp-version'] =  bsp_version
        self.logged['oe-version-string'] = oe_version_string
示例#9
0
    def runTest(self, client=wan, server=lan):
        mpstat_present = self.mpstat_ok()

        # this is running an arbitrary time, we will ctrl-c and get results
        self.run_iperf_server(server,
                              opts=self.server_opts_reverse(node=server))
        if mpstat_present:
            board.sendline('mpstat -P ALL 10000 1')
            board.expect('Linux')
        self.run_iperf(client, opts=opts, target=self.reverse_ip())
        rate = self.parse_iperf(client)
        if mpstat_present:
            board.sendcontrol('c')
            board.expect(
                'Average.*idle\r\nAverage:\s+all(\s+[0-9]+.[0-9]+){10}\r\n')
            idle_cpu = float(board.match.group(1))
            avg_cpu = 100 - float(idle_cpu)
            self.logged['avg_cpu'] = float(avg_cpu)
        else:
            avg_cpu = "N/A"

        self.kill_iperf(server)
        msg = 'iPerf from WAN to LAN (%s Mbps, CPU=%s)' % (rate, avg_cpu)
        lib.common.test_msg("\n%s" % msg)

        self.logged['rate'] = float(rate)
        self.result_message = msg
示例#10
0
 def runTest(self):
     board.sendline('\nopkg list-installed | grep qos-scripts')
     try:
         board.expect('qos-scripts - ', timeout=4)
     except:
         return  # pass if not installed
     assert False  # fail if installed
 def runTest(self):
     num_conn = 5000
     # Wan device: Create small file in web dir
     fname = 'small.txt'
     cmd = '\nhead -c 10000 /dev/urandom > /var/www/%s' % fname
     wan.sendline(cmd)
     wan.expect(prompt)
     # Lan Device: download small file a lot
     concurrency = 25
     url = 'http://192.168.0.1/%s' % fname
     # Start CPU monitor
     board.sendline('\nmpstat -P ALL 10000 1')
     # Lan Device: download small file a lot
     lan.sendline('\nab -dn %s -c %s %s' % (num_conn, concurrency, url))
     lan.expect('Benchmarking', timeout=5)
     lan.expect('Requests per second:\s+(\d+)')
     reqs_per_sec = int(lan.match.group(1))
     lan.expect(prompt)
     # Stop CPU monitor
     board.sendcontrol('c')
     board.expect('Average:\s+all(\s+[0-9]+.[0-9]+){10}\r\n')
     idle_cpu = float(board.match.group(1))
     avg_cpu = 100 - float(idle_cpu)
     board.expect(prompt)
     msg = "ApacheBench measured %s connections/second, CPU use = %s%%." % (
         reqs_per_sec, avg_cpu)
     self.result_message = msg
     time.sleep(5)  # Give router a few seconds to recover
示例#12
0
    def recover(self):
        board.touch()
        lan.sendcontrol('c')
        lan.expect(prompt)
        board.touch()

        print "Copying files from lan to dir = %s" % self.config.output_dir
        lan.sendline('readlink -f $HOME/%s/' % self.dir)
        lan.expect_exact('$HOME/%s/' % self.dir)
        board.touch()
        lan.expect(prompt)
        board.touch()
        fname = lan.before.replace('\n', '').replace('\r', '')
        board.touch()
        rm_r(os.path.join(self.config.output_dir, self.dir))
        scp_from(fname, lan.ipaddr, lan.username, lan.password, lan.port,
                 self.config.output_dir)

        # let board settle down
        board.expect(pexpect.TIMEOUT, timeout=30)
        board.touch()

        board.parse_stats(dict_to_log=self.logged)
        board.touch()
        self.result_message = 'JMeter: DONE, name = %s cpu usage = %s' % (
            self.shortname, self.logged['mpstat'])
示例#13
0
    def recover(self):
        if self.__class__.__name__ == "RootFSBootTest":
            try:
                if board.linux_booted:
                    board.sendline('ps auxfw || ps w')
                    board.expect(prompt)
                    board.sendline('iptables -S')
                    board.expect(prompt)
            except:
                pass

            board.close()
            lib.common.test_msg("Unable to boot, skipping remaining tests...")
            return
        try:
            # let user interact with console if test failed
            try:
                board.sendline()
                board.sendline()
                if not self.config.batch:
                    board.interact()
            except:
                pass
            if self.reboot == True and self.reset_after_fail:
                self.boot(self.reflash)
            self.reboot = True
        except Exception as e:
            print("Unable to recover, %s" % e)
            self.assertEqual(1, 0, e)
示例#14
0
    def recover(self):
        if self.__class__.__name__ == "RootFSBootTest":
            try:
                if board.linux_booted:
                    board.sendline('ps auxfw || ps w')
                    board.expect(prompt)
                    board.sendline('iptables -S')
                    board.expect(prompt)
            except:
                pass

            board.close()
            lib.common.test_msg("Unable to boot, skipping remaining tests...")
            return
        try:
            # let user interact with console if test failed
            try:
                board.sendline()
                board.sendline()
                if not self.config.batch:
                    board.interact()
            except:
                pass
            if self.reboot == True and self.reset_after_fail:
                self.boot(self.reflash)
            self.reboot = True
        except Exception as e:
            print("Unable to recover, %s" % e)
            self.assertEqual(1, 0, e)
    def runTest(self):
        #for d in [wan, lan]:
            #d.sendline('apt-get update && apt-get -o Dpkg::Options::="--force-confnew" -y install socat pv')
            #d.expect(prompt)

        max_time = 0
        single_max = 45

        # TODO: query interfaces but this is OK for now
        for i in range(1000):
            # keep long running test alive
            board.sendline()
            board.expect(prompt)
            print ("Starting connection %s" % i)
            sz, rate, ip, port = self.startSingleUDP(maxtime=single_max)
            print ("started UDP to %s:%s sz = %s, rate = %sk" % (ip, port, sz, rate))

            max_time = max(max_time, sz / ( rate * 1024))
            self.check_and_clean_ips()

        print ("waiting max time of %ss" % max_time)

        start = time.time()
        while time.time() - start < max_time + 5:
            lan.sendline('wait')
            lan.expect_exact('wait')
            if 0 != lan.expect([pexpect.TIMEOUT] + prompt, timeout=max_time + 5):
                lan.sendcontrol('c')
                lan.expect(prompt)
                self.check_and_clean_ips()

        self.recover()
示例#16
0
    def runTest(self):
        try:
            x, y = config.get_display_backend_size()
            # try to start vnc server
            self.display = Display(backend=config.default_display_backend,
                                   rfbport=config.default_display_backend_port,
                                   visible=0,
                                   size=(x, y))
            self.display.start()

            if "BFT_DEBUG" in os.environ:
                print("Connect to VNC display running on localhost:" +
                      config.default_display_backend_port)
                raw_input("Press any key after connecting to display....")
        except:
            # fallback xvfb
            self.display = Display(visible=0, size=(1366, 768))
            self.display.start()

        try:
            if lan.http_proxy is not None:
                proxy = lan.http_proxy
            elif lan.ipaddr is not None:
                ip = lan.ipaddr
                lan.sendline('cat /proc/net/vlan/config')
                lan.expect('eth1.*\|\s([0-9]+).*\|')
                port = 8000 + int(lan.match.group(1))
                lan.expect(prompt)
                proxy = "%s:%s" % (ip, port)
            else:
                # no proxy, use message below
                assert False
        except Exception as e:
            print e
            raise Exception(
                "No reasonable http proxy found, please add one to the board config"
            )

        print("Using proxy %s" % proxy)
        driver = lib.common.get_webproxy_driver(proxy)
        print("taking ss of http://%s" % board.lan_gateway)
        driver.get("http://%s" % board.lan_gateway)

        # wait for possible redirects to settle down
        url = driver.current_url
        for i in range(10):
            board.expect(pexpect.TIMEOUT, timeout=5)
            if url == driver.current_url:
                break
            url = driver.current_url
        board.expect(pexpect.TIMEOUT, timeout=10)

        # take screenshot
        driver.save_screenshot(self.config.output_dir + os.sep +
                               'lan_portal.png')

        driver.close()

        self.recover()
示例#17
0
 def runTest(self):
     if not wan:
         msg = 'No WAN Device defined, skipping ping WAN test.'
         lib.common.test_msg(msg)
         self.skipTest(msg)
     board.sendline('\nping -c5 %s' % wan.gw)
     board.expect('5 (packets )?received', timeout=15)
     board.expect(prompt)
示例#18
0
 def runTest(self):
     if not wan:
         msg = 'No WAN Device defined, skipping ping WAN test.'
         lib.common.test_msg(msg)
         self.skipTest(msg)
     board.sendline('\nping -c5 192.168.0.1')
     board.expect('5 packets received', timeout=10)
     board.expect(prompt)
示例#19
0
    def runTest(self):
        for d in [wan, lan]:
            d.sendline('tcpdump -i eth1 -w /tmp/tcpdump.pcap %s' % self.opts)

        board.expect(pexpect.TIMEOUT, timeout=15)

        for d in [wan, lan]:
            d.sendcontrol('c')
示例#20
0
 def runTest(self):
     if not wan:
         msg = 'No WAN Device defined, skipping ping WAN test.'
         lib.common.test_msg(msg)
         self.skipTest(msg)
     board.sendline('\nping -c5 192.168.0.1')
     board.expect('5 packets received', timeout=10)
     board.expect(prompt)
示例#21
0
    def mpstat_ok(self):
        board.sendline('mpstat -V')
        if board.expect(['sysstat version', 'BusyBox', 'not found'], timeout=5) == 0:
            mpstat_present = True
        else:
            mpstat_present = False
        board.expect(prompt)

        return mpstat_present
 def runTest(self):
     for sz in ["74", "128", "256", "512", "1024", "1280", "1518" ]:
         print("running %s UDP test" % sz)
         lan.sendline('netperf -H 192.168.0.1 -t UDP_STREAM -l 60 -- -m %s' % sz)
         lan.expect_exact('netperf -H 192.168.0.1 -t UDP_STREAM -l 60 -- -m %s' % sz)
         lan.expect('UDP UNIDIRECTIONAL')
         lan.expect(prompt, timeout=90)
         board.sendline()
         board.expect(prompt)
示例#23
0
    def mpstat_ok(self):
        board.sendline('mpstat -V')
        if board.expect(['sysstat version', 'BusyBox', 'not found'], timeout=5) == 0:
            mpstat_present = True
        else:
            mpstat_present = False
        board.expect(prompt)

        return mpstat_present
示例#24
0
 def runTest(self):
     board.sendline('\ntop -b -n 1')
     board.expect(pexpect.TIMEOUT, timeout=2)
     try:
         board.expect(prompt, timeout=2)
     except:
         # some versions of top do not support '-n'
         # must CTRL-C to kill top
         board.sendcontrol('c')
示例#25
0
文件: status.py 项目: qca/boardfarm
 def runTest(self):
     board.sendline('\ntop -b -n 1')
     board.expect('Mem:', timeout=5)
     try:
         board.expect(prompt, timeout=2)
     except:
         # some versions of top do not support '-n'
         # must CTRL-C to kill top
         board.sendcontrol('c')
示例#26
0
 def recover(self):
     lan.sendcontrol('c')
     lan.expect(lan.prompt)
     lan.sendline('rm -rf Fedora*')
     lan.expect(lan.prompt)
     board.sendcontrol('c')
     board.expect(board.prompt)
     board.sendline('fg')
     board.sendcontrol('c')
     board.expect(board.prompt)
示例#27
0
 def runTest(self):
     for sz in ["74", "128", "256", "512", "1024", "1280", "1518"]:
         print("running %s UDP test" % sz)
         lan.sendline(
             'netperf -H 192.168.0.1 -t UDP_STREAM -l 60 -- -m %s' % sz)
         lan.expect_exact(
             'netperf -H 192.168.0.1 -t UDP_STREAM -l 60 -- -m %s' % sz)
         lan.expect('UDP UNIDIRECTIONAL')
         lan.expect(prompt, timeout=90)
         board.sendline()
         board.expect(prompt)
示例#28
0
 def runTest(self):
     board.sendline('\nls -l /etc/config/')
     board.expect('/etc/config/', timeout=5)
     board.expect(prompt)
     board.sendline('ls -l /etc/config/ | wc -l')
     board.expect('(\d+)\r\n')
     num_files = int(board.match.group(1))
     board.expect(prompt)
     board.sendline('uci show')
     board.expect(prompt, searchwindowsize=50)
     self.result_message = 'Dumped all current uci settings from %s files in /etc/config/.' % num_files
示例#29
0
文件: status.py 项目: qca/boardfarm
 def runTest(self):
     board.sendline('\nls -l /etc/config/')
     board.expect('/etc/config/', timeout=5)
     board.expect(prompt)
     board.sendline('ls -l /etc/config/ | wc -l')
     board.expect('(\d+)\r\n')
     num_files = int(board.match.group(1))
     board.expect(prompt)
     board.sendline('uci show')
     board.expect(prompt, searchwindowsize=50)
     self.result_message = 'Dumped all current uci settings from %s files in /etc/config/.' % num_files
示例#30
0
 def runTest(self):
     variables=['loadaddr=0x0E000000', 'stdin=uart@18101500', 'boot_partition=(\d)']
     board.sendline('fw_printenv | tee uboot_vars && echo \"U-boot environment variables\"')
     board.expect('U-boot environment variables')
     board.expect(prompt)
     for v in variables:
         board.sendline('egrep -o "{}" uboot_vars'.format(v))
         board.expect(v)
         board.expect(prompt)
     board.sendline('\nrm -f uboot_vars')
     board.expect(prompt)
示例#31
0
    def runTest(self):
        super(NetperfTest, self).runTest()

        board.sendline('mpstat -P ALL 30 1')
        speed = self.run_netperf(lan, "192.168.0.1 -c -C -l 30")
        board.expect('Average.*idle\r\nAverage:\s+all(\s+[0-9]+.[0-9]+){10}\r\n')
        idle_cpu = float(board.match.group(1))
        avg_cpu = 100 - float(idle_cpu)
        lib.common.test_msg("Average cpu usage was %s" % avg_cpu)

        self.result_message = "Setup Netperf and Ran Throughput (Speed = %s 10^6bits/sec, CPU = %s)" % (speed, avg_cpu)
示例#32
0
    def runTest(self):
        super(NetperfTest, self).runTest()

        board.sendline('mpstat -P ALL 30 1')
        speed = self.run_netperf(lan, "192.168.0.1 -c -C -l 30")
        board.expect(
            'Average.*idle\r\nAverage:\s+all(\s+[0-9]+.[0-9]+){10}\r\n')
        idle_cpu = float(board.match.group(1))
        avg_cpu = 100 - float(idle_cpu)
        lib.common.test_msg("Average cpu usage was %s" % avg_cpu)

        self.result_message = "Setup Netperf and Ran Throughput (Speed = %s 10^6bits/sec, CPU = %s)" % (
            speed, avg_cpu)
示例#33
0
    def runTest(self):
        wlan_iface = wifi_interface(board)
        if wlan_iface is None:
            self.skipTest("No wifi interfaces detected, skipping..")

        board.sendline('\nuci show wireless')
        board.expect('uci show wireless')
        board.expect(prompt)
        wifi_interfaces = re.findall('wireless.*=wifi-device', board.before)
        self.result_message = "UCI shows %s wifi interface(s)." % (len(wifi_interfaces))
        self.logged['num_ifaces'] = len(wifi_interfaces)
        # Require that at least one wifi interface is present
        assert len(wifi_interfaces) > 0
示例#34
0
 def runTest(self):
     board.sendline('\n')
     board.expect(prompt)
     board.sendline('opkg install ca-certificates')
     board.expect(prompt)
     checks = [
         ('https://expired.badssl.com/', 'certificate has expired'),
         ('https://wrong.host.badssl.com/',
          'no alternative certificate subject name matches target host name'
          ),
         ('https://subdomain.preloaded-hsts.badssl.com/',
          'no alternative certificate subject name matches target host name'
          ),
         ('https://self-signed.badssl.com/',
          'unable to get local issuer certificate'),
         ('https://superfish.badssl.com/',
          'unable to get local issuer certificate'),
         ('https://edellroot.badssl.com/',
          'unable to get local issuer certificate'),
         ('https://dsdtestprovider.badssl.com/',
          'unable to get local issuer certificate'),
         ('https://incomplete-chain.badssl.com/',
          'unable to get local issuer certificate'),
     ]
     for check in checks:
         board.sendline('curl ' + check[0])
         board.expect(check[1])
         board.expect(prompt)
         print('\n\nCurl refused to download ' + check[0] +
               ' as expected\n')
示例#35
0
 def runTest(self):
     lan.sendline('nmap -sS -A -v -p 1-10000 %s' %
                  board.get_interface_ipaddr(board.lan_iface))
     lan.expect('Starting Nmap')
     for i in range(12):
         if 0 == lan.expect(['Nmap scan report', pexpect.TIMEOUT],
                            timeout=100):
             break
         board.sendcontrol('c')
         board.expect(prompt)
     lan.expect(prompt, timeout=60)
     open_ports = re.findall("(\d+)/tcp\s+open", lan.before)
     msg = "Found %s open TCP ports on LAN interface: %s." % \
         (len(open_ports), ", ".join(open_ports))
     self.result_message = msg
示例#36
0
    def runTest(self):
        super(NetperfTest, self).runTest()

        board.arm.sendline('mpstat -P ALL 30 1')
        board.arm.expect('Linux')

        speed = self.run_netperf(lan, "%s -c -C -l 30" % wan.gw)

        board.sendcontrol('c')
        board.expect('Average.*idle\r\nAverage:\s+all(\s+[0-9]+.[0-9]+){9}\r\n',timeout=60)
        idle_cpu = float(board.match.group(1))
        avg_cpu = 100 - float(idle_cpu)
        lib.common.test_msg("Average cpu usage was %s" % avg_cpu)
        self.kill_netserver(wan)

        self.result_message = "Setup Netperf and Ran Throughput (Speed = %s 10^6bits/sec, CPU = %s)" % (speed, avg_cpu)
    def runTest(self):
        #for d in [wan, lan]:
            #d.sendline('apt-get update && apt-get -o Dpkg::Options::="--force-confnew" -y install socat pv')
            #d.expect(prompt)

        sz, rate, ip, port = self.startSingleUDP()
        print ("started UDP to %s:%s sz = %s, rate = %sk" % (ip, port, sz, rate))
        time = sz / ( rate * 1024)
        print("time should be ~%s" % time)
        self.check_and_clean_ips()
        lan.sendline('fg')
        lan.expect(prompt, timeout=time+10)

        board.sendline('cat /proc/net/nf_conntrack | grep dst=%s.*dport=%s' % (ip, port))
        board.expect(prompt)

        self.recover()
示例#38
0
 def runTest(self):
     board.sendline("\n/etc/init.d/mcproxy stop")
     board.expect(prompt)
     board.sendline("ps | grep mcproxy")
     board.expect(prompt)
     assert "/usr/sbin/mcproxy" not in board.before
     board.sendline("/etc/init.d/mcproxy start")
     board.sendline("ps | grep mcproxy")
     board.expect("/usr/sbin/mcproxy -f /etc/mcproxy.conf", timeout=5)
     board.expect(prompt)
示例#39
0
 def runTest(self):
     board.sendline('\nlsmod | wc -l')
     board.expect('lsmod ')
     board.expect('(\d+)\r\n')
     num = int(board.match.group(1)) - 1 # subtract header line
     board.expect(prompt)
     board.sendline('lsmod | sort')
     board.expect(prompt)
     self.result_message = '%s kernel modules are loaded.' % num
     self.logged['num_loaded'] = num
示例#40
0
 def runTest(self):
     board.sendline('\n/etc/init.d/mcproxy stop')
     board.expect(prompt)
     board.sendline('ps | grep mcproxy')
     board.expect(prompt)
     assert '/usr/sbin/mcproxy' not in board.before
     board.sendline('/etc/init.d/mcproxy start')
     board.sendline('ps | grep mcproxy')
     board.expect('/usr/sbin/mcproxy -f /etc/mcproxy.conf', timeout=5)
     board.expect(prompt)
示例#41
0
    def runTest(self):
        self.logged.update(board.get_proc_vmstat())

        # Display extra info
        board.sendline('cat /proc/slabinfo /proc/buddyinfo /proc/meminfo')
        board.expect('cat /proc/')
        board.expect(prompt)
        board.sendline('cat /proc/vmallocinfo')
        board.expect('cat /proc/vmallocinfo')
        board.expect(prompt)
示例#42
0
文件: opkg.py 项目: mtusnio/boardfarm
 def runTest(self):
     board.sendline('\nopkg list-installed | wc -l')
     board.expect('opkg list')
     board.expect('(\d+)\r\n')
     num_pkgs = int(board.match.group(1))
     board.expect(prompt)
     board.sendline('opkg list-installed')
     board.expect(prompt)
     self.result_message = '%s OpenWrt packages are installed.' % num_pkgs
     self.logged['num_installed'] = num_pkgs
示例#43
0
 def runTest(self):
     board.sendline('\nopkg list-installed | wc -l')
     board.expect('opkg list')
     board.expect('(\d+)\r\n')
     num_pkgs = int(board.match.group(1))
     board.expect(prompt)
     board.sendline('opkg list-installed')
     board.expect(prompt)
     self.result_message = '%s OpenWrt packages are installed.' % num_pkgs
     self.logged['num_installed'] = num_pkgs
示例#44
0
 def runTest(self):
     board.sendline('\nhead -c 1000000 /dev/urandom > /www/deleteme.txt')
     board.expect('head ', timeout=5)
     board.expect(prompt)
     lan.sendline('\ncurl -m 25 http://192.168.1.1/deleteme.txt > /dev/null')
     lan.expect('Total', timeout=5)
     lan.expect('100 ', timeout=10)
     lan.expect(prompt, timeout=10)
     board.sendline('\nrm -f /www/deleteme.txt')
     board.expect('deleteme.txt')
     board.expect(prompt)
示例#45
0
 def runTest(self):
     board.sendline("\nuci show mcproxy")
     board.expect_exact("mcproxy.config=mcproxy", timeout=5)
     board.expect_exact("mcproxy.config.protocol=IGMPv3", timeout=5)
     board.expect_exact("mcproxy.@pinstance[0]=pinstance", timeout=5)
     board.expect_exact("mcproxy.@pinstance[0].name=mcproxy1", timeout=5)
     board.expect(prompt)
     board.sendline("cat /etc/mcproxy.conf")
     board.expect("protocol IGMPv3;", timeout=5)
     board.expect('pinstance mcproxy1: "eth0" ==> "br-lan";')
     board.expect(prompt)
示例#46
0
 def runTest(self):
     board.sendline('\nuci show mcproxy')
     board.expect_exact('mcproxy.config=mcproxy', timeout=5)
     board.expect_exact('mcproxy.config.protocol=IGMPv3', timeout=5)
     board.expect_exact('mcproxy.@pinstance[0]=pinstance', timeout=5)
     board.expect_exact('mcproxy.@pinstance[0].name=mcproxy1', timeout=5)
     board.expect(prompt)
     board.sendline('cat /etc/mcproxy.conf')
     board.expect('protocol IGMPv3;', timeout=5)
     board.expect('pinstance mcproxy1: "eth0" ==> "br-lan";')
     board.expect(prompt)
示例#47
0
 def runTest(self):
     # One package per feed: packages, openwrt-routing, openwrt-managements,
     # ci40-platform-feed, telephony, luci, kernel-module
     packages = [ "nano", "mrd6", "libssh", "glog", "miax", "luci-mod-rpc" , "kmod-usb-net-qmi-wwan" ]
     for pkg in packages:
         board.sendline('\nopkg remove --autoremove {}'.format(pkg))
         board.expect('Removing package {}'.format(pkg))
         board.expect(prompt)
         board.sendline('\nopkg list-installed | grep {}'.format(pkg))
         try:
             board.expect('{} - '.format(pkg))
             assert False # fail if installed
         except:
             pass   # pass if not installed
     # Check for removing packages which are not installed or already removed
     for pkg in packages:
         board.sendline("\nopkg remove --autoremove {}".format(pkg))
         board.expect("No packages removed")
         board.expect(prompt)
示例#48
0
文件: status.py 项目: qca/boardfarm
 def runTest(self):
     board.sendline('\nsync; echo 3 > /proc/sys/vm/drop_caches')
     board.expect('echo 3')
     board.expect(prompt, timeout=5)
     # There appears to be a tiny, tiny chance that
     # /proc/meminfo won't exist, so try one more time.
     for i in range(2):
         try:
             board.sendline('cat /proc/meminfo')
             board.expect('MemTotal:\s+(\d+) kB', timeout=5)
             break
         except:
             pass
     mem_total = int(board.match.group(1))
     board.expect('MemFree:\s+(\d+) kB')
     mem_free = int(board.match.group(1))
     board.expect(prompt)
     mem_used = mem_total - mem_free
     self.result_message = 'Used memory: %s MB. Free memory: %s MB.' % (mem_used/1000, mem_free/1000)
     self.logged['mem_used'] = mem_used/1000
示例#49
0
    def runTest(self):
        # setup port forwarding to lan netperf server
        lan_priv_ip = lan.get_interface_ipaddr("eth1")
        board.uci_forward_traffic_redirect("tcp", "12865", lan_priv_ip)
        # setup port for data socket separate from control port
        board.uci_forward_traffic_redirect("tcp", "12866", lan_priv_ip)

        wan_ip = board.get_interface_ipaddr(board.wan_iface)

        # send at router ip, which will forward to lan client
        wan.sendline('')
        wan.expect(prompt)
        board.sendline('mpstat -P ALL 30 1')
        speed = self.run_netperf(wan, wan_ip, "-c -C -l 30 -t TCP_STREAM -- -P ,12866")
        board.expect('Average.*idle\r\nAverage:\s+all(\s+[0-9]+.[0-9]+){10}\r\n')
        idle_cpu = float(board.match.group(1))
        avg_cpu = 100 - float(idle_cpu)
        lib.common.test_msg("Average cpu usage was %s" % avg_cpu)

        self.result_message = "Setup NetperfReverse and Ran Throughput (Speed = %s 10^6bits/sec, CPU = %s)" % (speed, avg_cpu)
示例#50
0
def wifi_cycle(board, num_times=5, wlan_iface="ath0"):
    '''Enable and disable wifi some number of times.'''
    if wifi_on(board):
        disable_wifi(board, wlan_iface)
    wifi_name = randomSSIDName()
    board.sendline('uci set wireless.@wifi-iface[0].ssid=%s' % wifi_name)
    board.expect(prompt)
    board.sendline('uci set wireless.@wifi-iface[0].encryption=psk2')
    board.expect(prompt)
    board.sendline('uci set wireless.@wifi-iface[0].key=%s' % randomSSIDName())
    board.expect(prompt)
    board.sendline('echo "7 7 7 7" > /proc/sys/kernel/printk')
    board.expect(prompt)
    for i in range(1, num_times+1):
        enable_wifi(board)
        wait_wifi_up(board, wlan_iface=wlan_iface)
        disable_wifi(board, wlan_iface=wlan_iface)
        print("\n\nEnabled and disabled WiFi %s times." % i)
    board.sendline('echo "1 1 1 7" > /proc/sys/kernel/printk')
    board.expect(prompt)
示例#51
0
    def runTest(self):
        board.sendline('mpstat -P ALL 30 1')
        opts = ""
        num_conns = 1

        up = down = 0.0
        for i in range(0, num_conns):
            self.run_netperf_cmd(lan, "192.168.0.1 -c -C -l 30 -- %s" % opts)
            self.run_netperf_cmd(lan, "192.168.0.1 -c -C -l 30 -t TCP_MAERTS -- %s" % opts)

        for i in range(0, num_conns):
            up += float(self.run_netperf_parse(lan))
            down += float(self.run_netperf_parse(lan))

        board.expect('Average.*idle\r\nAverage:\s+all(\s+[0-9]+.[0-9]+){10}\r\n')
        idle_cpu = float(board.match.group(1))
        avg_cpu = 100 - float(idle_cpu)

        msg = "Bidir speed was %s 10^6Mbits/sec with %s average cpu" % ((up + down), avg_cpu)
        lib.common.test_msg(msg)
        self.result_message = msg
示例#52
0
    def setUp(self):
        ip = "192.168.1.1"

        super(WebTest, self).setUp()
        if not lan:
            msg = 'No LAN Device defined, skipping web test.'
            lib.common.test_msg(msg)
            self.skipTest(msg)

        # Set password, just to be sure
        board.sendline("passwd")
        board.expect("New password:"******"password")
        board.expect("Retype password:"******"password")
        board.expect(prompt)

        # Create a driver
        self.driver = lib.common.phantom_webproxy_driver('http://' + lan.name + ':8080')
        self.driver.get("http://%s/cgi-bin/luci" % ip)
        self.assertIn(ip, self.driver.current_url)
        self.assertIn('LuCI', self.driver.title)
        self.driver.find_element_by_name('luci_password').send_keys('password')
        self.driver.find_element_by_class_name('cbi-button-apply').submit()
        self.driver.find_element_by_xpath("//ul/li/a[contains(text(),'Status')]")
示例#53
0
文件: status.py 项目: qca/boardfarm
 def runTest(self):
     board.sendline('\nifconfig')
     board.expect('ifconfig')
     board.expect(prompt)
     results = re.findall('([A-Za-z0-9-\.]+)\s+Link.*\n.*addr:([^ ]+)', board.before)
     tmp = ', '.join(["%s %s" % (x, y) for x, y in results])
     board.sendline('route -n')
     board.expect(prompt)
     self.result_message = 'ifconfig shows ip addresses: %s' % tmp
示例#54
0
 def runTest(self):
     board.sendline('\nuci delete network.lan.ip6addr')
     board.expect('uci ')
     board.expect(prompt)
     board.sendline('uci delete network.wan.ip6addr')
     board.expect(prompt)
     board.sendline('ip -6 addr delete 5aaa::1/64 dev eth0')
     board.expect(prompt)
     board.sendline('uci commit network')
     board.expect(prompt)
     board.network_restart()
     # Lan-side Device
     lan.sendline('\nip -6 addr del 4aaa::6/64 dev eth1')
     lan.expect('ip -6')
     lan.expect(prompt)
     lan.sendline('ip -6 route del default')
     lan.expect(prompt)
     # Wan-side Device
     wan.sendline('\nip -6 addr del 5aaa::6/64 dev eth1')
     wan.expect('ip -6')
     wan.expect(prompt)
     wan.sendline('ip -6 route del default')
     wan.expect(prompt)
     time.sleep(10)
示例#55
0
    def recover(self):
        if hasattr(self, 'results'):
            r = self.results.get(self.job_id)

            if r.status == "running":
                self.results.stop(self.job_id)
        # TODO: full recovery...
        for d in [wan,lan]:
            d.sendline('ifconfig eth1 up')
            d.expect(prompt)

        # make sure board is back in a sane state
        board.sendcontrol('c')
        board.sendline()
        if 0 != board.expect([pexpect.TIMEOUT] + board.uprompt, timeout=5):
            board.reset()
            board.wait_for_linux()