-
Notifications
You must be signed in to change notification settings - Fork 15
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
Initial test case validation using pyucis #23
base: master
Are you sure you want to change the base?
Changes from all commits
3aa967b
44b298d
32f39e4
d9e477f
d215168
b02bfea
15b8e17
4f76a32
d4d82e3
637e879
41976e3
6200e03
d36fb7a
9d0523f
cea7a5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
.settings/ | ||
Debug/ | ||
.pydevproject | ||
venv/ | ||
setenv.sh | ||
fir.xml |
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 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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\" " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not look ready to go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are hardcoded 1's and "KEY" in the code. The sample xml I am looking at has 4625 key="0" in it. It also has 54 entires which look like this
None have a value other than 1. |
||
<< "line=\"" << line << "\"" | ||
<< " inlineCount=\"1\"/>\n"; | ||
stream << "</ucis:cgId>\n"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__/ |
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 |
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. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# venv notes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are personal notes and don't belong to this project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figured it would help with someone who wanted to run the same setup, but sure I can back it out. |
||
|
||
# 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 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../examples/fir/coverage_results.xml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pyucis==0.0.5.20220416.1 | ||
pylint | ||
pyyaml | ||
|
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() |
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") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__/ |
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 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pyucis==0.0.5.20220416.1 | ||
pylint | ||
pyyaml | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the rename necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spaces in the name cause problems with my bash code parser. Its a preference to fix. FWIW, the output does not match the golden coverage report either. ie. foo[1] vs foo_1. I can handle either but spaces cause me to have to tweak the code.
If its a problem I can reverse this one. I was just thinking ahead. I don't know if the pyucis one has a problem with it to be honest. I do know the sample I am looking at has all _ separated names. FWIW the spec says this, but I am not entirely clear about the spec: