Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore fix #26

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
.settings/
Debug/
.pydevproject
venv/
setenv.sh
fir.xml
6 changes: 5 additions & 1 deletion examples/fir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ main: $(OBJFILES)
obj/%.o: %.cpp
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) $^ -o $@

run:
run: main
$(LDPATH) && ./$(EXEC)

test: run
$(MAKE) -C ../../test/pyucis-fir/ validate_fir

clean:
rm -rf obj $(EXEC)
rm coverage_results.xml
15 changes: 15 additions & 0 deletions examples/fir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build Instructions

These are the build instructions for using the example

```
# export SYSTEMC_HOME="path to systemC release dir"
$ make clean
$ make
$ make run
```

# Test Instructions *(optional)*
Optionally test the output using the following instructions


2 changes: 1 addition & 1 deletion examples/fir/src/stimulus.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ SC_MODULE(stimulus) {
bin<int>("invalid", 0)
};

cross<int, int, int> reset_valid_cross = cross<int, int, int> (this, "reset valid",
cross<int, int, int> reset_valid_cross = cross<int, int, int> (this, "reset_valid",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason why name was changed? Space character in name is not allowed under UCIS standard?

&reset_cvp,
&input_valid_cvp,
&values_cvp
Expand Down
3 changes: 2 additions & 1 deletion includes/fc4sc_bin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ class bin : public bin_base
stream << "type=\""
<< this->ucis_bin_type
<< "\" "
<< "alias=\"" << this->get_hitcount() << "\""
<< "alias=\"" << this->get_hitcount() << "\" "
<< "key=\"KEY\""
<< ">\n";

// Print each range. Coverpoint writes the header (name etc.)
Expand Down
2 changes: 1 addition & 1 deletion includes/fc4sc_covergroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class covergroup : public cvg_base
<< "\" line=\""
<< "1"
<< "\" inlineCount=\"1\"/>\n";
stream << "<ucis:cgSourceId file=\"" << file_name << "\" "
stream << "<ucis:cgSourceId file=\"1\" "
<< "line=\"" << line << "\""
<< " inlineCount=\"1\"/>\n";
stream << "</ucis:cgId>\n";
Expand Down
2 changes: 1 addition & 1 deletion includes/fc4sc_cross.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class cross : public cvp_base
<< "\" ";
stream << ">\n";

stream << option << "\n";
stream << "<ucis:options />\n";

for (auto &cvp : cvps_vec)
{
Expand Down
2 changes: 1 addition & 1 deletion includes/fc4sc_master.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class global
stream << ">\n";

stream << "<ucis:id ";
stream << "file=\"" << type_it.second.file_name << "\" ";
stream << "file=\"" << 1 << "\" ";
stream << "line=\"" << type_it.second.line << "\" ";
stream << "inlineCount=\""
<< "1"
Expand Down
1 change: 1 addition & 0 deletions test/pyucis-fir/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
5 changes: 5 additions & 0 deletions test/pyucis-fir/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DEFAULT_GOAL := validate_fir


validate_fir:
python3 validate_ucis_xml.py
7 changes: 7 additions & 0 deletions test/pyucis-fir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# test of xml output with pyucis

This directory contains test code to validate the coverage_report.xml
output for the fir example. It requires python3 and the [VENV.md](VENV.md)
file shows how to setup a virtual environment for testing.


22 changes: 22 additions & 0 deletions test/pyucis-fir/VENV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# venv notes

# Create and activate the venv

Do this once

```
sudo apt-get install python3-venv
python3 -m venv venv
. venv/bin/activate
python3 -m pip install -r requirements.txt
# test that usis can be imported
python3 -c 'import ucis'
alias bazel='/home/davis/bin/bazel-4.2.1-linux-x86_64'
```


# Activate the venv

```
. venv/bin/activate
```
1 change: 1 addition & 0 deletions test/pyucis-fir/coverage_results.xml
4 changes: 4 additions & 0 deletions test/pyucis-fir/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyucis==0.0.5.20220416.1
pylint
pyyaml

16 changes: 16 additions & 0 deletions test/pyucis-fir/ucis_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Tests for ucis."""

import unittest
from validate_ucis_xml import validate_ucis



class UcisTest(unittest.TestCase):

def test_validate_ucis_xml(self):
self.assertTrue(validate_ucis('../../examples/fir/coverage_results.xml'))



if __name__ == '__main__':
unittest.main()
44 changes: 44 additions & 0 deletions test/pyucis-fir/validate_ucis_xml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
""" Test script to compare coverage_results.xml with spec

Use pyucis to validate fir example coverage result generated
by FC4SC against specification.
"""

from io import BytesIO
from ucis.xml import validate_ucis_xml



def validate_ucis(file_name):
"""
Validate UCIS function

: arg file_name: The filename to validate
: returns: status of validation. TODO:return
"""
rc = False

try:
with open(file_name, encoding='utf-8') as f:
xml_file = BytesIO(bytes(bytearray(f.read(), encoding='utf-8')))
rc = validate_ucis_xml(xml_file)
except:
print("an exception occured")

return rc


def main() -> None:

rc = validate_ucis('../../examples/fir/coverage_results.xml')
return rc



if __name__ == '__main__':
rc = main()
if rc:
print("validation OK")
else:
print("validation Failure")

1 change: 1 addition & 0 deletions tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
22 changes: 22 additions & 0 deletions tools/VENV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# venv notes

# Create and activate the venv

Do this once

```
sudo apt-get install python3-venv
python3 -m venv venv
. venv/bin/activate
python3 -m pip install -r requirements.txt
# test that usis can be imported
python3 -c 'import ucis'
alias bazel='/home/davis/bin/bazel-4.2.1-linux-x86_64'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this alias does, but it looks hardcoded for specific user. Can it be removed? Otherwise it need to be generalized.

```


# Activate the venv

```
. venv/bin/activate
```
1 change: 1 addition & 0 deletions tools/coverage_report/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JFD/*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some local unneeded files?

6 changes: 6 additions & 0 deletions tools/coverage_report/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Usage

```
python3 report.py --xml_report foo.xml --yaml_out foo.yml
```

25 changes: 16 additions & 9 deletions tools/coverage_report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import argparse
import xml.etree.ElementTree as ET

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))

from ucis_parser import UCIS_DB_Parser

Expand Down Expand Up @@ -53,7 +53,9 @@ def get_covergroup_report_data(self, covergroupCoverage, module_data):

def get_coverpoint_report_data(self, cgInstance, cg_cp_bin_map, cg_data):
for coverpoint in self.findall_ucis_children(cgInstance, "coverpoint"):
print("coverpoint is ", coverpoint)
options = self.find_ucis_element(coverpoint, 'options')
print("JFD options is ", options)
cp_name = coverpoint.get('name')
cp_data = {
'item_type' : 'point',
Expand All @@ -78,7 +80,11 @@ def get_coverpoint_report_data(self, cgInstance, cg_cp_bin_map, cg_data):
else:
cp_data['bin_misses'] += 1
cp_data['misses'].append(bin_name)
cp_data['pct_cov'] = 100 * ((cp_data['bin_count'] - cp_data['bin_misses']) / float(cp_data['bin_count']))
if cp_data['bin_count'] == 0:
print('should not happen. get_coverpoint_report_data() cp_data["bin_count"] is zero')
print('skip')
else:
cp_data['pct_cov'] = 100 * ((cp_data['bin_count'] - cp_data['bin_misses']) / float(cp_data['bin_count']))

def collect_cross_bins(self, exprs, cg_cp_bin_map, parrent_bins):
expr_name = exprs[0].text
Expand All @@ -95,7 +101,6 @@ def get_cross_bin_name_from_tuple(self, cg_cp_bin_map, exprs, bin_tuple):
names = []
for expr_idx, bin_idx in enumerate(bin_tuple):
expr_name = exprs[expr_idx].text
#expr_bin_name = "%s(%s)" % (expr_name, cg_cp_bin_map[expr_name][bin_idx])
expr_bin_name = cg_cp_bin_map[expr_name][bin_idx]
names.append(expr_bin_name)
names.reverse()
Expand Down Expand Up @@ -126,7 +131,6 @@ def get_cross_report_data(self, cgInstance, cg_cp_bin_map, cg_data):
for cbin in all_cross_bins:
bin_hits[cbin] = 0

#
for bin_idx, bin in enumerate(self.findall_ucis_children(cross, "crossBin")):
bin_name = bin.get('name')
cg_cp_bin_map[cr_name][bin_idx] = bin_name
Expand All @@ -144,7 +148,10 @@ def get_cross_report_data(self, cgInstance, cg_cp_bin_map, cg_data):
else:
cr_data['bin_misses'] += 1
cr_data['misses'].append(self.get_cross_bin_name_from_tuple(cg_cp_bin_map, exprs, bin_tuple))
cr_data['pct_cov'] = 100 * ((cr_data['bin_count'] - cr_data['bin_misses']) / float(cr_data['bin_count']))
if cr_data['bin_count'] == 0:
print('JFD in get_cross_report_data() cr_data["bin_count"] is zero')
else:
cr_data['pct_cov'] = 100 * ((cr_data['bin_count'] - cr_data['bin_misses']) / float(cr_data['bin_count']))

args = {}

Expand Down Expand Up @@ -201,12 +208,12 @@ def reduce_to_cg_inst_summary(db):
args = parser.parse_args()

parser = UCIS_DB_Reporter()

if not args.xml_report:
raise ValueError("No input XML provided!")
if not args.yaml_out:
raise ValueError("No output YAML name provided!")

try:
d = parser.get_report_data(args.xml_report)
except IOError as e:
Expand All @@ -224,9 +231,9 @@ def reduce_to_cg_inst_summary(db):
if not args.quiet:
print("""
Overall Summary:

Total Coverage: %6.2f

Module Summary:
""" % (yaml_db['pct_cov']))

Expand Down
4 changes: 4 additions & 0 deletions tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyucis==0.0.5.20220416.1
pylint
pyyaml