Skip to content

Commit

Permalink
Merge #1763
Browse files Browse the repository at this point in the history
1763: Test C API with the native engine as well. r=nlewycky a=nlewycky

Fixes #1726 .

Co-authored-by: Nick Lewycky <[email protected]>
  • Loading branch information
bors[bot] and nlewycky authored Oct 26, 2020
2 parents c6978ea + 2eafde2 commit e6394e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:
- name: Build and Test C API
run: |
make build-capi
make test-capi-cranelift
make test-capi
if: matrix.os != 'windows-latest'
- name: Build C API on Windows
run: make build-capi
Expand Down
40 changes: 30 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,32 @@ build-docs-capi:
cd lib/c-api/ && doxygen doxyfile

# We use cranelift as the default backend for the capi for now
build-capi: build-capi-cranelift
build-capi: build-capi-cranelift-jit

build-capi-singlepass:
build-capi-singlepass-jit:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,jit,object-file,singlepass,wasi

build-capi-cranelift:
build-capi-cranelift-jit:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,jit,object-file,cranelift,wasi

build-capi-cranelift-native:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,native,object-file,cranelift,wasi

build-capi-cranelift-system-libffi:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,jit,object-file,cranelift,wasi,system-libffi
--no-default-features --features wat,jit,native,object-file,cranelift,wasi,system-libffi

build-capi-llvm:
build-capi-llvm-jit:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,jit,object-file,llvm,wasi

build-capi-llvm-native:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,native,object-file,llvm,wasi

###########
# Testing #
###########
Expand Down Expand Up @@ -149,23 +157,35 @@ test-packages:
cargo test -p wasmer-engine-native --release --no-default-features
cargo test -p wasmer-cli --release

test-capi-singlepass: build-capi-singlepass
# The test-capi rules depend on the build-capi rules to build the .a files to
# link the tests against. cargo test doesn't know that the tests will be running
# cmake + make to build programs whose dependencies cargo isn't aware of.

test-capi-singlepass-jit: build-capi-singlepass-jit
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,jit,singlepass,wasi -- --nocapture

test-capi-cranelift: build-capi-cranelift
test-capi-cranelift-jit: build-capi-cranelift-jit
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,jit,cranelift,wasi -- --nocapture

test-capi-cranelift-system-libffi: build-capi-cranelift-system-libffi
test-capi-cranelift-native: build-capi-cranelift-native
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,native,cranelift,wasi -- --nocapture

test-capi-cranelift-jit-system-libffi:
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,jit,cranelift,wasi,system-libffi -- --nocapture

test-capi-llvm: build-capi-llvm
test-capi-llvm-jit:
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,jit,llvm,wasi -- --nocapture

test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm
test-capi-llvm-native:
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,native,llvm,wasi -- --nocapture

test-capi: $(foreach compiler_engine,$(test_compilers_engines),test-capi-$(compiler_engine)) $(if $(findstring cranelift-jit,$(test_compilers_engines)),test-capi-cranelift-jit-system-libffi)

test-wasi-unit:
cargo test --manifest-path lib/wasi/Cargo.toml --release
Expand Down
12 changes: 0 additions & 12 deletions lib/c-api/tests/deprecated/test-module-serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ int main()
printf("Serialized module pointer: %p\n", serialized_module_bytes.bytes);
printf("Serialized module length: %d\n", serialized_module_bytes.bytes_len);
assert(serialized_module_bytes.bytes != NULL);
assert(serialized_module_bytes.bytes_len > 11);
assert(serialized_module_bytes.bytes[0] == '\0');
assert(serialized_module_bytes.bytes[1] == 'w');
assert(serialized_module_bytes.bytes[2] == 'a');
assert(serialized_module_bytes.bytes[3] == 's');
assert(serialized_module_bytes.bytes[4] == 'm');
assert(serialized_module_bytes.bytes[5] == 'e');
assert(serialized_module_bytes.bytes[6] == 'r');
assert(serialized_module_bytes.bytes[7] == '-');
assert(serialized_module_bytes.bytes[8] == 'j');
assert(serialized_module_bytes.bytes[9] == 'i');
assert(serialized_module_bytes.bytes[10] == 't');

wasmer_module_t *module_two = NULL;
wasmer_result_t unserialize_result = wasmer_module_deserialize(&module_two, serialized_module);
Expand Down

0 comments on commit e6394e8

Please sign in to comment.