-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
third_party/machinarium/channel_api: add ready count fn
This function will be used to obtain information about workers task_channel size in future commits. Signed-off-by: rkhapov <[email protected]> (cherry picked from commit fe27077) Signed-off-by: rkhapov <[email protected]>
- Loading branch information
Showing
10 changed files
with
102 additions
and
0 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
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,55 @@ | ||
|
||
#include <machinarium.h> | ||
#include <odyssey_test.h> | ||
|
||
static void test_coroutine(void *arg) | ||
{ | ||
(void)arg; | ||
machine_channel_t *channel; | ||
channel = machine_channel_create(0); | ||
test(channel != NULL); | ||
|
||
machine_msg_t *msg; | ||
msg = machine_msg_create(0); | ||
test(msg != NULL); | ||
|
||
test(machine_channel_ready_count(channel) == 0); | ||
|
||
machine_msg_set_type(msg, 1); | ||
machine_channel_write(channel, msg); | ||
test(machine_channel_ready_count(channel) == 1); | ||
|
||
machine_channel_write(channel, msg); | ||
test(machine_channel_ready_count(channel) == 2); | ||
|
||
machine_channel_write(channel, msg); | ||
test(machine_channel_ready_count(channel) == 3); | ||
|
||
(void)machine_channel_read_back(channel, UINT32_MAX); | ||
test(machine_channel_ready_count(channel) == 2); | ||
|
||
(void)machine_channel_read_back(channel, UINT32_MAX); | ||
test(machine_channel_ready_count(channel) == 1); | ||
|
||
(void)machine_channel_read_back(channel, UINT32_MAX); | ||
test(machine_channel_ready_count(channel) == 0); | ||
|
||
machine_msg_free(msg); | ||
|
||
machine_channel_free(channel); | ||
} | ||
|
||
void machinarium_test_channel_ready_count(void) | ||
{ | ||
machinarium_init(); | ||
|
||
int id; | ||
id = machine_create("test", test_coroutine, NULL); | ||
test(id != -1); | ||
|
||
int rc; | ||
rc = machine_wait(id); | ||
test(rc != -1); | ||
|
||
machinarium_free(); | ||
} |
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
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
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
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
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
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
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
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