def exemuta_select(self,operators):
		
		"""
		Args:
			operators = It can be a DICTIONARY wich contains the mutation operators for the mutants who want to select and a flot number who indicates the sample rate for that operator
				For instance: {u-SSDL: 1.0, u-VVDL: 0.5}  -> Will select 100 percent of mutants for the SSDL operator and 50 percent of the mutants for VVDL operator.
				Or it can be a LIST wich contains the mutants who wants to select.  
		"""
		
		if not operators:
			statment = 'exemuta -select -all 1.0  ' + self.session 
		else:
			if type(operators) is types.DictType: 
				operators_string = mutant_util.list_string2(sorted([" -%s %s " % (operator,percent) for operator,percent in operators.iteritems()])) #this converts a dict in a list then in a suitable string format to use in Proteum
				statment = 'exemuta -select  %s ' % (operators_string) + self.session 
				#Sample: Dict -> {'-u-SSDL': '1.0', '-u-CCDL': '1.0', '-u-OODL': '1.0'} ; Converted in a list: ['-u-CCDL  1.0 0', '-u-OODL  1.0 0', '-u-SSDL  1.0 0'] -> The number 0 after the Key and Value pf the dict is the sample rate of mutation for each operator
			
			elif type(operators) is types.ListType:
				mutants = mutant_util.list_string(operators)
				#Convert operators in a suitable string to use in Proteum
				statment = 'exemuta -select -x %s ' % (mutants) + self.session 
			else:
				if verbose: print 'The operators source don\'t have a expected value. Operators: %s \n' % (operators)
				raise ValueError
		
		os.system(statment)
		if verbose: print '\nProteum: ' + statment	
		if verbose: print 'Proteum: The state of the mutants  was modified! Number of active mutants: %d \n' % (len(operators))		
Example #2
0
    def muta_list(self, mutants):

        output = None
        statment = ''

        if not isinstance(mutants, list):
            mutants = []
        else:
            if len(mutants) == 0:
                statment = 'muta -l ' + self.session
            else:
                mutants = mutant_util.list_string(mutants)
                statment = 'muta -l -x %s ' % (mutants) + self.session

        output = str(subprocess.check_output(statment, shell=True))
        return output
	def muta_list(self,mutants):

		output = None
		statment = ''
		
		if not isinstance(mutants,list):
			mutants =[]
		else:
			if len(mutants) == 0:
				statment = 'muta -l ' + self.session
			else:
				mutants  = mutant_util.list_string(mutants)
				statment = 'muta -l -x %s ' % (mutants) + self.session 

		output = str(subprocess.check_output(statment, shell=True))
		return output
	def tcase_remove(self,testcase_list):
		
		"""
		Args:
			testcase_list = a list witch contains the number of the test cases want to remove
				if testcase_list is a empty list, them will apply the effect for all test_cases
		"""

		test_cases = mutant_util.list_string(testcase_list) #Convert testcase_list in a suitable string to use in Proteum

		if not testcase_list:
			statment = 'tcase -d ' + self.session
		else:
			statment = 'tcase -d -x  %s ' % (test_cases) + self.session 

		if verbose: print '\nProteum: ' + statment
		if verbose: print 'Proteum: The set of test case for the program was changed! List of test cases removed: %s \n' % (testcase_list)
		os.system(statment)
	def tcase_show(self, testcase_list):
		
		"""
		Args:
			testcase_list = a list witch contains the number of the test cases want to visualize
				if testcase_list is a empty list, them will apply the effect for all test_cases
		"""

		test_cases = mutant_util.list_string(testcase_list) #Convert testcase_list in a suitable string to use in Proteum

		if not testcase_list:
			statment = 'tcase -l ' + self.session
		else:
			statment = 'tcase -x %s ' % (test_cases) + self.session 

		if verbose: print '\nProteum: ' + statment
		if verbose: print "Proteum: Listing the test case for the program under test.. \n"
		os.system(statment)
	def tcase_add(self, testcase_list):
		
		"""
		Args:
			testcase_list = a list witch contains the inputs of the test cases that want to add
				if testcase_list is a empty list, them will insert a test case with no parameters
		"""

		test_case = mutant_util.list_string(testcase_list) #Convert testcase_list in a suitable string to use in Proteum

		if not testcase_list:
			statment = 'tcase-add -timeout 300 -trace ' + self.session
		else:
			statment = 'tcase-add -timeout 300 -trace -p %s ' % (test_case) + self.session 

		#if verbose: print '\nProteum: ' + statment #Dont need print because Proteum already make a print on stdout when add a new TC
		if verbose: print "Proteum: Adding a new  test case for the program under test! Test Case: %s " % (test_case)
		os.system(statment)
		print '\n' #put a \n because at the end of execution proteum dont skip a line on stdout
Example #7
0
    def tcase_show(self, testcase_list):
        """
		Args:
			testcase_list = a list witch contains the number of the test cases want to visualize
				if testcase_list is a empty list, them will apply the effect for all test_cases
		"""

        test_cases = mutant_util.list_string(
            testcase_list
        )  #Convert testcase_list in a suitable string to use in Proteum

        if not testcase_list:
            statment = 'tcase -l ' + self.session
        else:
            statment = 'tcase -x %s ' % (test_cases) + self.session

        if verbose: print '\nProteum: ' + statment
        if verbose:
            print "Proteum: Listing the test case for the program under test.. \n"
        os.system(statment)
Example #8
0
    def muta_active(self, mutant_list):
        """
			If mutant_list is a empty list, will set all mutants as active
		"""
        statment = ''

        if not isinstance(mutant_list, list):
            mutant_list = []
        else:
            if len(mutant_list) == 0:
                statment = 'muta -active ' + self.session
            else:
                mutant_list = mutant_util.list_string(mutant_list)
                statment = 'muta -active -x %s ' % (mutant_list) + self.session

        statment2 = 'exemuta -exec -v . ' + self.session

        os.system(statment)
        if verbose: print '\nProteum: ' + statment
        if verbose:
            print 'Proteum: --> The mutants inside mutant_list were define as active! \n'
