Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
midnightveil committed Sep 4, 2024
1 parent ba073b8 commit cc4c48c
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tool/microkit/tests/sdf/ch_end_invalid_notify.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2024, UNSW.
SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<protection_domain name="test1">
<program_image path="test" />
</protection_domain>
<protection_domain name="test2">
<program_image path="test" />
</protection_domain>

<channel>
<end pd="test1" id="0" />
<end pd="test2" id="5" notify="no" />
</channel>
</system>
19 changes: 19 additions & 0 deletions tool/microkit/tests/sdf/ch_end_invalid_pp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2024, UNSW.
SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<protection_domain name="test1">
<program_image path="test" />
</protection_domain>
<protection_domain name="test2">
<program_image path="test" />
</protection_domain>

<channel>
<end pd="test1" id="0" pp="no" />
<end pd="test2" id="5"/>
</channel>
</system>
19 changes: 19 additions & 0 deletions tool/microkit/tests/sdf/ch_invalid_element.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2024, UNSW.
SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<protection_domain name="test1">
<program_image path="test" />
</protection_domain>
<protection_domain name="test2">
<program_image path="test" />
</protection_domain>

<channel>
<ending pd="test1" id="0" />
<end pd="test2" id="5" notify="true" />
</channel>
</system>
18 changes: 18 additions & 0 deletions tool/microkit/tests/sdf/ch_not_enough_ends.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2024, UNSW.
SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<protection_domain name="test1">
<program_image path="test" />
</protection_domain>
<protection_domain name="test2">
<program_image path="test" />
</protection_domain>

<channel>
<end pd="test1" id="5" notify="true" />
</channel>
</system>
20 changes: 20 additions & 0 deletions tool/microkit/tests/sdf/ch_too_many_ends.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2024, UNSW.
SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<protection_domain name="test1">
<program_image path="test" />
</protection_domain>
<protection_domain name="test2">
<program_image path="test" />
</protection_domain>

<channel>
<end pd="test1" id="5" notify="true" />
<end pd="test2" id="5" notify="true" />
<end pd="test2" id="5" notify="true" />
</channel>
</system>
40 changes: 40 additions & 0 deletions tool/microkit/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,46 @@ mod channel {
"Error: invalid PD name 'invalidpd' on element 'end': ",
)
}

#[test]
fn test_invalid_element() {
check_error(
"ch_invalid_element.xml",
"Error: invalid XML element 'ending': ",
)
}

#[test]
fn test_not_enough_ends() {
check_error(
"ch_not_enough_ends.xml",
"Error: exactly two end elements must be specified on element 'channel': ",
)
}

#[test]
fn test_too_many_ends() {
check_error(
"ch_too_many_ends.xml",
"Error: exactly two end elements must be specified on element 'channel': ",
)
}

#[test]
fn test_end_invalid_pp() {
check_error(
"ch_end_invalid_pp.xml",
"Error: pp must be 'true'/'false' on element 'end': ",
)
}

#[test]
fn test_end_invalid_notify() {
check_error(
"ch_end_invalid_notify.xml",
"Error: notify must be 'true'/'false' on element 'end': ",
)
}
}

#[cfg(test)]
Expand Down

0 comments on commit cc4c48c

Please sign in to comment.