Skip to content

Commit 6a509fc

Browse files
authored
Add symbol to do general host interface tests (#115)
* libfaasm: add faasm_hsot_interface_test * func: add demo func to throw exception from handler * gh: bump version for new libfaasm * nit: run clang format
1 parent 8002016 commit 6a509fc

File tree

9 files changed

+39
-4
lines changed

9 files changed

+39
-4
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SYSROOT_VERSION=0.2.5
2-
SYSROOT_CLI_IMAGE=faasm.azurecr.io/cpp-sysroot:0.2.5
1+
SYSROOT_VERSION=0.2.6
2+
SYSROOT_CLI_IMAGE=faasm.azurecr.io/cpp-sysroot:0.2.6
33
COMPOSE_PROJECT_NAME=cpp-dev

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
if: github.event.pull_request.draft == false
2020
runs-on: ubuntu-latest
2121
container:
22-
image: faasm.azurecr.io/cpp-sysroot:0.2.5
22+
image: faasm.azurecr.io/cpp-sysroot:0.2.6
2323
credentials:
2424
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
2525
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.5
1+
0.2.6

func/demo/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ demo_func(cpp_example cpp_example.cpp)
2828
#demo_func(curl_net curl_net.cpp)
2929
demo_func(dummy dummy.cpp)
3030
demo_func(echo echo.cpp)
31+
demo_func(exception exception.cpp)
3132
demo_func(exit exit.cpp)
3233
demo_func(fcntl fcntl.cpp)
3334
demo_func(fibonacci fibonacci.cpp)

func/demo/exception.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extern "C"
2+
{
3+
#include "faasm/host_interface.h"
4+
#include "faasm/host_interface_test.h"
5+
}
6+
7+
#include <stdlib.h>
8+
9+
// This function tests that exceptions can be propagated from host interface
10+
// calls to the Faasm runtime
11+
int main(int argc, char* argv[])
12+
{
13+
__faasm_host_interface_test(HostInterfaceTest::ExceptionPropagationTest);
14+
}

libfaasm/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD 17)
88
set(PUBLIC_HEADERS
99
faasm/core.h
1010
faasm/host_interface.h
11+
faasm/host_interface_test.h
1112
faasm/array.h
1213
faasm/compare.h
1314
faasm/faasm.h

libfaasm/faasm.imports

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ __faasm_sm_critical_local_end
4242
# Migration
4343
__faasm_migrate_point
4444

45+
# Test
46+
__faasm_host_interface_test

libfaasm/faasm/host_interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,7 @@ void __faasm_sm_critical_local_end();
157157

158158
HOST_IFACE_FUNC
159159
void __faasm_migrate_point(FaasmMigrateEntryPoint f, int arg);
160+
161+
HOST_IFACE_FUNC
162+
void __faasm_host_interface_test(int testNum);
160163
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
/* We use one host interface call, `__faasm_host_interface_test` to test
4+
* different behaviours of host interface calls like, for example, throwing
5+
* an exception and testing that it propagates correctly through the WASM
6+
* runtime all the way to Faasm. With this enum we indicate the test number.
7+
* Note that this header file needs to be duplicated in Faasm in:
8+
* faasm/include/wasm/host_interface_test.h
9+
*/
10+
enum HostInterfaceTest
11+
{
12+
NoTest = 0,
13+
ExceptionPropagationTest = 1,
14+
};

0 commit comments

Comments
 (0)