Esempio n. 1
0
    def markExecuted(self,transition_object):
        locked=0 # keeps if this function has acquired search_front_lock

        # Update advances to the 'official' coverage object
        GuidanceBase.markExecuted(self,transition_object)
        
        # Then cleanup search front: remove every entry from the
        # search front if it starts with some other than the executed
        # transition_object, and shorten entries starting with the
        # transition.

        # Shortening cannot be done if paths are too short, therefore,
        # if the thread is running, let it do its job 
        while 1:
            self.search_front_lock.acquire()
            locked=1
            if len(self.search_front[0][1])<2:
                # There is just one action in the search front, it can
                # be safely removed only if the thread is no more
                # running, that is, time_to_quit signal has been
                # given.
                if self.time_to_quit: break
                else:
                    self.search_front_lock.release()
                    locked=0
                    time.sleep(1) # give some time to the thread
                    continue
                    
                # NOTE: This may cause a livelock if there are
                # deadlocks in the model: search front is not getting
                # any deeper. There should not be deadlocks!
            else:
                break
            
        # If the thread is quitting, there is no reason to
        # cleanup the search front
        #if self.time_to_quit:
        #    if locked: self.search_front_lock.release()
        #    return

        # This function must own the lock now, search_front can be
        # edited.
        new_search_front=[]
        for points,path,reqs in self.search_front:
            if path[0]==transition_object:
                self._front_shortened=1 # message to the thread
                new_search_front.append([points,path[1:],reqs])
        self.search_front=new_search_front
        self.log("Search front reduced to length %s and depth %s" %
                 (len(self.search_front),len(self.search_front[0][1])))
        self.search_front_lock.release()
Esempio n. 2
0
    def markExecuted(self, transition_object):
        locked = 0  # keeps if this function has acquired search_front_lock

        # Update advances to the 'official' coverage object
        GuidanceBase.markExecuted(self, transition_object)

        # Then cleanup search front: remove every entry from the
        # search front if it starts with some other than the executed
        # transition_object, and shorten entries starting with the
        # transition.

        # Shortening cannot be done if paths are too short, therefore,
        # if the thread is running, let it do its job
        while 1:
            self.search_front_lock.acquire()
            locked = 1
            if len(self.search_front[0][1]) < 2:
                # There is just one action in the search front, it can
                # be safely removed only if the thread is no more
                # running, that is, time_to_quit signal has been
                # given.
                if self.time_to_quit: break
                else:
                    self.search_front_lock.release()
                    locked = 0
                    time.sleep(1)  # give some time to the thread
                    continue

                # NOTE: This may cause a livelock if there are
                # deadlocks in the model: search front is not getting
                # any deeper. There should not be deadlocks!
            else:
                break

        # If the thread is quitting, there is no reason to
        # cleanup the search front
        #if self.time_to_quit:
        #    if locked: self.search_front_lock.release()
        #    return

        # This function must own the lock now, search_front can be
        # edited.
        new_search_front = []
        for points, path, reqs in self.search_front:
            if path[0] == transition_object:
                self._front_shortened = 1  # message to the thread
                new_search_front.append([points, path[1:], reqs])
        self.search_front = new_search_front
        self.log("Search front reduced to length %s and depth %s" %
                 (len(self.search_front), len(self.search_front[0][1])))
        self.search_front_lock.release()
Esempio n. 3
0
    def markExecuted(self, transition):

        # special case: add the very first (source) state to the tabu-list
        statelist = self._tabulist_state
        if statelist and len(statelist) == 0:
            statelist.add(transition.getSourceState())

        # add actions/states/transitions to tabulists if given tabulist exists
        if self._tabulist_action is not None:
            self._tabulist_action.add(str(transition.getAction()))
        if self._tabulist_state is not None:
            self._tabulist_state.add(str(transition.getDestState()))
        if self._tabulist_transition is not None:
            self._tabulist_transition.add(str(transition))

        GuidanceBase.markExecuted(self, transition)
Esempio n. 4
0
    def markExecuted(self, transition):

        # special case: add the very first (source) state to the tabu-list
        statelist = self._tabulist_state
        if statelist and len(statelist) == 0:
            statelist.add(transition.getSourceState())

        # add actions/states/transitions to tabulists if given tabulist exists
        if self._tabulist_action is not None:
            self._tabulist_action.add(str(transition.getAction()))
        if self._tabulist_state is not None:
            self._tabulist_state.add(str(transition.getDestState()))
        if self._tabulist_transition is not None:
            self._tabulist_transition.add(str(transition))

        GuidanceBase.markExecuted(self, transition)
Esempio n. 5
0
 def markExecuted(self, transition):
     self._path = self._path[1:]
     GuidanceBase.markExecuted(self, transition)
Esempio n. 6
0
 def markExecuted(self, transition):
     self._path = self._path[1:]
     GuidanceBase.markExecuted(self,transition)