def junit(toolName, file):

    junit_xml = junit_xml_output.JunitXml(toolName,
                                          test_cases,
                                          total_tests=None,
                                          total_failures=None)
    with open(file, 'w') as file:
        print "Writing Junit test files"
        file.write(junit_xml.dump())
Example #2
0
                           stderr=subprocess.PIPE,
                           env=test_env)
    stdout, stderr = get_subprocess_output(val)
    f = open('output/' + arg, 'w')
    f.write(stdout)
    f.close()
    if val.returncode != 0:
        test_cases.append(
            junit_xml_output.TestCase(arg, '(crash)\n ' + stderr, "failure"))
        print('CRASH ' + arg + '  -- LD_LIBRARY_PATH=.:../ ./' + arg + '-ldso')
    else:
        cmd = ['diff', '-q', 'output/' + arg, 'output/' + arg + '.ref']
        val = subprocess.Popen(cmd,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
        stdout, stderr = get_subprocess_output(val)
        if val.returncode != 0:
            test_cases.append(junit_xml_output.TestCase(
                arg, stderr, "failure"))
            print('FAIL ' + arg + '  -- LD_LIBRARY_PATH=.:../ ./' + arg +
                  '-ldso')
        else:
            test_cases.append(junit_xml_output.TestCase(
                arg, stdout, "success"))
            print('PASS ' + arg)

junit_xml = junit_xml_output.JunitXml("elf-loader-tests", test_cases)
f = open('elf-loader-tests.xml', 'w')
f.write(junit_xml.dump())
f.close()
Example #3
0
import junit_xml_output
import sys

counter=0
fname=sys.argv[1] # filename to grep
err=sys.argv[2]   # error message to grep for
test_cases = []


f = open(fname, "r")
for x in f:
  if (x.find(err) != -1):
    test_cases.append(junit_xml_output.TestCase("line: " + str(counter) , x, "failure"))
  #print(x)
  counter += 1
f.close()

junit_xml = junit_xml_output.JunitXml(fname, test_cases)
print (junit_xml.dump())
Example #4
0
import junit_xml_output
test_cases = []
test_cases.append(junit_xml_output.TestCase("first", "eg_contents", "failure"))
junit_xml = junit_xml_output.JunitXml("example_usage", test_cases)
print(junit_xml.dump())

#
# # code snippet for the usage
# """ a short example of how to use this module """
# test_cases = []
# for i in range(0, 5):
#     type_c = ""
#     if i % 2 == 0:
#         type_c = "failure"
#     test_cases.append(TestCase(i, str(i) + "contents", type_c) )
#
# junit_xml = JunitXml("demo test example", test_cases)
Example #5
0
                        type=lambda p: Path(p).absolute(),
                        default=Path(__file__).absolute().parent / "target",
                        help="Path to the target directory")
    parser.add_argument("--file_pattern",
                        type=str,
                        default="*.xml",
                        help="file pattern")
    p = parser.parse_args()
    return p


if __name__ == "__main__":
    params = getPathArg()
    for entry in params.target_dir.glob(params.file_pattern):
        test_cases = []
        fileName = entry.name
        with entry.open() as f:
            for line in f:
                header = ""
                try:
                    regResult = re.search("(\([A-Z]+[0-9]+\))", line)
                    header = regResult.group(1)
                except:
                    header = line
                test_cases.append(
                    junit_xml_output.TestCase(header, line, "failure"))
        junit_xml = junit_xml_output.JunitXml(fileName, test_cases)  # suite
        output = params.target_dir / fileName
        with open(str(output) + ".xml", "w") as f:
            f.write(junit_xml.dump())