Esempio n. 1
0
    def test_that_manifest_dependencies_are_included(self):
        package_name = 'my_package'

        # Make a CMakeLists.txt file.
        cmakelists_path = create_temp_file(contents='')

        # Make a manifest.xml file.
        manifest_path = create_temp_file(contents='''
<package>
  <depend package="pkg_a"/>
  <depend package="pkg_b"/>
  <rosdep name="pkg_c" />
  <rosdep name="pkg_d" />
</package>
''')
        output = StringIO.StringIO()

        # Run the catkinize script.
        main([package_name, cmakelists_path, manifest_path], output)

        # Check that dependencies are listed.
        out_lines = output.getvalue().splitlines()
        cpkg_lines = [l for l in out_lines if 'catkin_package' in l]
        self.assertEqual(1, len(cpkg_lines), str(cpkg_lines))
        cpkg_line = cpkg_lines[0]
        pattern = 'DEPENDS pkg_a pkg_b pkg_c pkg_d'
        msg = '''
    Failed to find package dependencies in the catkin_package() call:
    Expected to find a line containing
    %s
    but got
    %s
''' % (pattern, cpkg_line)
        self.assertTrue(pattern in cpkg_line, msg)
Esempio n. 2
0
    def setUp(self):
        # Create the Songs, Groups, and Tracks that match expected_zip_structure
        song1 = self.project.songs.create(title="Song 1")
        group1 = song1.groups.create(title="Group 1")
        group1.tracks.create(
            file=create_temp_file("track1.wav", "audio/x-wav"))
        group1.tracks.create(
            file=create_temp_file("track2.wav", "audio/x-wav"))
        group2 = song1.groups.create(title="Group 2")
        group2.tracks.create(
            file=create_temp_file("track3.wav", "audio/x-wav"))
        group2.tracks.create(
            file=create_temp_file("track4.wav", "audio/x-wav"))

        song2 = self.project.songs.create(title="Song 2")
        group3 = song2.groups.create(title="Group 3")
        group3.tracks.create(
            file=create_temp_file("track5.aif", "audio/x-aiff"))
        group3.tracks.create(
            file=create_temp_file("track6.aif", "audio/x-aiff"))
        group4 = song2.groups.create(title="Group 4")
        group4.tracks.create(
            file=create_temp_file("track7.aif", "audio/x-aiff"))
        group4.tracks.create(
            file=create_temp_file("track8.aif", "audio/x-aiff"))
Esempio n. 3
0
  def create_mutated_ipcdump_testcase(self):
    ipcdumps = ','.join(random.sample(self.corpus, IPCDUMP_MERGE_LIMIT))
    tmp_ipcdump_testcase = utils.create_temp_file()
    mutated_ipcdump_testcase = (
        utils.random_ipcdump_testcase_path(self.args.output_dir))

    # Concatenate ipcdumps -> tmp_ipcdump.
    cmd = [
      self.ipc_message_util_binary_path,
      ipcdumps,
      tmp_ipcdump_testcase,
    ]
    if subprocess.call(cmd):
      sys.exit('%s failed.' % self.ipc_message_util_binary)

    # Mutate tmp_ipcdump -> mutated_ipcdump.
    cmd = [
      self.ipc_fuzzer_binary_path,
      FUZZER_NAME_OPTION,
      tmp_ipcdump_testcase,
      mutated_ipcdump_testcase,
    ]
    if subprocess.call(cmd):
      sys.exit('%s failed.' % self.ipc_fuzzer_binary)

    utils.create_flags_file(
        mutated_ipcdump_testcase, self.ipc_replay_binary_path)
    os.remove(tmp_ipcdump_testcase)
Esempio n. 4
0
    def create_mutated_ipcdump_testcase(self):
        ipcdumps = ','.join(random.sample(self.corpus, IPCDUMP_MERGE_LIMIT))
        tmp_ipcdump_testcase = utils.create_temp_file()
        mutated_ipcdump_testcase = (utils.random_ipcdump_testcase_path(
            self.args.output_dir))

        # Concatenate ipcdumps -> tmp_ipcdump.
        cmd = [
            self.ipc_message_util_binary_path,
            ipcdumps,
            tmp_ipcdump_testcase,
        ]
        if subprocess.call(cmd):
            sys.exit('%s failed.' % self.ipc_message_util_binary)

        # Mutate tmp_ipcdump -> mutated_ipcdump.
        cmd = [
            self.ipc_fuzzer_binary_path,
            FUZZER_NAME_OPTION,
            tmp_ipcdump_testcase,
            mutated_ipcdump_testcase,
        ]
        if subprocess.call(cmd):
            sys.exit('%s failed.' % self.ipc_fuzzer_binary)

        utils.create_flags_file(mutated_ipcdump_testcase)
        os.remove(tmp_ipcdump_testcase)
Esempio n. 5
0
    def test_create_comment_on_active_project(self):
        url = reverse("comment-list")
        data = {
            "content": "Test Comment",
            "attachment": create_temp_file("test.txt", "text/plain"),
            "project": self.active_project.pk,
        }

        # User is anon
        response = self.client.post(url, data)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

        # User is not owner
        data["attachment"].seek(0)
        self.client.force_authenticate(user=self.non_owner)
        response = self.client.post(url, data)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

        # User is owner
        data["attachment"].seek(0)
        self.client.force_authenticate(user=self.owner)
        response = self.client.post(url, data)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(Comment.objects.count(), 1)
        self.assertEqual(Comment.objects.get().content, "Test Comment")
        self.assertTrue(
            Comment.objects.get().attachment.name.endswith("test.txt"))
def create_private_files(owner):
    project = Project.objects.create(title="Project", owner=owner)
    song = Song.objects.create(project=project, title="Song")
    group = Group.objects.create(song=song, title="Group")

    f = create_temp_file("temp-track.wav", "audio/x-wav")
    track = Track.objects.create(group=group, file=f)

    f = create_temp_file("attachment.txt", "text/plain")
    comment = Comment.objects.create(project=project,
                                     attachment=f,
                                     author=owner,
                                     content="Comment")

    f = create_temp_file("final.wav", "audio/x-wav")
    final = FinalFile.objects.create(project=project, attachment=f)

    return track, comment, final
Esempio n. 7
0
 def test_main(self):
     for case in ['rpekf', 'stage']:
         infile = os.path.join(os.path.dirname(__file__), 'fixtures', 'CMakeLists.%s.txt.in' % case)
         outfile = os.path.join(os.path.dirname(__file__), 'fixtures', 'CMakeLists.%s.txt.out' % case)
         result_buf = StringIO.StringIO()
         manifest = create_temp_file(contents='<package/>')
         main(['foo', infile, manifest], outstream=result_buf)
         with open(outfile, 'r') as fhand:
             expect = fhand.read()
         self.compare_contents(outfile, expect, result_buf.getvalue())
Esempio n. 8
0
def create_temp_track():
    return create_temp_file("test-song.wav", "audio/wav")