Example #1
0
    def test_poweroff(self):
        """Measure system power off time
        @fn test_poweroff
        @param self
        @return
        """
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        port = "/dev/ttyACM0"
        running = True
        search_s = "Poweroff time: "
    
        ser = serial.Serial(port, 9600, timeout=5.0)
        time.sleep(2)       #wait for serial port available
        ser.write('s')      #ask arduino to check power singnal
        (status, out)=self.target.run('poweroff &')
        while running:
            data = ser.readline()
            print data
            i = data.find(search_s)
            if (i != -1):
                running = False
                time_p = data[(i+len(search_s)):]

        poweroff_t = str(float(time_p)/1000.0) + "s"
        collect_pnp_log(casename, casename, poweroff_t)
        print "\n%s:%s\n" % (casename, poweroff_t)
        ##
        # TESTPOINT: #1, test_poweroff
        #
        self.assertEqual(status, 0, poweroff_t)

        ser.write('o')      #ask arduino to power on device
        ser.close()
Example #2
0
    def test_netperf(self):
        """Use Netperf to measure network bandwidth
        @fn test_netperf
        @param self
        @return
        """
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        
        (status, output) = self.target.run(
            "/tmp/netperf -t TCP_STREAM -l 60 -H %s"
            ">/tmp/netperf-detail.log" % self.target.server_ip)
        
        (status, output) = self.target.run(
            "cat /tmp/netperf-detail.log | tail -1 | awk '{print $5}'")
        netperf_res = output + "Mb/s"
        collect_pnp_log(casename, casename, netperf_res)
        print "\n%s:%s\n" % (casename, netperf_res)
        ##
        # TESTPOINT: #1, test_netperf
        #
        self.assertEqual(status, 0, netperf_res)

        (status, output) = self.target.run(
            "cat /tmp/netperf-detail.log")
        logname = casename + "-detail"
        collect_pnp_log(casename, logname, output)
Example #3
0
    def test_cpuusage(self):
        """Measure system idle CPU usage
        @fn test_cpuusage
        @param self
        @return
        """
        # self._reboot()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        (status, output) = self.target.run(
            "top -b -d 10 -n 12 >/tmp/top.log")
        (status, output) = self.target.run(
            "cat /tmp/top.log | grep -i 'CPU' | grep 'id*' | "
            "tail -10 | awk '{print $8}' | "
            "awk -F '%' '{sum+=$1} END {print sum/NR}'")
        cpu_idle = float(output)
        cpu_idle = float("{0:.2f}".format(cpu_idle))
        cpu_used = str(100 - cpu_idle) + "%"
        collect_pnp_log(casename, casename, cpu_used)
        print "\n%s:%s\n" % (casename, cpu_used)
        ##
        # TESTPOINT: #1, test_cpuusage
        #
        self.assertEqual(status, 0, cpu_used)

        (status, output) = self.target.run(
            "cat /tmp/top.log")
        logname = casename + "-topinfo"
        collect_pnp_log(casename, logname, output)
Example #4
0
    def test_netperf(self):
        """Use Netperf to measure network bandwidth
        @fn test_netperf
        @param self
        @return
        """
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]

        (status, output) = self.target.run(
            "/tmp/netperf -t TCP_STREAM -l 60 -H %s"
            ">/tmp/netperf-detail.log" % self.target.server_ip)

        (status, output) = self.target.run(
            "cat /tmp/netperf-detail.log | tail -1 | awk '{print $5}'")
        netperf_res = output + "Mb/s"
        collect_pnp_log(casename, casename, netperf_res)
        print "\n%s:%s\n" % (casename, netperf_res)
        ##
        # TESTPOINT: #1, test_netperf
        #
        self.assertEqual(status, 0, netperf_res)

        (status, output) = self.target.run("cat /tmp/netperf-detail.log")
        logname = casename + "-detail"
        collect_pnp_log(casename, logname, output)
Example #5
0
    def test_mem(self):
        """Mem_Used = Mem_Total - Mem_Available
        @fn test_mem
        @param self
        @return
        """
        # self._reboot()
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        (status, output) = self.target.run(
            "cat /proc/meminfo" " | grep 'MemTotal' | awk '{print $2}'")
        mem_total = int(output)
        (status, output) = self.target.run(
            "cat /proc/meminfo" " | grep 'MemAvailable' | awk '{print $2}'")
        mem_available = int(output)
        mem_used = str(mem_total - mem_available) + "KB"
        collect_pnp_log(casename, casename, mem_used)
        print "\n%s:%s\n" % (casename, mem_used)
        ##
        # TESTPOINT: #1, test_mem
        #
        self.assertEqual(status, 0, mem_used)

        (status, output) = self.target.run(
            "cat /proc/meminfo")
        logname = casename + "-meminfo"
        collect_pnp_log(casename, logname, output)
Example #6
0
    def test_power(self):
        """Measure power consumption
        @fn test_power
        @param self
        @return
        """
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]

        powermonitor = "/dev/ttyUSB0"
        resistance = 0
        voltage = 12
        measure_time = 120

        (status, output) = shell_cmd_timeout(
            "timeout %d rs2 %s %d %d > /tmp/power.log" %
            (measure_time, powermonitor, resistance, voltage))
        (status,
         output) = shell_cmd_timeout("cat /tmp/power.log | "
                                     "awk '{sum+=$4} END {print sum/NR}'")
        ##
        # TESTPOINT: #1, test_power
        #
        self.assertEqual(status, 0, output)
        collect_pnp_log(casename, casename, output)
        print "\n%s:%s\n" % (casename, output)

        (status, output) = shell_cmd_timeout("cat /tmp/power.log")
        logname = casename + "-detail"
        collect_pnp_log(casename, logname, output)
Example #7
0
    def test_power(self):
        """Measure power consumption
        @fn test_power
        @param self
        @return
        """
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        
        powermonitor="/dev/ttyUSB0"
        resistance=0
        voltage=12
        measure_time=120

        (status, output) = shell_cmd_timeout("timeout %d rs2 %s %d %d > /tmp/power.log" 
                % (measure_time, powermonitor, resistance, voltage))
        (status, output) = shell_cmd_timeout("cat /tmp/power.log | "
                "awk '{sum+=$4} END {print sum/NR}'")
        ##
        # TESTPOINT: #1, test_power
        #
        self.assertEqual(status, 0, output)
        collect_pnp_log(casename, casename, output)
        print "\n%s:%s\n" % (casename, output)

        (status, output) = shell_cmd_timeout(
            "cat /tmp/power.log")
        logname = casename + "-detail"
        collect_pnp_log(casename, logname, output) 
Example #8
0
    def test_cpuusage(self):
        """Measure system idle CPU usage
        @fn test_cpuusage
        @param self
        @return
        """
        # self._reboot()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        (status, output) = self.target.run("top -b -d 10 -n 12 >/tmp/top.log")
        (status, output) = self.target.run(
            "cat /tmp/top.log | grep -i 'CPU' | grep 'id*' | "
            "tail -10 | awk '{print $8}' | "
            "awk -F '%' '{sum+=$1} END {print sum/NR}'")
        cpu_idle = float(output)
        cpu_idle = float("{0:.2f}".format(cpu_idle))
        cpu_used = str(100 - cpu_idle) + "%"
        collect_pnp_log(casename, casename, cpu_used)
        print "\n%s:%s\n" % (casename, cpu_used)
        ##
        # TESTPOINT: #1, test_cpuusage
        #
        self.assertEqual(status, 0, cpu_used)

        (status, output) = self.target.run("cat /tmp/top.log")
        logname = casename + "-topinfo"
        collect_pnp_log(casename, logname, output)
Example #9
0
    def test_mem(self):
        """Mem_Used = Mem_Total - Mem_Available
        @fn test_mem
        @param self
        @return
        """
        # self._reboot()
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        (status,
         output) = self.target.run("cat /proc/meminfo"
                                   " | grep 'MemTotal' | awk '{print $2}'")
        mem_total = int(output)
        (status,
         output) = self.target.run("cat /proc/meminfo"
                                   " | grep 'MemAvailable' | awk '{print $2}'")
        mem_available = int(output)
        mem_used = str(mem_total - mem_available) + "KB"
        collect_pnp_log(casename, casename, mem_used)
        print "\n%s:%s\n" % (casename, mem_used)
        ##
        # TESTPOINT: #1, test_mem
        #
        self.assertEqual(status, 0, mem_used)

        (status, output) = self.target.run("cat /proc/meminfo")
        logname = casename + "-meminfo"
        collect_pnp_log(casename, logname, output)
Example #10
0
    def test_reboottime(self):
        """Measure system reboot time
        @fn test_reboottime
        @param self
        @return
        """
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        (status, out) = self.target.run('date +"%m-%d %H:%M:%S"; reboot &')
        print "\nReboot start time: %s\n" % (out)
        start_t = datetime.strptime(out, "%m-%d %H:%M:%S")
        #print start_t
        time.sleep(60)

        (status, out) = self.target.run("journalctl -b -a >/tmp/system.log")
        ##
        # TESTPOINT: #1, test_reboottime
        #
        self.assertEqual(status, 0, msg="Error messages: %s" % out)
        (status, out) = self.target.run(" cat /tmp/system.log | "
                                        "grep 'Starting Login' | "
                                        "awk '{print $1, $2, $3}'")
        ##
        # TESTPOINT: #2, test_reboottime
        #
        self.assertEqual(status, 0, msg="Error messages: %s" % out)

        print "\nReboot end time: %s\n" % (out)
        end_t = datetime.strptime(out, "%b %d %H:%M:%S")
        #print end_t
        used_t = end_t - start_t
        reboot_time = used_t.total_seconds()
        reboot_time_str = str(reboot_time) + "s"

        if (reboot_time <= 0):
            print "please check system date:\n"
            print reboot_time_str
            ##
            # TESTPOINT: #3, test_reboottime
            #
            self.assertEqual(-1, 0, reboot_time_str)
        else:
            collect_pnp_log(casename, casename, reboot_time_str)
            print "\n%s:%s\n" % (casename, reboot_time_str)
            ##
            # TESTPOINT: #4, test_reboottime
            #
            self.assertEqual(status, 0, reboot_time_str)
Example #11
0
    def test_reboottime(self):
        """Measure system reboot time
        @fn test_reboottime
        @param self
        @return
        """
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        (status, out)=self.target.run('date +"%m-%d %H:%M:%S"; reboot &')
        print "\nReboot start time: %s\n" % (out)
        start_t = datetime.strptime(out,"%m-%d %H:%M:%S")
        #print start_t
        time.sleep(60)
        
        (status, out)=self.target.run("journalctl -b -a >/tmp/system.log")
        ##
        # TESTPOINT: #1, test_reboottime
        #
        self.assertEqual(status, 0, msg="Error messages: %s" % out)
        (status, out)=self.target.run(" cat /tmp/system.log | "
                "grep 'Starting Login' | "
                "awk '{print $1, $2, $3}'")
        ##
        # TESTPOINT: #2, test_reboottime
        #
        self.assertEqual(status, 0, msg="Error messages: %s" % out)
 
        print "\nReboot end time: %s\n" % (out)
        end_t = datetime.strptime(out,"%b %d %H:%M:%S")
        #print end_t
        used_t = end_t -start_t
        reboot_time = used_t.total_seconds()
        reboot_time_str = str(reboot_time) + "s"
       
        if(reboot_time <= 0):
            print "please check system date:\n"
            print reboot_time_str
            ##
            # TESTPOINT: #3, test_reboottime
            #
            self.assertEqual(-1, 0, reboot_time_str)
        else:
            collect_pnp_log(casename, casename, reboot_time_str)
            print "\n%s:%s\n" % (casename, reboot_time_str)
            ##
            # TESTPOINT: #4, test_reboottime
            #
            self.assertEqual(status, 0, reboot_time_str)
