Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Add simple test #42

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ jobs:
- name: build examples on WASI
run: |
export PATH="$HOME/.cargo/bin:$PATH"
cargo build --examples
cargo build --examples
- name: install WasmEdge
run: |
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash
- name: run unit tests
run: |
source /home/runner/.wasmedge/env
cargo test
31 changes: 31 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,34 @@ impl UdpSocket {
Ok(sent)
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_dns_query() {
let node = String::from("www.rust-lang");
let service = String::from("http");
let hints: WasiAddrinfo = WasiAddrinfo::default();
let mut sockaddr = Vec::new();
let mut sockbuff = Vec::new();
let mut ai_canonname = Vec::new();
let addrinfo = WasiAddrinfo::get_addrinfo(
&node,
&service,
&hints,
10,
&mut sockaddr,
&mut sockbuff,
&mut ai_canonname,
)
.unwrap();
assert!(addrinfo.len() > 0);
}

#[test]
fn test_tcp_listen() {
let _ = TcpListener::bind("127.0.0.1:52222", true).unwrap();
}
}