Skip to content

Commit

Permalink
Add reproduction of #1217
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <[email protected]>
  • Loading branch information
NobodyXu committed Sep 30, 2024
1 parent e6a87a6 commit ae62d29
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,49 @@ jobs:
- run: cargo test --no-run --target ${{ matrix.target }} --release
- run: cargo test --no-run --target ${{ matrix.target }} --features parallel

test-wasm32-wasip1-thread:
name: Test wasm32-wasip1-thread
runs-on: ubuntu-latest
env:
TARGET: wasm32-wasip1-threads
steps:
- uses: actions/checkout@v4
- name: Install Rust (rustup)
run: |
rustup toolchain install nightly --no-self-update --profile minimal --target $TARGET
- name: Get latest version of wasi-sdk
env:
REPO: WebAssembly/wasi-sdk
GH_TOKEN: ${{ github.token }}
run: |
set -euxo pipefail
VERSION="$(gh release list --repo $REPO -L 1 --json tagName --jq '.[]|.tagName')"
echo "WASI_TOOLCHAIN_VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Install wasi-sdk
working-directory: /tmp
env:
REPO: WebAssembly/wasi-sdk
run: |
set -euxo pipefail
VERSION="$WASI_TOOLCHAIN_VERSION"
FILE="${VERSION}.0-x86_64-linux.deb"
wget "https://github.com/$REPO/releases/download/${VERSION}/${FILE}"
sudo dpkg -i "${FILE}"
WASI_SDK_PATH="/opt/wasi-sdk"
CC="${WASI_SDK_PATH}/bin/clang"
echo "WASI_SDK_PATH=$WASI_SDK_PATH" >> "$GITHUB_ENV"
echo "CC=$CC" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@v2
with:
env-vars: "WASI_TOOLCHAIN_VERSION"
cache-all-crates: "true"

- name: Run tests
run: cargo +nightly build -p $TARGET-test --target $TARGET

cuda:
name: Test CUDA support
runs-on: ubuntu-20.04
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ members = [
"dev-tools/cc-test",
"dev-tools/gen-target-info",
"dev-tools/gen-windows-sys-binding",
"dev-tools/wasm32-wasip1-threads-test",
]

[patch.crates-io]
cc = { path = "." }
8 changes: 8 additions & 0 deletions dev-tools/wasm32-wasip1-threads-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "wasm32-wasip1-threads-test"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
rusqlite = { version = "0.32.0", features = ["bundled"] }
44 changes: 44 additions & 0 deletions dev-tools/wasm32-wasip1-threads-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use rusqlite::{Connection, Result};

#[derive(Debug)]
pub struct Person {
pub id: i32,
pub name: String,
pub data: Option<Vec<u8>>,
}

pub fn f() -> Result<()> {
let conn = Connection::open_in_memory()?;

conn.execute(
"CREATE TABLE person (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
data BLOB
)",
(), // empty list of parameters.
)?;
let me = Person {
id: 0,
name: "Steven".to_string(),
data: None,
};
conn.execute(
"INSERT INTO person (name, data) VALUES (?1, ?2)",
(&me.name, &me.data),
)?;

let mut stmt = conn.prepare("SELECT id, name, data FROM person")?;
let person_iter = stmt.query_map([], |row| {
Ok(Person {
id: row.get(0)?,
name: row.get(1)?,
data: row.get(2)?,
})
})?;

for person in person_iter {
println!("Found person {:?}", person.unwrap());
}
Ok(())
}

0 comments on commit ae62d29

Please sign in to comment.