Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2c0ccc3

Browse files
committedAug 9, 2018
Run wasm tests like all other tests
1 parent 0bd5460 commit 2c0ccc3

File tree

13 files changed

+800
-732
lines changed

13 files changed

+800
-732
lines changed
 

‎.travis.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,6 @@ matrix:
3030
env: TARGET=x86_64-apple-darwin NO_ADD=1
3131
script: ci/run.sh
3232
- env: TARGET=wasm32-unknown-unknown
33-
before_script:
34-
- git clone --recursive https://github.com/WebAssembly/wabt
35-
- (cd wabt && git reset --hard a0bdeb7 && make -j4)
36-
- export PATH=$PATH:$PWD/wabt/bin
37-
- git clone https://github.com/rustwasm/wasm-bindgen
38-
- (cd wasm-bindgen && cargo install --path crates/cli)
39-
script:
40-
- cargo build --target wasm32-unknown-unknown -p stdsimd
41-
- cargo build --target wasm32-unknown-unknown -p stdsimd --release
42-
- cargo rustc --target wasm32-unknown-unknown -p stdsimd --release --example wasm -- -C lto
43-
- wasm2wat target/wasm32-unknown-unknown/release/examples/wasm.wasm -o wasm.wat
44-
- cat wasm.wat
45-
- grep current_memory wasm.wat
46-
- grep grow_memory wasm.wat
47-
- cd crates/wasm-test
48-
- cargo test --target=$TARGET
49-
- cargo test --target=$TARGET --release
5033
- env: TARGET=thumbv6m-none-eabi NOSTD=1
5134
- env: TARGET=thumbv7m-none-eabi NOSTD=1
5235
- env: TARGET=thumbv7em-none-eabi NOSTD=1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM ubuntu:18.04
2+
3+
RUN apt-get update -y && apt-get install -y --no-install-recommends \
4+
ca-certificates \
5+
clang \
6+
cmake \
7+
curl \
8+
git \
9+
libc6-dev \
10+
make \
11+
python \
12+
xz-utils
13+
14+
# Install `wasm2wat`
15+
RUN git clone --recursive https://github.com/WebAssembly/wabt
16+
RUN make -C wabt -j$(nproc)
17+
ENV PATH=$PATH:/wabt/bin
18+
19+
# Install `wasm-bindgen-test-runner`
20+
RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.15/wasm-bindgen-0.2.15-x86_64-unknown-linux-musl.tar.gz \
21+
| tar xzf -
22+
ENV PATH=$PATH:/wasm-bindgen-0.2.15-x86_64-unknown-linux-musl
23+
ENV CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner
24+
25+
# Install `node`
26+
RUN curl https://nodejs.org/dist/v10.8.0/node-v10.8.0-linux-x64.tar.xz | tar xJf -
27+
ENV PATH=$PATH:/node-v10.8.0-linux-x64/bin

‎ci/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ case ${TARGET} in
3939
*android*)
4040
export STDSIMD_DISABLE_ASSERT_INSTR=1
4141
;;
42+
wasm32*)
43+
# export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+simd128"
44+
;;
45+
4246
*)
4347
;;
4448
esac

‎coresimd/wasm32/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! WASM32 intrinsics
22
33
#[macro_use]
4+
#[cfg(not(test))]
45
mod simd128;
6+
#[cfg(test)]
7+
pub mod simd128;
58
pub use self::simd128::*;
69

710
extern "C" {

‎coresimd/wasm32/simd128.rs

Lines changed: 727 additions & 78 deletions
Large diffs are not rendered by default.

‎crates/coresimd/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ maintenance = { status = "experimental" }
2222
stdsimd-test = { version = "0.*", path = "../stdsimd-test" }
2323
stdsimd = { version = "0.0.3", path = "../stdsimd" }
2424

25+
[target.wasm32-unknown-unknown.dev-dependencies]
26+
wasm-bindgen-test = "=0.2.15"
27+
2528
[features]
2629
# Internal-usage only: denies all warnings.
2730
strict = []

‎crates/coresimd/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ extern crate stdsimd_test;
8484
#[cfg(test)]
8585
extern crate test;
8686

87+
#[cfg(all(test, target_arch = "wasm32"))]
88+
extern crate wasm_bindgen_test;
89+
8790
#[path = "../../../coresimd/mod.rs"]
8891
mod coresimd;
8992

‎crates/stdsimd-test/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ fn parse_objdump(output: &str) -> HashMap<String, Vec<Function>> {
137137
.skip_while(|s| {
138138
s.len() == expected_len
139139
&& usize::from_str_radix(s, 16).is_ok()
140-
})
141-
.map(|s| s.to_string())
140+
}).map(|s| s.to_string())
142141
.collect::<Vec<String>>();
143142
instructions.push(Instruction { parts });
144143
}
@@ -232,8 +231,7 @@ fn parse_dumpbin(output: &str) -> HashMap<String, Vec<Function>> {
232231
.skip(1)
233232
.skip_while(|s| {
234233
s.len() == 2 && usize::from_str_radix(s, 16).is_ok()
235-
})
236-
.map(|s| s.to_string())
234+
}).map(|s| s.to_string())
237235
.collect::<Vec<String>>();
238236
instructions.push(Instruction { parts });
239237
}

