Skip to content
Draft
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
14 changes: 14 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ jobs:
- name: Delete build directory
run: rm -rf build

- name: Configure (system tests IPC)
run: mkdir build && cd build && cmake ../tests/system/posix-ipc

- name: Build (system tests IPC)
working-directory: build
run: make

- name: Run (system tests IPC)
working-directory: build
run: make run-systests

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

- name: Configure (leak checks)
run: mkdir build && cd build && cmake ../tests/leaks

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
[submodule "tests/Unity"]
path = tests/Unity
url = https://github.com/ThrowTheSwitch/Unity.git
[submodule "src/samples/supervisor/posix/zcbor"]
path = src/samples/supervisor/posix/zcbor
url = https://github.com/NordicSemiconductor/zcbor.git
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ add_subdirectory(src/shell)
add_subdirectory(src/samples/mini/posix)
add_subdirectory(src/samples/demo/posix)

# supervisor
add_subdirectory(src/samples/supervisor/posix)

# this sample is useful for static code analysis on POSIX
add_subdirectory(src/samples/static_checks/posix)
8 changes: 4 additions & 4 deletions docs/samples/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ The demo sample will run a few scenarios in a sequential demonstration.
Currently it will run the following scenarios in order:

1. `hello-world.wasm`
- Prints a nice ASCII art
- Prints a nice ASCII art

2. `blinky.wasm` runs for 2 seconds
- Prints some logs to stdout
- Prints some logs to stdout

3. `subscriber.wasm` and `publisher.wasm` run alongside for 4 seconds
- Exchange messages between the containers
- Exchange messages between the containers

It requires the [state information](../StateInformation.md) directory
to load the images from.
Expand All @@ -27,7 +27,7 @@ tools for Linux described in the [Get Started with Linux](../GetStartedLinux.md)

In Linux, the demo sample is part of the main library build.

From the root of the repository, or from anywhere else, reate build directory:
From the root of the repository, or from anywhere else, create build directory:

```sh
mkdir build
Expand Down
94 changes: 82 additions & 12 deletions docs/samples/supervisor.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ It also preloads the following images:
- `webserver-complex.wasm`
- `webserver.wasm`

Currently it only supports Zephyr.
In Zephyr, there is no daemon, and Ocre is run directly from the command line. In Linux there is the `ocred` daemon, which listens in a socket and `ocre` (client) will connect to it.

In Linux, a library called OcreClient is used to interact with the daemon. It offers almost the same functionality as the OcreCore library.

## Building and running on Zephyr

Expand Down Expand Up @@ -72,34 +74,92 @@ If it is not possible to flash the storage_partition with west, as a workaround,
it is possible to use the [Supervisor] with `ocre pull` to populate the images
directory, and then flash just this demo with the command above.

## Building and running on Linux

Make sure you are using the [Devcontainer](../Devcontainers.md) or have the necessary
tools for Linux described in the [Get Started with Linux](../GetStartedLinux.md) guide.

In Linux, the the supervisor is split in two parts:

- `ocred`, the ocre daemon which uses a control socket that listens in a socket.
- `ocre-cli`, the ocre command line which interacts with the daemon to manage the containers.

From the root of the repository, or from anywhere else, create build directory:

```sh
mkdir build
cd build
```

Configure the Ocre Library build:

```sh
cmake ..
```

Make sure `..` points to the root of the ocre-runtime source tree.

Build ocre and the samples:

```sh
make
```

Run the daemon:

```sh
./src/samples/supervisor/posix/server/ocred
```

Note that this command should be run from the build directory
(i.e. the directory that contains files in the relative path `./src/ocre/var/lib/ocre/images/`).

This will create the ocre socket by default in `/tmp/ocre.sock`.

On another terminal, run the client:

```sh
./src/samples/supervisor/posix/ocre_cli ps
```

Other commands, described in the next section work just fine.

Notice that the container logs are not redirected to the client. Check the ocre daemon logs for more information.

## Using ocre-cli (shell)

Quick usage of ocre client is described below. Detailed usage information can be found on the [Ocre CLI](../OcreCli.md) documentation.

Get help:

```
````

ocre

```

List local images:

```

ocre image ls

```

It should display the local images:

```
SHA-256 SIZE NAME
d9d2984172d74b157cbcd27ff53ce5b5e07c1b8f9aa06facd16a59f66ddd0afb 22772 blinky.wasm
fdeffaf2240bd6b3541fccbb5974c72f03cbf4bdd0970ea7e0a5647f08b7b50a 58601 filesystem-full.wasm
a8042be335fd733ecf4c48b76e6c00a43b274ad9b0d9a6d3c662c5f0c36d4a40 41545 filesystem.wasm
4a42158ff5b0a4d0a65d9cf8a3d2bb411d846434a236ca84b483e05b2f1dff99 5026 hello-world.wasm
c7b29c38bd91f67e69771fbe83db4ae84d515a6038a77ee6823ae377c55eac3c 23111 publisher.wasm
5f94ea4678c4c1ab42a3302e190ffe61c58b8db4fcf4919e1c5a576a1b8dcd3b 22944 subscriber.wasm
496ab513d6b1b586f846834fd8d17e0360c053bc614f2c2418ef84a87fbcd384 98082 webserver-complex.wasm
0a8cd55cb93c995d71500381c11bab1f2536c66282b8cab324b42c35817fba57 81647 webserver.wasm

