예제 #1
0
 def assertMatches(self, checkerString, c1String):
     checkerString = \
       """
     /// CHECK-START: MyMethod MyPass
   """ + checkerString
     c1String = \
       """
     begin_compilation
       name "MyMethod"
       method "MyMethod"
       date 1234
     end_compilation
     begin_cfg
       name "MyPass"
   """ + c1String + \
       """
     end_cfg
   """
     checkerFile = ParseCheckerStream("<test-file>", "CHECK",
                                      io.StringIO(ToUnicode(checkerString)))
     c1File = ParseC1visualizerStream("<c1-file>",
                                      io.StringIO(ToUnicode(c1String)))
     assert len(checkerFile.testCases) == 1
     assert len(c1File.passes) == 1
     MatchTestCase(checkerFile.testCases[0], c1File.passes[0])
예제 #2
0
파일: test.py 프로젝트: COS-Temp/art
 def parseAssertion(self, string, variant=""):
   checkerText = (u"/// CHECK-START: pass\n" +
                  u"/// CHECK" + ToUnicode(variant) + u": " + ToUnicode(string))
   checkerFile = ParseCheckerStream("<test-file>", "CHECK", io.StringIO(checkerText))
   self.assertEqual(len(checkerFile.testCases), 1)
   testCase = checkerFile.testCases[0]
   self.assertEqual(len(testCase.assertions), 1)
   return testCase.assertions[0]
예제 #3
0
    def assertMatches(self,
                      checkerString,
                      c1String,
                      isa=None,
                      instructionSetFeatures=None):
        checkerString = \
          """
        /// CHECK-START: MyMethod MyPass
      """ + checkerString
        metaData = ""
        if isa:
            metaData += "isa:" + isa

        if instructionSetFeatures:
            if metaData:
                metaData += " "

            joinedFeatures = ",".join(
                map(
                    lambda feature: feature
                    if instructionSetFeatures[feature] else "-" + feature,
                    instructionSetFeatures))
            metaData += "isa_features:" + joinedFeatures

        metaDataString = ""
        if metaData:
            metaDataString = \
              """
          begin_compilation
            name "%s"
            method "%s"
            date 1234
          end_compilation
        """ % (metaData, metaData)
        c1String = metaDataString + \
          """
        begin_compilation
          name "MyMethod"
          method "MyMethod"
          date 1234
        end_compilation
        begin_cfg
          name "MyPass"
      """ + c1String + \
          """
        end_cfg
      """
        checkerFile = ParseCheckerStream("<test-file>", "CHECK",
                                         io.StringIO(ToUnicode(checkerString)))
        c1File = ParseC1visualizerStream("<c1-file>",
                                         io.StringIO(ToUnicode(c1String)))
        assert len(checkerFile.testCases) == 1
        assert len(c1File.passes) == 1
        MatchTestCase(checkerFile.testCases[0], c1File.passes[0],
                      c1File.instructionSetFeatures)
예제 #4
0
파일: test.py 프로젝트: hhhaiai/android_art
 def test_NonArchTests(self):
   for arch in [None] + archs_list:
     checkerFile = ParseCheckerStream("<test-file>",
                                      "CHECK",
                                      io.StringIO(ToUnicode(self.noarch_block)))
     self.assertEqual(len(checkerFile.testCases), 1)
     self.assertEqual(len(checkerFile.testCases[0].assertions), 4)
예제 #5
0
파일: test.py 프로젝트: hhhaiai/android_art
 def test_Arch(self):
   for arch in archs_list:
     checkerText = self.arch_block.format(test_arch = arch)
     checkerFile = ParseCheckerStream("<test-file>",
                                      "CHECK",
                                      io.StringIO(ToUnicode(checkerText)))
     self.assertEqual(len(checkerFile.testCases), 1)
     self.assertEqual(len(checkerFile.testCasesForArch(arch)), 1)
     self.assertEqual(len(checkerFile.testCases[0].assertions), 4)
예제 #6
0
파일: test.py 프로젝트: hhhaiai/android_art
 def test_IgnoreNonTargetArch(self):
   for targetArch in archs_list:
     for testArch in [a for a in archs_list if a != targetArch]:
       checkerText = self.arch_block.format(test_arch = testArch)
       checkerFile = ParseCheckerStream("<test-file>",
                                        "CHECK",
                                        io.StringIO(ToUnicode(checkerText)))
       self.assertEqual(len(checkerFile.testCases), 1)
       self.assertEqual(len(checkerFile.testCasesForArch(testArch)), 1)
       self.assertEqual(len(checkerFile.testCasesForArch(targetArch)), 0)
예제 #7
0
파일: test.py 프로젝트: COS-Temp/art
 def parseTestCase(self, string):
     checkerText = u"/// CHECK-START: pass\n" + ToUnicode(string)
     checkerFile = ParseCheckerStream("<test-file>", "CHECK",
                                      io.StringIO(checkerText))
     self.assertEqual(len(checkerFile.testCases), 1)
     return checkerFile.testCases[0]
예제 #8
0
파일: test.py 프로젝트: COS-Temp/art
 def parse(self, checkerText):
     return ParseCheckerStream("<test_file>", "CHECK",
                               io.StringIO(ToUnicode(checkerText)))
예제 #9
0
파일: test.py 프로젝트: COS-Temp/art
 def tryParse(self, string):
     checkerText = u"/// CHECK-START: pass\n" + ToUnicode(string)
     return ParseCheckerStream("<test-file>", "CHECK",
                               io.StringIO(checkerText))
예제 #10
0
 def assertParsesTo(self, c1Text, expectedData):
     expectedFile = self.createFile(expectedData)
     actualFile = ParseC1visualizerStream("<c1_file>",
                                          io.StringIO(ToUnicode(c1Text)))
     return self.assertEqual(expectedFile, actualFile)
예제 #11
0
 def tryMatch(self, checkerString, c1String, varState={}):
     return MatchLines(self.createTestStatement(checkerString),
                       ToUnicode(c1String), ImmutableDict(varState))