Skip to content

Commit

Permalink
[ESD-2043] Merge master (#88)
Browse files Browse the repository at this point in the history
* SV4-144 update googleflags (#83)

* scripts: Fix flakes

`sys` was unused.
Also tabs were used in memcheck_xml2junit_converter.py

* memcheck_xml2junit_converter.py: Remove redundancy

SonarCloud complains about the repeated string.

Co-authored-by: Rodrigo Reichert <[email protected]>
Co-authored-by: John Vandenberg <[email protected]>
  • Loading branch information
3 people authored Jun 29, 2021
1 parent 9da11ab commit 4a938a6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions FindGFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include("GenericFindDependency")
option(GFLAGS_STRIP_INTERNAL_FLAG_HELP "Hide help from GFLAGS modules" true)
GenericFindDependency(
TARGET gflags
SOURCE_DIR "googleflags"
Expand Down
18 changes: 11 additions & 7 deletions scripts/memcheck_xml2junit_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@
# * -o, --output_directory: Defines the output folder where the converted JUnit
# xml files are collected.
# * -s, --skip_tests: Error elements in a Valgrind Memcheck xml file are
# replaced by a skipped message type in the converted
# replaced by a skipped message type in the converted
# JUnit xml file.
#
import argparse
import os
import xml.etree.ElementTree as ET
import sys, os, argparse

def get_testcase_preamble(name, close=False):
return ' <testcase classname="valgrind-memcheck" name="{}"{}>\n'.format(str(name), "/" if close else "")


parser = argparse.ArgumentParser(description='Convert Valgrind Memcheck xml into JUnit xml format.')
optional = parser._action_groups.pop()
Expand Down Expand Up @@ -78,7 +83,7 @@
out.write('<?xml version="1.0" encoding="UTF-8"?>\n')
if len(errors) == 0:
out.write('<testsuite name="valgrind" tests="1" '+test_type+''+plural+'="'+str(len(errors))+'">\n')
out.write(' <testcase classname="valgrind-memcheck" name="'+str(filename)+'"/>\n')
out.write(get_testcase_preamble(filename, close=True))
else:
out.write('<testsuite name="valgrind" tests="'+str(len(errors))+'" '+test_type+''+plural+'="'+str(len(errors))+'">\n')
errorcount=0
Expand All @@ -100,9 +105,9 @@
break

if fi != None and li != None:
out.write(' <testcase classname="valgrind-memcheck" name="'+str(filename)+' '+str(errorcount)+' ('+kind.text+', '+fi.text+':'+li.text+')">\n')
out.write(get_testcase_preamble("{} {} ({}, {}:{})".format(str(filename), errorcount, kind.text, fi.text, li.text)))
else:
out.write(' <testcase classname="valgrind-memcheck" name="'+str(filename)+' '+str(errorcount)+' ('+kind.text+')">\n')
out.write(get_testcase_preamble("{} {} ({})".format(str(filename), errorcount, kind.text)))
out.write(' <'+test_type+' type="'+kind.text+'">\n')
out.write(' '+what.text+'\n\n')

Expand All @@ -111,7 +116,7 @@
fn = frame.find('fn')
fi = frame.find('file')
li = frame.find('line')
if fn != None:
if fn != None:
bodytext = fn.text
else:
bodytext = "unknown function name"
Expand All @@ -126,4 +131,3 @@
out.write(' </testcase>\n')
out.write('</testsuite>\n')
out.close()

6 changes: 3 additions & 3 deletions scripts/parse_bloaty.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# * -o, --output_file: Sets the output file path.
# * -m, --message: Adds a message to the reported memory usage.
#
import sys, argparse
import argparse
import sys

parser = argparse.ArgumentParser(description='Log total static memory size reported by Bloaty.')
optional = parser._action_groups.pop()
Expand All @@ -37,7 +38,7 @@
finput = open(args.input_file)
foutput = open(args.output_file,"a")
except IOError:
exit()
sys.exit()

with finput:
lines = finput.readlines()
Expand All @@ -51,4 +52,3 @@
foutput.write(message)
finput.close()
foutput.close()

8 changes: 5 additions & 3 deletions scripts/parse_heaptrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
# * -o, --output_file: Sets the output file path.
# * -m, --message: Adds a message to the reported memory usage.
#
import sys, subprocess, re, argparse
import argparse
import re
import subprocess
import sys

parser = argparse.ArgumentParser(description='Log peak heap memory consumption reported by Heaptrack.')
optional = parser._action_groups.pop()
Expand All @@ -38,7 +41,7 @@
try:
foutput = open(args.output_file,"a")
except IOError:
exit()
sys.exit()

p_heaptrack_print = subprocess.Popen(['which', 'heaptrack_print'], stdout=subprocess.PIPE)
program_path = p_heaptrack_print.stdout.read().rstrip()
Expand All @@ -57,4 +60,3 @@
break
foutput.close()
p.terminate()

6 changes: 3 additions & 3 deletions scripts/parse_stackusage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# * -o, --output_file: Sets the output file path.
# * -m, --message: Adds a message to the reported memory usage.
#
import sys, argparse
import argparse
import sys

parser = argparse.ArgumentParser(description='Log sum of the maximal used stack for all active threads reported by Stackusage.')
optional = parser._action_groups.pop()
Expand All @@ -37,7 +38,7 @@
finput = open(args.input_file)
foutput = open(args.output_file,"a")
except IOError:
exit()
sys.exit()

with finput:
lines = finput.readlines()
Expand All @@ -52,4 +53,3 @@
foutput.write(message)
finput.close()
foutput.close()

0 comments on commit 4a938a6

Please sign in to comment.