SHA-256 SIZE NAME
d9d2984172d74b157cbcd27ff53ce5b5e07c1b8f9aa06facd16a59f66ddd0afb 22772 blinky.wasm
fdeffaf2240bd6b3541fccbb5974c72f03cbf4bdd0970ea7e0a5647f08b7b50a 58601 filesystem-full.wasm
a8042be335fd733ecf4c48b76e6c00a43b274ad9b0d9a6d3c662c5f0c36d4a40 41545 filesystem.wasm
4a42158ff5b0a4d0a65d9cf8a3d2bb411d846434a236ca84b483e05b2f1dff99 5026 hello-world.wasm
c7b29c38bd91f67e69771fbe83db4ae84d515a6038a77ee6823ae377c55eac3c 23111 publisher.wasm
5f94ea4678c4c1ab42a3302e190ffe61c58b8db4fcf4919e1c5a576a1b8dcd3b 22944 subscriber.wasm
496ab513d6b1b586f846834fd8d17e0360c053bc614f2c2418ef84a87fbcd384 98082 webserver-complex.wasm
0a8cd55cb93c995d71500381c11bab1f2536c66282b8cab324b42c35817fba57 81647 webserver.wasm

```

If there are no images, before you proceed, you can use `ocre pull` to populate the images.
Expand All @@ -108,32 +168,42 @@ Check the Ocre SDK and [Ocre CLI](../OcreCli.md) documentation for details.
Start a container with the the `hello-world.wasm` image:

```

ocre run hello-world.wasm

```

Start a background container named `my_blinky` with the `blinky.wasm` image:

```

ocre run -n my_blinky -d -k ocre:api blinky.wasm

```

Show container statuses:

```

ocre ps

```

Kill the `my_blinky` container:

```

ocre kill my_blinky

```

Remove the `my_blinky` container:

```

ocre rm my_blinky
```

````

Please, refer to [Ocre CLI](../OcreCli.md) documentation and help messages for details

Expand Down
8 changes: 7 additions & 1 deletion docs/tests/SystemTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ cd tests/system/posix/build

Configure and build the cmake project. Note that `..` points to `tests/system/posix`:

Alternatively, the IPC system tests can be build in the directory `tests/system/posix-ipc`. Note that only `test_context` and `test_container` are available in IPC mode.

```sh
cmake ..
make
Expand Down Expand Up @@ -68,6 +70,7 @@ Please, refer to their source code for more details.
## Zephyr

### Build and run

To build the Zephyr system tests for the `native_sim_64` board:

```sh
Expand All @@ -82,16 +85,19 @@ Replace `context` with `container`, `lib`, or `ocre` to build different tests:
- `tests/system/zephyr/container` - Tests the specific functionality of a container

To run the test:

```sh
west build -t run
```

The last lines of the output will be something like:

```
-----------------------
25 Tests 0 Failures 0 Ignored
25 Tests 0 Failures 0 Ignored
OK
```

### Details

Each test must be run individually. Run the build command for one test at a time, then execute `west build -t run` to run that specific test.
1 change: 1 addition & 0 deletions scripts/check_c_formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ find . -type f '(' -name '*.c' -o -name '*.h' ')' \
'(' -path './src/*' -o -path './tests/*' ')' \
! -name 'utlist.h' \
! -path './tests/Unity/*' \
! -path 'src/samples/supervisor/posix/zcbor/*' \
-print0 | \
xargs -0 -n1 clang-format ${ARGUMENT} -Werror
21 changes: 21 additions & 0 deletions src/samples/supervisor/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @copyright Copyright (c) contributors to Project Ocre,
# which has been established as Project Ocre a Series of LF Projects, LLC
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

add_subdirectory(server)

add_subdirectory(client)

add_executable(ocre_cli
ocre.c
download.c
)

target_link_libraries(ocre_cli
PRIVATE
OcreShell
OcreClient
)
32 changes: 32 additions & 0 deletions src/samples/supervisor/posix/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# @copyright Copyright (c) contributors to Project Ocre,
# which has been established as Project Ocre a Series of LF Projects, LLC
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

add_library(OcreClient)

target_sources(OcreClient
PRIVATE
client.c
context.c
../zcbor_helpers.c
../zcbor/src/zcbor_encode.c
../zcbor/src/zcbor_decode.c
../zcbor/src/zcbor_common.c
)

target_include_directories(OcreClient
PUBLIC
../../../../ocre/include
../../../../runtime/include
PRIVATE
../zcbor/include
..
)

target_link_libraries(OcreClient
PUBLIC
OcreCommon
)
Loading
Loading