Skip to content

Commit

Permalink
[Test] Add simple test
Browse files Browse the repository at this point in the history
Signed-off-by: KernelErr <[email protected]>
  • Loading branch information
KernelErr committed Feb 18, 2022
1 parent 7358ee1 commit f65b789
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
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();
}
}

0 comments on commit f65b789

Please sign in to comment.