Skip to content

Commit e03ff98

Browse files
committed
Merge branch 'main' of github.com:mgeeIOL/ocre-runtime into test-initial-basic-rp5-tests
2 parents 8b04724 + 091452e commit e03ff98

25 files changed

Lines changed: 459 additions & 96 deletions

File tree

.github/workflows/linux.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,25 @@ jobs:
5757
- name: Delete build directory
5858
run: rm -rf build
5959

60-
- name: Configure (source coverage)
60+
- name: Configure (test coverage)
6161
run: mkdir build && cd build && cmake ../tests/coverage
6262

63-
- name: Build and run (source coverage)
63+
- name: Build and run (test coverage)
6464
working-directory: build
65-
run: make
65+
run: make coverage report.md
6666

6767
- name: Upload coverage report
6868
uses: actions/upload-artifact@v4
6969
with:
7070
name: ocre-coverage
7171
include-hidden-files: true
72-
path: build/report
72+
path: build/coverage
73+
74+
- name: Report code coverage
75+
uses: marocchino/sticky-pull-request-comment@v3
76+
with:
77+
GITHUB_TOKEN: ${{ secrets.TOKEN_WRITE_PR }}
78+
path: build/report.md
7379

7480
- name: Delete build directory
7581
run: rm -rf build

.github/workflows/zephyr-systests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
image: ghcr.io/${{ github.repository }}/devcontainer-zephyr:${{ inputs.devcontainer-tag }}
2323
options: --user 1000:1000
2424
strategy:
25+
fail-fast: false
2526
matrix:
2627
test:
2728
- container

src/ocre/container.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <errno.h>
99
#include <stdlib.h>
1010
#include <stdint.h>
11+
#include <unistd.h>
1112
#include <string.h>
1213
#include <stdbool.h>
1314
#include <pthread.h>
@@ -145,12 +146,23 @@ static const char *ocre_find_best_matching_runtime(const char *image)
145146

146147
struct ocre_container *ocre_container_create(const char *img_path, const char *workdir, const char *runtime,
147148
const char *container_id, bool detached,
148-
const struct ocre_container_args *arguments)
149+
const struct ocre_container_args *arguments, int stdin_fd, int stdout_fd,
150+
int stderr_fd)
149151
{
150152
int rc;
151153
const char **capabilities = NULL;
152154
const char **mounts = NULL;
153155

156+
if (stdin_fd < 0) {
157+
stdin_fd = STDIN_FILENO;
158+
}
159+
if (stdout_fd < 0) {
160+
stdout_fd = STDOUT_FILENO;
161+
}
162+
if (stderr_fd < 0) {
163+
stderr_fd = STDERR_FILENO;
164+
}
165+
154166
if (!runtime) {
155167
runtime = ocre_find_best_matching_runtime(img_path);
156168
if (!runtime) {
@@ -266,9 +278,9 @@ struct ocre_container *ocre_container_create(const char *img_path, const char *w
266278
goto error_mutex;
267279
}
268280

269-
container->runtime_context =
270-
container->runtime->create(container_id, img_path, workdir, capabilities,
271-
(const char **)container->argv, (const char **)container->envp, mounts);
281+
container->runtime_context = container->runtime->create(
282+
container_id, img_path, workdir, capabilities, (const char **)container->argv,
283+
(const char **)container->envp, mounts, stdin_fd, stdout_fd, stderr_fd);
272284
if (!container->runtime_context) {
273285
LOG_ERR("Failed to create container");
274286
goto error_cond;

src/ocre/container.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ struct ocre_container;
1313

1414
struct ocre_container *ocre_container_create(const char *img_path, const char *workdir, const char *runtime,
1515
const char *container_id, bool detached,
16-
const struct ocre_container_args *arguments);
16+
const struct ocre_container_args *arguments, int stdin_fd, int stdout_fd,
17+
int stderr_fd);
1718
int ocre_container_destroy(struct ocre_container *container);

src/ocre/context.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ int ocre_context_destroy(struct ocre_context *context)
177177

178178
struct ocre_container *ocre_context_create_container(struct ocre_context *context, const char *image,
179179
const char *const runtime, const char *container_id, bool detached,
180-
const struct ocre_container_args *arguments)
180+
const struct ocre_container_args *arguments, int stdin_fd,
181+
int stdout_fd, int stderr_fd)
181182
{
182183
const char *computed_container_id = NULL;
183184
struct ocre_container *container = NULL;
@@ -285,7 +286,7 @@ struct ocre_container *ocre_context_create_container(struct ocre_context *contex
285286
/* Create the container */
286287

287288
container = ocre_container_create(image_path, container_workdir, runtime, computed_container_id, detached,
288-
arguments);
289+
arguments, stdin_fd, stdout_fd, stderr_fd);
289290
if (!container) {
290291
LOG_ERR("Failed to create container %s: errno=%d", computed_container_id, errno);
291292
goto error;

src/ocre/include/ocre/container.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99
#define OCRE_CONTAINER_H
1010

1111
#include <stdbool.h>
12+
#include <unistd.h>
13+
14+
/* Hack until Zephyr define those */
15+
#ifndef STDIN_FILENO
16+
#define STDIN_FILENO 0
17+
#endif
18+
19+
#ifndef STDOUT_FILENO
20+
#define STDOUT_FILENO 1
21+
#endif
22+
23+
#ifndef STDERR_FILENO
24+
#define STDERR_FILENO 2
25+
#endif
1226

1327
/**
1428
* @brief The possible status of a container

src/ocre/include/ocre/context.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,16 @@ struct ocre_container_args {
129129
* @param container_id The ID to assign to the container. Can be NULL, in which case a random ID will be generated
130130
* @param detached Whether the container should be detached (run in the background) or not
131131
* @param arguments The container arguments to pass to the container. Can be NULL
132+
* @param stdin_fd The file descriptor to use for stdin. Can be -1 to use the default (STDIN_FILENO)
133+
* @param stdout_fd The file descriptor to use for stdout. Can be -1 to use the default (STDOUT_FILENO)
134+
* @param stderr_fd The file descriptor to use for stderr. Can be -1 to use the default (STDERR_FILENO)
132135
*
133136
* @return A pointer to the newly created container, or NULL on failure
134137
*/
135138
struct ocre_container *ocre_context_create_container(struct ocre_context *context, const char *image,
136139
const char *const runtime, const char *container_id, bool detached,
137-
const struct ocre_container_args *arguments);
140+
const struct ocre_container_args *arguments, int stdin_fd,
141+
int stdout_fd, int stderr_fd);
138142

139143
/**
140144
* @brief Get a container by its ID

src/ocre/ocre.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <string.h>
9+
#include <stdio.h>
910
#include <errno.h>
1011
#include <stdlib.h>
1112
#include <strings.h>

src/platform/zephyr/memory.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ void *user_realloc(void *ptr, size_t size)
2929

3030
#else
3131

32+
#ifndef CONFIG_SOC_POSIX
3233
#warning CONFIG_SHARED_MULTI_HEAP is not defined. Using internal RAM
34+
#endif
3335

3436
void *user_malloc(size_t size)
3537
{

0 commit comments

Comments
 (0)