Exemplo n.º 1
0
def _handle_empty_project(proj_class, *args, **options):
    if not options['no_target']:
        raise CommandError('No target binary specified. Use the -m option to '
                           'create an empty project')

    if not options['image']:
        raise CommandError('An empty project requires a VM image. Use the -i '
                           'option to specify the image')

    if not options['name']:
        raise CommandError('An empty project requires a name. Use the -n '
                           'option to specify one')

    # If the project class wasn't explicitly overridden programmatically, get
    # one of the default project classes from the command line
    if not proj_class:
        project_types = PROJECT_TYPES.keys()
        if options['type'] not in project_types:
            raise CommandError('An empty project requires a type. Use the -t '
                               'option and specify one from %s' %
                               project_types)
        proj_class = PROJECT_TYPES[options['type']]

    target = Target.empty(proj_class)
    options['target'] = target

    return call_command(target.initialize_project(), *args, **options)
Exemplo n.º 2
0
    def test_empty_xpsp3pro_project_config(self):
        """Test empty Windows XP SP3 project creation."""
        target = Target.empty(WindowsProject)
        project = monkey_patch_project(target.initialize_project(),
                                       WINDOWS_XPSP3_X86_IMAGE_DESC)
        options = {
            'image': 'windows-xpsp3pro-i386',
            'name': 'test',
        }

        config = project._configure(target, **options)

        # Assert that we have actually created a Windows project
        self.assertEqual(config['project_type'], 'windows')

        # Assert that the project has no target
        self.assertIsNone(config['target_path'])
        self.assertIsNone(config['target_arch'])
        self.assertFalse(config['target_files'])

        # Should be empty when no target is specified
        self.assertFalse(config['processes'])
        self.assertFalse(config['modules'])

        # An empty project with no target will have no arguments
        self.assertFalse(config['target_args'])
        self.assertFalse(config['sym_args'])
        self.assertFalse(config['use_symb_input_file'])

        # Disabled by default
        self.assertFalse(config['enable_pov_generation'])
        self.assertFalse(config['use_seeds'])
        self.assertFalse(config['use_recipes'])
        self.assertFalse(config['use_fault_injection'])
Exemplo n.º 3
0
    def test_empty_x86_project_config(self):
        """Test empty Linux x86 project creation."""
        target = Target.empty()
        project = monkey_patch_project(LinuxProject(), LINUX_IMAGE_DESC)

        options = {
            'image': 'debian-9.2.1-i386',
            'name': 'test',
        }

        config = project._configure(target, **options)

        # Assert that we have actually created a Linux project
        self.assertEqual(config['project_type'], 'linux')

        # Assert that the project has no target
        self.assertIsNone(config['target'].path)
        self.assertIsNone(config['target'].arch)
        self.assertFalse(config['target'].files)

        # Should be empty when no target is specified
        self.assertFalse(config['processes'])
        self.assertFalse(config['modules'])

        # An empty project with no target will have no arguments
        self.assertFalse(config['target'].args.get_resolved_args(''))
        self.assertFalse(config['target'].args.symbolic_files)
        self.assertFalse(config['sym_args'])

        # Disabled by default
        self.assertFalse(config['enable_pov_generation'])
        self.assertFalse(config['use_seeds'])
        self.assertFalse(config['use_recipes'])
        self.assertFalse(config['use_fault_injection'])
Exemplo n.º 4
0
    def test_empty_cgc_target(self):
        """Test empty CGC target."""
        target = Target.empty()

        self.assertFalse(target.path)
        self.assertFalse(target.arch)
        self.assertFalse(target.operating_system)
        self.assertFalse(target.aux_files)
        self.assertTrue(target.is_empty())
Exemplo n.º 5
0
    def test_empty_cgc_target(self):
        """Test empty CGC target."""
        target = Target.empty(CGCProject)

        self.assertFalse(target.path)
        self.assertFalse(target.arch)
        self.assertFalse(target.operating_system)
        self.assertFalse(target.aux_files)
        self.assertIsInstance(target.initialize_project(), CGCProject)
        self.assertTrue(target.is_empty())
Exemplo n.º 6
0
    def test_empty_project_config(self):
        """Test empty CGC project creation."""
        target = Target.empty(CGCProject)
        project = monkey_patch_project(target.initialize_project(),
                                       CGC_IMAGE_DESC)
        options = {
            'image': 'cgc_debian-9.2.1-i386',
            'name': 'test',
        }

        config = project._configure(target, **options)

        # Assert that we have actually created a CGC project
        self.assertEqual(config['project_type'], 'cgc')

        # Assert that the projet has no target
        self.assertIsNone(config['target_path'])
        self.assertIsNone(config['target_arch'])
        self.assertFalse(config['target_files'])

        # Should be empty when no target is specified
        self.assertFalse(config['processes'])
        self.assertFalse(config['modules'])

        # CGC binaries have no input files
        self.assertFalse(config['target_args'])
        self.assertFalse(config['sym_args'])
        self.assertFalse(config['use_symb_input_file'])
        self.assertFalse(config['warn_input_file'])
        self.assertFalse(config['warn_seeds'])

        # CGC projects should always have POV generation, seeds and recipes
        # enabled
        self.assertTrue(config['enable_pov_generation'])
        self.assertTrue(config['use_seeds'])
        self.assertTrue(config['use_recipes'])

        # CGC has its own test case generation system
        self.assertFalse(config['use_test_case_generator'])