-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
;-------------------------------------------------------------------- | ||
; Simple sequence file | ||
; Note: that anything after a ';' is a comment | ||
;-------------------------------------------------------------------- | ||
|
||
|
||
R00:00:00 cmdDisp.CMD_NO_OP | ||
R00:00:00 cmdDisp.CMD_NO_OP_STRING "Awesome string!" ; And a nice comment too | ||
R00:00:00 cmdDisp.FRNDLY_GRTNG "Hello!" | ||
Check failure on line 9 in test/fprime_gds/common/tools/input/simple_bad_sequence.seq GitHub Actions / Spell checking
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
;-------------------------------------------------------------------- | ||
; Simple sequence file | ||
; Note: that anything after a ';' is a comment | ||
;-------------------------------------------------------------------- | ||
|
||
|
||
R00:00:00 cmdDisp.CMD_NO_OP | ||
R00:00:00 cmdDisp.CMD_NO_OP_STRING "Awesome string!" ; And a nice comment too |
40 changes: 40 additions & 0 deletions
40
test/fprime_gds/common/tools/resources/simple_dictionary.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"metadata" : { | ||
"deploymentName" : "test", | ||
"projectVersion" : "0", | ||
"frameworkVersion" : "0", | ||
"libraryVersions" : [ | ||
], | ||
"dictionarySpecVersion" : "1.0.0" | ||
}, | ||
"commands" : [ | ||
{ | ||
"name" : "cmdDisp.CMD_NO_OP_STRING", | ||
"commandKind" : "async", | ||
"opcode" : 4097, | ||
"formalParams" : [ | ||
{ | ||
"name" : "arg1", | ||
"type" : { | ||
"name" : "string", | ||
"kind" : "string", | ||
"size" : 40 | ||
}, | ||
"ref" : false, | ||
"annotation" : "The String command argument" | ||
} | ||
], | ||
"queueFullBehavior" : "assert", | ||
"annotation" : "No-op string command" | ||
}, | ||
{ | ||
"name" : "cmdDisp.CMD_NO_OP", | ||
"commandKind" : "async", | ||
"opcode" : 4096, | ||
"formalParams" : [ | ||
], | ||
"queueFullBehavior" : "assert", | ||
"annotation" : "No-op command" | ||
} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
test/fprime_gds/common/tools/resources/simple_dictionary.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<dictionary topology="test" framework_version="0" project_version="0"> | ||
<commands> | ||
<command component="cmdDisp" mnemonic="CMD_NO_OP" opcode="0x1000" description="No-op command"> | ||
<args/> | ||
</command> | ||
<command component="cmdDisp" mnemonic="CMD_NO_OP_STRING" opcode="0x1001" description="No-op string command"> | ||
<args> | ||
<arg name="arg1" description=" The String command argument " len="40" type="string"/> | ||
</args> | ||
</command> | ||
</commands> | ||
</dictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,42 @@ | ||
import filecmp | ||
from pathlib import Path | ||
import tempfile | ||
import unittest | ||
|
||
import fprime_gds.common.tools.seqgen as seqgen | ||
|
||
class APITestCases(unittest.TestCase): | ||
def test_nominal_sequence(self): | ||
|
||
pass | ||
self.assertEqual(self.diff_input_sequence( | ||
"./input/simple_sequence.seq", | ||
"./expected/simple_sequence_expected.bin", | ||
"./resources/simple_dictionary.json" | ||
), True) | ||
|
||
# This test is expected to fail due to unmatched command in | ||
# simple_bad_sequence.seq and seqgen should produce a SeqGenException. | ||
# Passing these executions is a test failure. | ||
@unittest.expectedFailure | ||
def test_fail_unmatched_command_sequence(self): | ||
self.diff_input_sequence( | ||
"./input/simple_bad_sequence.seq", | ||
"./expected/simple_sequence_expected.bin", | ||
"./resources/simple_dictionary.json" | ||
) | ||
|
||
def diff_input_sequence(self, input_sequence, expected_output, dictionary): | ||
temp_dir = tempfile.TemporaryDirectory() | ||
output_bin = Path(f"{temp_dir.name}/out_binary") | ||
seqgen.generateSequence( | ||
input_sequence, | ||
output_bin, | ||
dictionary, | ||
0xffff | ||
) | ||
is_equal = filecmp.cmp(output_bin, expected_output) | ||
Check failure on line 36 in test/fprime_gds/common/tools/seqgen_unit_test.py GitHub Actions / Spell checking
|
||
temp_dir.cleanup() | ||
return is_equal | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |