Ejemplo n.º 1
0
def get_instance():
    global os_instance
    if os_instance is None:
        os = envstore.get_instance().get_variable('sat_os')
        if os < 0:
            print "\nNo target OS selected"
            print "Please run 'satt config'"
            sys.exit(-1)
        else:
            if os == OsHelper.Linux:
                from satt.common.targetos.os_linux import LinuxOs
                os_instance = LinuxOs()
            elif os == OsHelper.Android:
                from satt.common.targetos.os_android import AndroidOs
                os_instance = AndroidOs()
            elif os == OsHelper.ChromeOS:
                from satt.common.targetos.os_chromeos import ChromeOs
                os_instance = ChromeOs()
            elif os == OsHelper.YoctoOs:
                from satt.common.targetos.os_yocto import YoctoOs
                os_instance = YoctoOs()
            else:
                print "ERROR: Unsupported target OS type (" + os + ")"
                sys.exit(-1)
    return os_instance
Ejemplo n.º 2
0
    def check_version(self):
        version_file = os.path.join(self._sat_path, '.version')
        self._satt_version = ''

        if os.path.isfile(version_file):
            self._satt_version = open(version_file).readline().rstrip()
        else:
            old_dir = os.getcwd()
            os.chdir(self._sat_path)
            try:
                self._satt_version = subprocess.check_output(
                    'git describe --tags --always', shell=True).rstrip()
            except:
                self._satt_version = '0.0.0'
            os.chdir(old_dir)

        envstore.get_instance().set_sat_version(self._satt_version)
Ejemplo n.º 3
0
def get_instance():
    global control_instance
    if control_instance is None:
        from satt.common import envstore
        ctrl = envstore.get_instance().get_variable('sat_control_bus')
        if ctrl == '':
            print "\nNo control bus selected"
            print "Please run 'satt config'"
            sys.exit(-1)
        else:
            if ctrl == "SSH":
                from satt.common.control import SshControl
                control_instance = SshControl(DEBUG)
            elif ctrl == "SHELL":
                from satt.common.control import ShellControl
                control_instance = ShellControl(DEBUG)
            elif ctrl == "ADB":
                from satt.common.control import AdbControl
                control_instance = AdbControl(DEBUG)
            else:
                print "ERROR: Unsupported control bus type (" + ctrl + ")"
                sys.exit(-1)
    return control_instance
Ejemplo n.º 4
0
 def pti_available(self):
     from satt.common import envstore
     s = envstore.get_instance()
     return os.path.exists(
         os.path.join(s.get_sat_home(), "satt", "trace", "t32"))
