-
Notifications
You must be signed in to change notification settings - Fork 141
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
Also generate normalized XML #168
Conversation
test/generate-xml.sh
Outdated
generate_xml() { | ||
directory="$1" | ||
hexfile="$2" | ||
mode="$3" | ||
|
||
filename=`basename $hexfile .hex` |
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.
filename=`basename $hexfile .hex` | |
filename=$(basename "$hexfile" .hex) |
Shellcheck, a linter for shell scripts using $( ) instead of
, and wants you to add quotes where filenames possibly could contain spaces.
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.
Makes sense
test/generate-xml.sh
Outdated
# Parse hex file and write XML in file | ||
$mbus_parse_hex "$hexfile" > "$directory/$filename.xml.new" | ||
$mbus_parse_hex $options "$hexfile" > "$directory/$filename$suffix.new" |
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.
Personal opinion: I would have a dot after filename, and probably keep "xml.new" down here.
Since that is invariant (does not differ over the two cases.
if [ $mode = "normalized" ]; then
options="-n"
suffix="norm"
else
options=""
suffix=""
fi
...
$mbus_parse_hex $options "$hexfile" > "$directory/$filename.${suffix}xml.new"
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.
I didn't understand the keep xml.new thing. In case the output differ we keep the new file. So we need the suffix, otherwise we will overwrite the new default output.
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.
What I was trying to say, is that both modes "default" and "normalized" will name the files withe the ending ".xml.new",
I would write it like this:
options = ""
if [ "$mode" = "default" ]; then
mode=""
elif [ "$mode" = "normalized" ];
mode=".norm"
options="-n"
else
echo "ERROR: Unknown mode $mode."
return 1
fi
...
$mbus_parse_hex $options "$hexfile" > "$directory/$filename$mode.xml.new"
diff -u "$directory/$filename$mode.xml" "$directory/$filename$mode.xm.new" 2> /dev/null > "$directory/$filename$mode.dif"
test/generate-xml.sh
Outdated
fi | ||
|
||
# Compare old XML with new XML and write in file | ||
diff -u "$directory/$filename.xml" "$directory/$filename.xml.new" 2> /dev/null > "$directory/$filename.dif" | ||
diff -u "$directory/$filename$suffix" "$directory/$filename$suffix.new" 2> /dev/null > "$directory/$filename.dif" |
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.
diff -u "$directory/$filename$suffix" "$directory/$filename$suffix.new" 2> /dev/null > "$directory/$filename.dif" | |
diff -u "$directory/$filename$suffix" "$directory/$filename$suffix.new" 2> /dev/null > "$directory/$filename$suffix.dif" |
I would like to run all tests at once, and see every failed test at once. Both not nromailized and normalized could fail. So it is better to add the suffix here. So there is no question about which test that failed.
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.
Found some more things...
generate_xml "$directory" "$hexfile" "default" | ||
|
||
generate_xml "$directory" "$hexfile" "normalized" |
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.
Here we don't seem to look at the return value of the function
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.
Or did you intend me to update the commit "make build stop on broken tests"?
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.
It was your idea, so you should get the credits for it.
test/generate-xml.sh
Outdated
rm "$directory/$filename.dif" | ||
;; | ||
esac | ||
|
||
return 0 |
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.
return 0 | |
return $result |
85afa2d
to
d114d53
Compare
I pushed a new version |
Hello We can definetly handle this as a new issue. I didn't notice this until I rebased my work onto your PR and ran the tests. When looking at the tests of this PR, https://github.com/rscada/libmbus/pull/168/checks?check_run_id=816071416 Lines 12-14 of the step "generate test frames" is new.
Locally, I added this command It indicated:
Looking at the diff, indicates that datarecord with id=2 is completly empty in the normalized file.
I would suggest two actions from this.
|
<DataRecord id="2"> | ||
</DataRecord> |
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.
See comment #168 (comment) .
This is probably where this is printed.
mbus_vif_unit_normalize: Unknown VIF 0x07B
mbus_vib_unit_normalize: Error mbus_vif_unit_normalize
mbus_parse_variable_record: problem with mbus_vib_unit_normalize
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.
Perhaps skip checking in this file while this issue remains?
In order to increase the test coverage also generate the normalized version of XML output.
d114d53
to
9799794
Compare
In order to increase the test coverage also generate the normalized version
of XML output.