Esempio n. 1
0
    def runjob(self, job):
        if 'buildurl' not in job or 'androidprocname' not in job or \
                'revision' not in job or 'blddate' not in job or \
                'bldtype' not in job or 'version' not in job:
            self.logger.error('Invalid job configuration: %s' % job)
            raise NameError('ERROR: Invalid job configuration: %s' % job)

        if not androidutils.install_build_adb(phoneid=self.phone_cfg['phoneid'],
                                              url=job['buildurl'],
                                              procname=job['androidprocname'],
                                              serial=self.phone_cfg['serial']):
            return

        # Read our config file which gives us our number of
        # iterations and urls that we will be testing
        self.prepare_phone(job)

        self.dm = DeviceManagerSUT(self.phone_cfg['ip'],
                                   self.phone_cfg['sutcmdport'])

        intent = job['androidprocname'] + '/.App'

        for testname,url in self._urls.iteritems():
            self.logger.info('%s: Running test %s for %s iterations' %
                             (self.phone_cfg['phoneid'], testname,
                              self._iterations))
            for i in range(self._iterations):
                # Set status
                self.set_status(msg='Run %s for url %s' % (i,url))

                # Clear logcat
                androidutils.run_adb('logcat', ['-c'], self.phone_cfg['serial'])

                # Get start time
                try:
                    starttime = self.dm.getInfo('uptimemillis')['uptimemillis'][0]
                except IndexError:
                    starttime = 0

                # Run test
                androidutils.run_adb('shell',
                                     ['sh', '/mnt/sdcard/s1test/runbrowser.sh', intent,
                                      url], self.phone_cfg['serial'])

                # Let browser stabilize - this was 5s but that wasn't long
                # enough for the device to stabilize on slow devices
                sleep(10)

                # Get results
                throbberstart, throbberstop, drawtime = self.analyze_logcat()

                # Publish results
                self.publish_results(starttime=int(starttime),
                                     tstrt=throbberstart,
                                     tstop=throbberstop,
                                     drawing=drawtime,
                                     job=job,
                                     testname=testname)
                androidutils.kill_proc_sut(self.phone_cfg['ip'],
                                           self.phone_cfg['sutcmdport'],
                                           job['androidprocname'])
                androidutils.remove_sessionstore_files_adb(
                    self.phone_cfg['serial'],
                    procname=job['androidprocname'])
Esempio n. 2
0
    def runtests(self):
        # Ensure we have a connection to the device
        self.dm = DeviceManagerSUT(self._ip, self._sutcmdport)
        # Get our next job
        while 1:
            if self._jobs.empty() and self.stop:
                # Then we are finished and we should end the thread
                break

            # This blocks until a job arrives
            job = self._jobs.get()
            self._logger.debug("Got job: %s" % job)
            if ("buildurl" not in job or "androidprocname" not in job or
                "revision" not in job or "blddate" not in job or
                "bldtype" not in job or "version" not in job):
                self._logger.error("Invalid job configuration: %s" % job)
                raise NameError("ERROR: Invalid job configuration: %s" % job)
                
            androidutils.install_build_adb(phoneid = self._phoneid,
                                           url=job["buildurl"],
                                           procname = job["androidprocname"],
                                           serial=self._serial)

            # Read our config file which gives us our number of
            # iterations and urls that we will be testing
            self.prepare_phone(job)

            intent = job["androidprocname"] + "/.App"

            for testname,url in self._urls.iteritems():
                self._logger.info("%s: Running test %s for %s iterations" %
                        (self._phoneid, testname, self._iterations))
                for i in range(self._iterations):
                    # Set status
                    self._set_status(msg="Run %s for url %s" % (i,url))

                    # Clear logcat
                    androidutils.run_adb("logcat", ["-c"], self._serial)

                    # Get start time
                    starttime = self.dm.getInfo('uptimemillis')['uptimemillis'][0]

                    # Run test
                    androidutils.run_adb("shell",
                            ["sh", "/mnt/sdcard/s1test/runbrowser.sh", intent,
                                url], self._serial)

                    # Let browser stabilize
                    sleep(5)

                    # Get results
                    throbberstart, throbberstop, drawtime = self.analyze_logcat()

                    # Publish results
                    self.publish_results(starttime=int(starttime),
                                         tstrt=throbberstart,
                                         tstop=throbberstop,
                                         drawing=drawtime,
                                         job = job,
                                         testname = testname)
                    androidutils.kill_proc_sut(self._ip, self._sutcmdport,
                            job["androidprocname"])
                    androidutils.remove_sessionstore_files_adb(self._serial,
                            procname=job["androidprocname"])

            self._jobs.task_done()
            self._logger.debug("Finished job: %s" % job)