Ejemplo n.º 5
0
    def generate_model(self, debug, debug_level):
        # Make collection
        import multiprocessing
        max_procs = multiprocessing.cpu_count()
        command = ''
        collection_file = os.path.join(self._os._trace_path,
                                       self._os._trace_path + '.collection')

        # commands for rtit/ipt
        collection_make_version = ''
        collection_model_version = ''
        sat_collection_cbr_version = ''
        sat_collection_stats_version = ''
        sat_collection_tasks_version = ''
        if self._args.rtit:
            collection_make_version = 'sat-rtit-collection-make'
            collection_model_version = 'sat-rtit-collection-model'
            sat_collection_cbr_version = 'sat-rtit-collection-cbr'
            sat_collection_stats_version = 'sat-rtit-collection-stats'
            sat_collection_tasks_version = 'sat-rtit-collection-tasks'
        else:
            collection_make_version = 'sat-ipt-collection-make'
            collection_model_version = 'sat-ipt-model'
            sat_collection_cbr_version = 'sat-ipt-collection-cbr'
            sat_collection_stats_version = 'sat-ipt-collection-stats'
            sat_collection_tasks_version = 'sat-ipt-collection-tasks'

        print 'MAKING COLLECTION ' + collection_file

        command = (os.path.join(self._post_process_bin_path,
                                collection_make_version) + ' -s ' +
                   os.path.join(self._os._trace_path, 'sideband.bin'))
        cpu_files = glob.glob(os.path.join(self._os._trace_path, 'cpu*.bin'))
        cpu_files.sort()
        for i in cpu_files:
            command += ' -r ' + i
        command += ' | grep -v "^#" > ' + collection_file
        #print "COMMAND=" + command

        # Execute: MAKE COLLECTION

        ret = subprocess.call(command, shell=True)

        # Building execution model
        print 'BUILDING EXECUTION MODEL ON COLLECTION ' + collection_file

        python_path = 'python'

        if self._satt_venv_bin:
            python_path = os.path.join(self._satt_venv_bin, python_path)

        path_helper = (
            python_path + " " + os.path.join(self._sat_home, 'satt', 'process',
                                             'binary_server.py') + " '%s' " +
            "-p " + os.path.join(self._post_process_bin_path, 'sat-path-map') +
            " " + "-k " + os.path.join(self._os._trace_path, 'binaries',
                                       'kernel', 'vmlinux') + " " + "-m " +
            os.path.join(self._os._trace_path, 'binaries', 'kernel',
                         'modules') + " ")

        path_helper += "-d " + self._os.get_debug_paths() + " "

        # Host tracing, local host files can be used for processing
        if envstore.get_instance().get_variable('sat_control_bus') == 'SHELL':
            path_helper += "--host_tracing "

        path_helper += (
            os.path.join(self._os._trace_path, 'binaries', 'symbols') + " " +
            os.path.join(self._os._trace_path, 'binaries') + " " +
            os.path.join(self._os._trace_path, 'binaries', 'sat-path-cache'))

        command = (
            os.path.join(self._post_process_bin_path,
                         collection_model_version) + ' -C ' + collection_file +
            ' -m ' + os.path.join(self._os._trace_path, 'binaries', 'kernel',
                                  'System.map') + ' -f "' + path_helper + '"'
            ' -F ' +
            os.path.join(self._os._trace_path, 'binaries', 'sat-path-cache') +
            ' -P ' + str(max_procs) + ' -o ' + os.path.join(
                self._os._trace_path, self._os._trace_path + '-%u.model') +
            ' -w ' + os.path.join(self._os._trace_path,
                                  self._os._trace_path + '-%u.lwm') + ' -n ' +
            os.path.join(self._os._trace_path,
                         self._os._trace_path + '.satsym') + ' -e ' +
            os.path.join(self._os._trace_path,
                         self._os._trace_path + '.satmod') + ' -h ' +
            os.path.join(self._os._trace_path,
                         self._os._trace_path + '.satmodh'))
        if debug:
            command += ' -d'
            command += ' -D' * debug_level

        # Execute: BUILD MODELS
        ret = subprocess.call(command, shell=True)

        print "INTERMEDIATE PROCESSING",
        print "AND SHRINKING MODEL" if not debug else ''

        tid_files = glob.glob(
            os.path.join(self._os._trace_path,
                         self._os._trace_path + '-*.model'))
        tid_files.sort()
        for i, t in enumerate(tid_files):
            tid_files[i] = os.path.splitext(os.path.basename(t))[0]
        tid_string = '\n'.join(tid_files)
        command = (
            'echo "' + tid_string + '" | xargs -n 1 --max-procs=' +
            str(max_procs) + ' -I PER_TID bash -c ' + '"' +
            os.path.join(self._post_process_bin_path, 'sat-intermediate'))
        if debug:
            command += ' -d '
        command += (' -w ' +
                    os.path.join(self._os._trace_path, 'PER_TID.lwm') +
                    ' -o ' +
                    os.path.join(self._os._trace_path, 'PER_TID.sat') + ' ' +
                    os.path.join(self._os._trace_path, 'PER_TID.model') + ';')
        if not debug:
            command += (' rm ' +
                        os.path.join(self._os._trace_path, 'PER_TID.model') +
                        ' ' +
                        os.path.join(self._os._trace_path, 'PER_TID.lwm') +
                        ';')
            command += (' ' + os.path.join(self._post_process_bin_path,
                                           'sat-shrink-output') + ' ' +
                        os.path.join(self._os._trace_path, 'PER_TID.sat'))
        command += (
            '" | ' + os.path.join(self._post_process_bin_path, 'sat-post') +
            ' -o ' +
            os.path.join(self._os._trace_path, self._os._trace_path + '.log'))

        # Execute: INTERMEDIATE
        subprocess.call(command, shell=True)

        if not debug:
            print "MERGING MODEL"
            command = (os.path.join(self._post_process_bin_path, 'sat-merge') +
                       ' ' + os.path.join(self._os._trace_path,
                                          self._os._trace_path + '-*.sat') +
                       ' > ' + os.path.join(self._os._trace_path,
                                            self._os._trace_path + '.sat0'))
            subprocess.call(command, shell=True)

            # Generate satcbr
            command = (os.path.join(self._post_process_bin_path,
                                    sat_collection_cbr_version) + ' ' +
                       collection_file + ' | grep -v "^#" > ' +
                       os.path.join(self._os._trace_path,
                                    self._os._trace_path + '.satcbr'))
            subprocess.call(command, shell=True)

            # Generate satstats
            command = (os.path.join(self._post_process_bin_path,
                                    sat_collection_stats_version) + ' ' +
                       collection_file + ' | grep -v "^#" > ' +
                       os.path.join(self._os._trace_path,
                                    self._os._trace_path + '.satstats'))
            subprocess.call(command, shell=True)

            # Generate satp
            command = (os.path.join(self._post_process_bin_path,
                                    sat_collection_tasks_version) + ' ' +
                       collection_file + ' | grep -v "^#" > ' +
                       os.path.join(self._os._trace_path,
                                    self._os._trace_path + '.satp'))
            subprocess.call(command, shell=True)

            print "REMOVING PER-PROCESS MODELS"
            sat_files = glob.glob(
                os.path.join(self._os._trace_path,
                             self._os._trace_path + '-*.sat'))
            for f in sat_files:
                os.remove(f)
Ejemplo n.º 6
0
 def initialize(self):
     envstore.get_instance().load()
     self.check_version()
Ejemplo n.º 7
0
 def __init__(self, sat_path, sat_venv_bin):
     self._sat_path = sat_path
     self._sat_venv_bin = sat_venv_bin
     envstore.get_instance().set_sat_home(sat_path)
     envstore.get_instance().set_sat_venv_bin(sat_venv_bin)