Skip to content

Commit 1e65ae6

Browse files
committed
test: add unreachable.wasm, only passes on extism a91846a or later
1 parent 754e681 commit 1e65ae6

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Extism/host.wasm
2+
Extism/unreachable.wasm
23
Extism/MYMETA.json
34
Extism/MYMETA.yml
45
Extism/Makefile
@@ -17,3 +18,9 @@ examples/Extism-AudioDecoder/*.wav
1718
examples/Extism-AudioDecoder/*.pcm
1819
examples/Extism-AudioDecoder/.vscode
1920
examples/CountVowels/.vscode
21+
Alien-libextism/MYMETA.json
22+
Alien-libextism/MYMETA.yml
23+
Alien-libextism/Makefile
24+
Alien-libextism/_alien/
25+
Alien-libextism/blib/
26+
Alien-libextism/pm_to_blib

Extism/t/02-extism.t

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Extism ':all';
77
use JSON::PP qw(encode_json decode_json);
88
use File::Temp qw(tempfile);
99
use Devel::Peek qw(Dump);
10-
plan tests => 40;
10+
plan tests => 44;
1111

1212
# ...
1313
ok(Extism::version());
@@ -180,3 +180,18 @@ ok($decoded[1]{total} == 6);
180180
# Verify both sets of results are the same
181181
is($highlevel[0], $lowlevel[0]);
182182
is($highlevel[1], $lowlevel[1]);
183+
184+
# test unreachable plugin
185+
my $unreachable = encode_json({
186+
wasm => [
187+
{
188+
path => 'unreachable.wasm',
189+
}
190+
],
191+
});
192+
my $uplugin = Extism::Plugin->new($unreachable, {wasi => 1});
193+
ok($uplugin);
194+
my ($ures, $urc, $uinfo) = $uplugin->call('do_unreachable');
195+
ok(!defined $ures);
196+
ok($urc != 0);
197+
ok($uinfo);

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
.PHONY: all
2-
all: Extism Extism/host.wasm
2+
all: Extism Extism/host.wasm Extism/unreachable.wasm
33

44
Extism/host.wasm: host.c
55
$(WASI_SDK_PATH)/bin/clang -o $@ $^ -mexec-model=reactor
66

7+
Extism/unreachable.wasm: unreachable.cpp
8+
$(WASI_SDK_PATH)/bin/clang++ -fno-exceptions -o $@ $^ -mexec-model=reactor
9+
710
Extism/Makefile: Extism/Makefile.PL
811
cd Extism && perl Makefile.PL
912
.PHONY: Extism

unreachable.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// #define EXTISM_IMPLEMENTATION
2+
#include "extism-pdk.h"
3+
#include <stdexcept>
4+
#include <stdint.h>
5+
6+
int32_t EXTISM_EXPORTED_FUNCTION(do_unreachable)
7+
{
8+
std::terminate();
9+
return -1;
10+
}

0 commit comments

Comments
 (0)