-
Notifications
You must be signed in to change notification settings - Fork 14
support unit test with picotest. This unit test runs when the libtlp is compiled. #3
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
Open
sora
wants to merge
13
commits into
NetTLP:master
Choose a base branch
from
sora:picotest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7b0c82b
git module add picotest
sora 34ea5fa
ctest: initial support
sora 0fc7e5c
unit_test: test_tlp_calculate_fstdw_lstdw
sora b99da45
unit_test: test_tlp_calculate_length
sora c278742
Merge remote-tracking branch 'origin' into picotest
sora e13c1e1
move test/* to snippet/
sora e7ffe1e
move unit_test.c to test/test.c
sora 7b96a78
cmake: use findthreads
sora ed67dcd
test: comment out tests that fail temporarily
sora 49e6573
cmake: minor
sora 56fc334
github-actions: support ctest
sora 02d2a92
test: test_tlp_mr_addr
sora 83af726
test: minor
sora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| [submodule "picotest"] | ||
| path = picotest | ||
| url = https://github.com/h2o/picotest.git |
This file contains hidden or 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
This file contains hidden or 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,153 @@ | ||
| #include "picotest/picotest.h" | ||
|
|
||
| #include <libtlp.h> | ||
|
|
||
| static void | ||
| calculate_fstdw_lstdw(uintptr_t addr, size_t count, int *result_fst, int *result_lst) | ||
| { | ||
| *result_fst = tlp_calculate_fstdw(addr, count); | ||
| *result_lst = tlp_calculate_lstdw(addr, count); | ||
| //note("result_fst=0x%x, result_lst=0x%x", *result_fst, *result_lst); | ||
| } | ||
|
|
||
| static void | ||
| test_tlp_calculate_fstdw_lstdw(void) | ||
| { | ||
| int result_fst, result_lst; | ||
|
|
||
| // zero-length read and write | ||
| calculate_fstdw_lstdw(0x0, 0, &result_fst, &result_lst); | ||
| ok(result_fst == 0 && result_lst == 0); | ||
|
|
||
| calculate_fstdw_lstdw(0x0, 4093, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0x1); | ||
|
|
||
| calculate_fstdw_lstdw(0x0, 4094, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0x3); | ||
|
|
||
| calculate_fstdw_lstdw(0x0, 4095, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0x7); | ||
|
|
||
| calculate_fstdw_lstdw(0x0, 4096, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0xf); | ||
|
|
||
| // zero-length read and write | ||
| calculate_fstdw_lstdw(0xa0000003, 0, &result_fst, &result_lst); | ||
| ok(result_fst == 0x0 && result_lst == 0x0); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 1, &result_fst, &result_lst); | ||
| ok(result_fst == 0x1 && result_lst == 0x0); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 2, &result_fst, &result_lst); | ||
| ok(result_fst == 0x3 && result_lst == 0x0); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 3, &result_fst, &result_lst); | ||
| ok(result_fst == 0x7 && result_lst == 0x0); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 4, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0x0); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 5, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0x1); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 6, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0x3); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 7, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0x7); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 8, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0xf); | ||
|
|
||
| calculate_fstdw_lstdw(0xa0000000, 16, &result_fst, &result_lst); | ||
| ok(result_fst == 0xf && result_lst == 0xf); | ||
|
|
||
| calculate_fstdw_lstdw(0x00000003, 9, &result_fst, &result_lst); | ||
| ok(result_fst == 0x8 && result_lst == 0xf); | ||
|
|
||
| calculate_fstdw_lstdw(0x00000003, 10, &result_fst, &result_lst); | ||
| ok(result_fst == 0x8 && result_lst == 0x1); | ||
|
|
||
| calculate_fstdw_lstdw(0x00000003, 11, &result_fst, &result_lst); | ||
| ok(result_fst == 0x8 && result_lst == 0x3); | ||
|
|
||
| calculate_fstdw_lstdw(0x00000003, 12, &result_fst, &result_lst); | ||
| ok(result_fst == 0x8 && result_lst == 0x7); | ||
|
|
||
| calculate_fstdw_lstdw(0x00000003, 13, &result_fst, &result_lst); | ||
| ok(result_fst == 0x8 && result_lst == 0xf); | ||
| } | ||
|
|
||
| static void | ||
| test_tlp_calculate_length(void) | ||
| { | ||
| int result_length; | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 0); | ||
| ok(result_length == 0); | ||
|
|
||
| result_length = tlp_calculate_length(0x1, 0); | ||
| ok(result_length == 0); | ||
|
|
||
| result_length = tlp_calculate_length(0x2, 0); | ||
| ok(result_length == 0); | ||
|
|
||
| result_length = tlp_calculate_length(0x3, 0); | ||
| ok(result_length == 0); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 1); | ||
| ok(result_length == 1); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 2); | ||
| ok(result_length == 1); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 3); | ||
| ok(result_length == 1); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 4); | ||
| ok(result_length == 1); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 5); | ||
| ok(result_length == 2); | ||
|
|
||
| result_length = tlp_calculate_length(0x3, 2); | ||
| ok(result_length == 2); | ||
|
|
||
| result_length = tlp_calculate_length(0x3, 7); | ||
| ok(result_length == 3); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 4089); | ||
| ok(result_length == 1023); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 4090); | ||
| ok(result_length == 1023); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 4091); | ||
| ok(result_length == 1023); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 4092); | ||
| ok(result_length == 1023); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 4093); | ||
| ok(result_length == 0); | ||
|
Collaborator
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 four tests also fail. result_length must be 1024. |
||
|
|
||
| result_length = tlp_calculate_length(0x0, 4094); | ||
| ok(result_length == 0); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 4095); | ||
| ok(result_length == 0); | ||
|
|
||
| result_length = tlp_calculate_length(0x0, 4096); | ||
| ok(result_length == 0); | ||
|
|
||
| } | ||
|
|
||
| int | ||
| main(int argc, char **argv) | ||
| { | ||
| subtest("tlp_calculate_fstdw_lstdw", test_tlp_calculate_fstdw_lstdw); | ||
| subtest("tlp_calculate_length", test_tlp_calculate_length); | ||
|
|
||
| return done_testing(); | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This test fails. the correct behavior is 0?