@@ -9,3 +9,58 @@ The following command can be used to generate the `compile_commands.json` file:
99```
1010BAZEL_BUILD_OPTION_LIST="--define=engine=multi" ./tools/gen_compilation_database.py --include_all //test/... //:lib
1111```
12+
13+ ## Testing s390x locally
14+
15+ The s390x build-tools image used in our CI environment does not contain all the tools necessary to build test wasm modules. First, build those wasm modules in your native environment:
16+
17+ ``` bash
18+ bazel build --verbose_failures --test_output=errors --config=clang --config=hermetic-llvm -c opt $( bazel query ' kind(was.*_rust_binary, //test/test_data/...)' ) $( bazel query ' kind(_optimized_wasm_cc_binary, //test/test_data/...)' )
19+
20+ # Copy the built artifacts to the test_data dir.
21+ cp bazel-bin/test/test_data/* .wasm test/test_data/
22+
23+ # Rewrite test/test_data/BUILD to use the pre-built wasm module artifacts
24+ echo " package(default_visibility = [\" //visibility:public\" ])" > test/test_data/BUILD
25+ for i in $( cd test/test_data && ls -1 * .wasm | sed ' s/\.wasm$//g' ) ; do \
26+ echo " filegroup(name = \" $i \" , srcs = [\" $i .wasm\" ])" >> test/test_data/BUILD; \
27+ done
28+ # Rewrite test/BUILD to use the pre-built artifacts
29+ sed ' s/\.wasm//g' test/BUILD > test/BUILD.tmp && mv test/BUILD.tmp test/BUILD
30+ ```
31+
32+ s390x tests can be run locally using the build-tools docker images published in
33+ this repo. An s390x QEMU emulator is required to be installed ([ example
34+ instructions] ( https://docs.gitlab.com/omnibus/development/s390x/#vm-provisioning ) ).
35+ The following command will start an interactive session in an emulated s390x
36+ environment with bazel installed. The command mounts $HOME inside the container
37+ and assumes proxy-wasm-cpp-host is somewhere under $HOME.
38+
39+ ``` bash
40+ docker run --env HOME=$HOME --env USER=$( id -un) --volume " $HOME :$HOME " --workdir $( pwd) --user $( id -u) :$( id -g) --platform linux/s390x --interactive -t --env PS1=" docker (s390x):" ghcr.io/proxy-wasm/build-tools:ubuntu-24.04-bazel-7.7.1 bash
41+
42+ # Set a useful prompt to remind yourself this shell is in s390x:
43+ export PS1=' docker@s390x:\[\033[01;34m\]\w\[\033[00m\] )> '
44+ ```
45+
46+ Inside this shell, you may now call out to bazel to run any build or test
47+ command using the s390x environment. Note that ` --config=hermetic-llvm ` is not
48+ supported for s390x.
49+
50+ ``` bash
51+ bazel test --verbose_failures --test_output=errors --define engine=wasmtime --config=clang --test_timeout=1800 //test:runtime_test --test_filter=\* PassingValue\*
52+ ```
53+
54+
55+ ### Troubleshooting
56+
57+ If you experience errors relating to GCC_DUMMY_TOOLCHAIN, re-check that your
58+ test/test_data/BUILD file contains only ` filegroup() ` rules pointing at
59+ pre-build wasm modules.
60+
61+ If you get a "Required file not available" error message when executing a
62+ toolchain with your host architecture in the file path, it is likely due to
63+ bazel re-using a cache from your host environment. Please run `bazel clean
64+ --expunge` and ` bazel shutdown` in the docker container to clear bazel's cache
65+ analysis cache.
66+
0 commit comments