Example #12
0
 def test_disksize(self):
     """use df command to calculate the image installed size
     @fn test_disksize
     @param self
     @return
     """
     filename = os.path.basename(__file__)
     casename = os.path.splitext(filename)[0]
     (status, output) = self.target.run("df -h")
     logname = casename + "-detail"
     collect_pnp_log(casename, logname, output)
     disksize = self._parse_result(casename, logname)
     collect_pnp_log(casename, casename, disksize)
     ##
     # TESTPOINT: #1, test_disksize
     #
     print "\n%s:%s\n" % (casename, output)
     self.assertEqual(status, 0, output)
Example #13
0
 def test_disksize(self):
     """use df command to calculate the image installed size
     @fn test_disksize
     @param self
     @return
     """
     filename = os.path.basename(__file__)
     casename = os.path.splitext(filename)[0]
     (status, output) = self.target.run("df -h")
     logname = casename + "-detail"
     collect_pnp_log(casename, logname, output)
     disksize = self._parse_result(casename,logname)
     collect_pnp_log(casename, casename, disksize)
     ##
     # TESTPOINT: #1, test_disksize
     #
     print "\n%s:%s\n" % (casename, output)
     self.assertEqual(status, 0, output)
Example #14
0
 def test_boot_time(self):
     """Measure boot time with systemd-analyze
     @fn test_boot_time
     @param self
     @return
     """
     self._setup()
     time.sleep(60)
     filename = os.path.basename(__file__)
     casename = os.path.splitext(filename)[0]
     (status, output) = self.target.run("/tmp/systemd-analyze time")
     result = self._parse_result(output)
     boottime = str(result) + "s"
     collect_pnp_log(casename, casename, boottime)
     print "\n%s:%s\n" % (casename, boottime)
     logname = casename + "-systemd-analyze"
     collect_pnp_log(casename, logname, output)
     ##
     # TESTPOINT: #1, test_boot_time
     #
     self.assertEqual(status, 0, output)
Example #15
0
 def test_boot_time(self):
     """Measure boot time with systemd-analyze
     @fn test_boot_time
     @param self
     @return
     """
     self._setup()
     time.sleep(60)
     filename = os.path.basename(__file__)
     casename = os.path.splitext(filename)[0]
     (status, output) = self.target.run("/tmp/systemd-analyze time")
     result = self._parse_result(output)
     boottime = str(result)+"s"
     collect_pnp_log(casename, casename, boottime)
     print "\n%s:%s\n" % (casename, boottime)
     logname = casename + "-systemd-analyze"
     collect_pnp_log(casename, logname, output)
     ##
     # TESTPOINT: #1, test_boot_time
     #
     self.assertEqual(status, 0, output)
Example #16
0
    def test_iozone(self):
        """Use IOzone to measure storage read/write speed
        @fn test_iozone
        @param self
        @return
        """
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]

        (status,
         output) = self.target.run("/tmp/iozone -a -i 0 -i 1 -s 512M -r 1M"
                                   ">/tmp/iozone-detail.log")

        (status,
         output) = self.target.run("cat /tmp/iozone-detail.log | tail -4 | "
                                   "grep '524288'| awk '{print $5/1024}'")
        read_res = "Read: " + output + "MB/s"

        (status,
         output) = self.target.run("cat /tmp/iozone-detail.log | tail -4 | "
                                   "grep '524288'| awk '{print $3/1024}'")
        write_res = "Write:" + output + "MB/s"

        collect_pnp_log(casename, casename, read_res)
        collect_pnp_log(casename, casename, write_res)
        print "\n%s:%s %s\n" % (casename, read_res, write_res)
        ##
        # TESTPOINT: #1, test_iozone
        #
        self.assertEqual(status, 0, read_res)

        (status, output) = self.target.run("cat /tmp/iozone-detail.log")
        logname = casename + "-detail"
        collect_pnp_log(casename, logname, output)