Example #9
0
    def muta_equiv(self, equivalents):
        """
			If equivalents is a empty list, will set all live mutants as equivalents
		"""
        statment = ''

        if not isinstance(equivalents, list):
            equivalents = []
        else:
            if len(equivalents) == 0:
                statment = 'muta -equiv ' + self.session
            else:
                equivalents = mutant_util.list_string(equivalents)
                statment = 'muta -equiv -x %s ' % (equivalents) + self.session

        statment2 = 'exemuta -exec -v . ' + self.session

        os.system(statment)
        if verbose: print '\nProteum: ' + statment
        if verbose:
            print 'Proteum: --> Some mutants were define as equivalents \n'
Example #10
0
    def tcase_remove(self, testcase_list):
        """
		Args:
			testcase_list = a list witch contains the number of the test cases want to remove
				if testcase_list is a empty list, them will apply the effect for all test_cases
		"""

        test_cases = mutant_util.list_string(
            testcase_list
        )  #Convert testcase_list in a suitable string to use in Proteum

        if not testcase_list:
            statment = 'tcase -d ' + self.session
        else:
            statment = 'tcase -d -x  %s ' % (test_cases) + self.session

        if verbose: print '\nProteum: ' + statment
        if verbose:
            print 'Proteum: The set of test case for the program was changed! List of test cases removed: %s \n' % (
                testcase_list)
        os.system(statment)
	def muta_nactive(self,mutant_list):

		"""
			If mutant_list is a empty list, will set all mutants as inactive
		"""
		statment = ''
		
		if not isinstance(mutant_list,list):
			mutant_list =[]
		else:
			if len(mutant_list) == 0:
				statment = 'muta -nactive ' + self.session
			else:
				mutant_list = mutant_util.list_string(mutant_list)
				statment = 'muta -nactive -x %s ' % (mutant_list) + self.session 
		
		statment2 = 'exemuta -exec -v . ' + self.session
		
		os.system(statment)
		if verbose: print '\nProteum: ' + statment
		if verbose: print 'Proteum: The mutants inside mutant_list were define as inactive \n'
	def muta_equiv(self,equivalents):
		
		"""
			If equivalents is a empty list, will set all live mutants as equivalents
		"""
		statment = ''
		
		if not isinstance(equivalents,list):
			equivalents =[]
		else:
			if len(equivalents) == 0:
				statment = 'muta -equiv ' + self.session
			else:
				equivalents = mutant_util.list_string(equivalents)
				statment    = 'muta -equiv -x %s ' % (equivalents) + self.session

		statment2 = 'exemuta -exec -v . ' + self.session 

		os.system(statment)
		if verbose: print '\nProteum: ' + statment 
		if verbose: print 'Proteum: --> Some mutants were define as equivalents \n'
Example #13
0
    def tcase_add(self, testcase_list):
        """
		Args:
			testcase_list = a list witch contains the inputs of the test cases that want to add
				if testcase_list is a empty list, them will insert a test case with no parameters
		"""

        test_case = mutant_util.list_string(
            testcase_list
        )  #Convert testcase_list in a suitable string to use in Proteum

        if not testcase_list:
            statment = 'tcase-add -timeout 300 -trace ' + self.session
        else:
            statment = 'tcase-add -timeout 300 -trace -p %s ' % (
                test_case) + self.session

        #if verbose: print '\nProteum: ' + statment #Dont need print because Proteum already make a print on stdout when add a new TC
        if verbose:
            print "Proteum: Adding a new  test case for the program under test! Test Case: %s " % (
                test_case)
        os.system(statment)
        print '\n'  #put a \n because at the end of execution proteum dont skip a line on stdout
Example #14
0
    def exemuta_select(self, operators):
        """
		Args:
			operators = It can be a DICTIONARY wich contains the mutation operators for the mutants who want to select and a flot number who indicates the sample rate for that operator
				For instance: {u-SSDL: 1.0, u-VVDL: 0.5}  -> Will select 100 percent of mutants for the SSDL operator and 50 percent of the mutants for VVDL operator.
				Or it can be a LIST wich contains the mutants who wants to select.  
		"""

        if not operators:
            statment = 'exemuta -select -all 1.0  ' + self.session
        else:
            if type(operators) is types.DictType:
                operators_string = mutant_util.list_string2(
                    sorted([
                        " -%s %s " % (operator, percent)
                        for operator, percent in operators.iteritems()
                    ])
                )  #this converts a dict in a list then in a suitable string format to use in Proteum
                statment = 'exemuta -select  %s ' % (
                    operators_string) + self.session
                #Sample: Dict -> {'-u-SSDL': '1.0', '-u-CCDL': '1.0', '-u-OODL': '1.0'} ; Converted in a list: ['-u-CCDL  1.0 0', '-u-OODL  1.0 0', '-u-SSDL  1.0 0'] -> The number 0 after the Key and Value pf the dict is the sample rate of mutation for each operator

            elif type(operators) is types.ListType:
                mutants = mutant_util.list_string(operators)
                #Convert operators in a suitable string to use in Proteum
                statment = 'exemuta -select -x %s ' % (mutants) + self.session
            else:
                if verbose:
                    print 'The operators source don\'t have a expected value. Operators: %s \n' % (
                        operators)
                raise ValueError

        os.system(statment)
        if verbose: print '\nProteum: ' + statment
        if verbose:
            print 'Proteum: The state of the mutants  was modified! Number of active mutants: %d \n' % (
                len(operators))