Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/zephyr-systests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- lib
- ocre
- context
- input_output
steps:
- name: Clean other workspace
run: rm -rf ../.west
Expand Down
23 changes: 16 additions & 7 deletions tests/system/input_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,25 @@ void test_ocre_container_output_stdout(void)

ocre_container_wait(container, NULL);

char buf[1000];
/* Skip to newline */

char c;
do {
size_t n = read(stdout_pair[0], &c, 1);
TEST_ASSERT_EQUAL_size_t(1, n);
} while (c != '\n');

char buf[19]; /* "argv[1]=Zirigdum!\n" */
memset(buf, 0, sizeof(buf));

ssize_t n = read(stdout_pair[0], buf, sizeof(buf) - 1);

TEST_ASSERT_GREATER_THAN_size_t(0, n);

char *second_line = strchr(buf, '\n');
++second_line;
TEST_ASSERT_NOT_NULL(second_line);
TEST_ASSERT_EQUAL_size_t(sizeof(buf) - 1, n);

TEST_ASSERT_EQUAL_STRING("argv[1]=" ARG_TEST_STRING "\n", second_line);
TEST_ASSERT_EQUAL_STRING("argv[1]=" ARG_TEST_STRING "\n", buf);

ocre_container_kill(container);
close(stdout_pair[0]);
ocre_container_wait(container, NULL);

ocre_context_remove_container(context, container);
Expand Down Expand Up @@ -94,6 +99,8 @@ void test_ocre_container_input_stdin_output_stdout(void)
TEST_ASSERT_EQUAL_STRING(ARG_TEST_STRING "\n", buf);

ocre_container_kill(container);
close(stdin_pair[0]);
close(stdout_pair[0]);
ocre_container_wait(container, NULL);

ocre_context_remove_container(context, container);
Expand Down Expand Up @@ -131,6 +138,8 @@ void test_ocre_container_input_stdin_output_stderr(void)
TEST_ASSERT_EQUAL_STRING(ARG_TEST_STRING "\n", buf);

ocre_container_kill(container);
close(stdin_pair[0]);
close(stderr_pair[0]);
ocre_container_wait(container, NULL);

ocre_context_remove_container(context, container);
Expand Down
3 changes: 3 additions & 0 deletions tests/system/zephyr/input_output/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ add_library(Unity STATIC
../../../../tests/Unity/src/unity.c
)

target_link_libraries(Unity PUBLIC zephyr_interface)


target_include_directories(Unity PUBLIC
../../../../tests/Unity/src
)
Expand Down
Loading