‎crates/stdsimd-verify/src/lib.rs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ pub fn x86_functions(input: TokenStream) -> TokenStream {
8383
required_const: &[#(#required_const),*],
8484
}
8585
}
86-
})
87-
.collect::<Vec<_>>();
86+
}).collect::<Vec<_>>();
8887

8988
let ret = quote! { #input: &[Function] = &[#(#functions),*]; };
9089
// println!("{}", ret);
@@ -93,28 +92,30 @@ pub fn x86_functions(input: TokenStream) -> TokenStream {
9392

9493
fn to_type(t: &syn::Type) -> proc_macro2::TokenStream {
9594
match *t {
96-
syn::Type::Path(ref p) => match extract_path_ident(&p.path).to_string().as_ref() {
97-
"__m128" => quote! { &M128 },
98-
"__m128d" => quote! { &M128D },
99-
"__m128i" => quote! { &M128I },
100-
"__m256" => quote! { &M256 },
101-
"__m256d" => quote! { &M256D },
102-
"__m256i" => quote! { &M256I },
103-
"__m64" => quote! { &M64 },
104-
"bool" => quote! { &BOOL },
105-
"f32" => quote! { &F32 },
106-
"f64" => quote! { &F64 },
107-
"i16" => quote! { &I16 },
108-
"i32" => quote! { &I32 },
109-
"i64" => quote! { &I64 },
110-
"i8" => quote! { &I8 },
111-
"u16" => quote! { &U16 },
112-
"u32" => quote! { &U32 },
113-
"u64" => quote! { &U64 },
114-
"u8" => quote! { &U8 },
115-
"CpuidResult" => quote! { &CPUID },
116-
s => panic!("unspported type: {}", s),
117-
},
95+
syn::Type::Path(ref p) => {
96+
match extract_path_ident(&p.path).to_string().as_ref() {
97+
"__m128" => quote! { &M128 },
98+
"__m128d" => quote! { &M128D },
99+
"__m128i" => quote! { &M128I },
100+
"__m256" => quote! { &M256 },
101+
"__m256d" => quote! { &M256D },
102+
"__m256i" => quote! { &M256I },
103+
"__m64" => quote! { &M64 },
104+
"bool" => quote! { &BOOL },
105+
"f32" => quote! { &F32 },
106+
"f64" => quote! { &F64 },
107+
"i16" => quote! { &I16 },
108+
"i32" => quote! { &I32 },
109+
"i64" => quote! { &I64 },
110+
"i8" => quote! { &I8 },
111+
"u16" => quote! { &U16 },
112+
"u32" => quote! { &U32 },
113+
"u64" => quote! { &U64 },
114+
"u8" => quote! { &U8 },
115+
"CpuidResult" => quote! { &CPUID },
116+
s => panic!("unspported type: {}", s),
117+
}
118+
}
118119
syn::Type::Ptr(syn::TypePtr { ref elem, .. })
119120
| syn::Type::Reference(syn::TypeReference { ref elem, .. }) => {
120121
let tokens = to_type(&elem);
@@ -183,8 +184,7 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<syn::Ident> {
183184
}
184185
}
185186
_ => None,
186-
})
187-
.filter_map(|nested| match nested {
187+
}).filter_map(|nested| match nested {
188188
syn::NestedMeta::Meta(syn::Meta::List(i)) => {
189189
if i.ident == "assert_instr" {
190190
i.nested.into_iter().next()
@@ -193,12 +193,10 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<syn::Ident> {
193193
}
194194
}
195195
_ => None,
196-
})
197-
.filter_map(|nested| match nested {
196+
}).filter_map(|nested| match nested {
198197
syn::NestedMeta::Meta(syn::Meta::Word(i)) => Some(i),
199198
_ => None,
200-
})
201-
.collect()
199+
}).collect()
202200
}
203201

204202
fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
@@ -214,13 +212,11 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
214212
}
215213
}
216214
_ => None,
217-
})
218-
.flat_map(|list| list)
215+
}).flat_map(|list| list)
219216
.filter_map(|nested| match nested {
220217
syn::NestedMeta::Meta(m) => Some(m),
221218
syn::NestedMeta::Literal(_) => None,
222-
})
223-
.filter_map(|m| match m {
219+
}).filter_map(|m| match m {
224220
syn::Meta::NameValue(i) => {
225221
if i.ident == "enable" {
226222
Some(i.lit)
@@ -229,8 +225,7 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
229225
}
230226
}
231227
_ => None,
232-
})
233-
.next()
228+
}).next()
234229
}
235230

236231
fn find_required_const(attrs: &[syn::Attribute]) -> Vec<usize> {

‎crates/wasm-test/.cargo/config

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎crates/wasm-test/Cargo.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎crates/wasm-test/src/lib.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎crates/wasm-test/tests/simd128.rs

Lines changed: 0 additions & 583 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.