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

Github Actions for Windows CI #117

Merged
merged 8 commits into from
Aug 28, 2020
Merged
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
49 changes: 49 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Rust

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always
LIB: 'c:\winpcap-dp\WpdPack\Lib\x64'

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Install WinPcap 4.1.3
run: cinst -y winpcap --version 4.1.3.20161116
- name: Install WinPcap 4.1.2 Developer's Pack
shell: bash
run: |
mkdir /c/winpcap-dp
pushd /c/winpcap-dp
curl -O https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip
7z x WpdPack_4_1_2.zip -o.
ls -l WpdPack/Lib/x64
# echo "::set-env LIB=$LIB:/c/winpcap-dp/WpdPack/Lib/x64"
popd
- name: Build and Test (default)
run: |
cargo build --verbose
cargo test --verbose
cargo clean
- name: Build and Test (tokio)
run: |
cargo build --verbose --features tokio
cargo test --verbose --features tokio
cargo clean
sekineh marked this conversation as resolved.
Show resolved Hide resolved
- name: Build and Test (full)
run: |
cargo build --verbose --features full
cargo test --verbose --features full
cargo clean
- name: Clean up
shell: bash
run: rm -r /c/winpcap-dp
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ See examples for usage.

Install [WinPcap](http://www.winpcap.org/install/default.htm).

Place wpcap.dll in your `C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\` directory on 64 bit
or `C:\Rust\bin\rustlib\i686-pc-windows-gnu\lib\` on 32 bit.
Download the WinPcap [Developer's Pack](https://www.winpcap.org/devel.htm).
Add the `/Lib` or `/Lib/x64` folder to your `LIB` environment variable.

## Linux

Expand Down
18 changes: 14 additions & 4 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ use tempdir::TempDir;

use pcap::{Active, Activated, Offline, Capture, Packet, PacketHeader, Linktype, Precision, Error};

#[cfg(not(windows))]
type time_t = libc::time_t;
#[cfg(windows)]
type time_t = libc::c_long;

#[cfg(not(windows))]
type suseconds_t = libc::suseconds_t;
#[cfg(windows)]
type suseconds_t = libc::c_long;

#[test]
fn read_packet_with_full_data() {
let mut capture = capture_from_test_file("packet_snaplen_65535.pcap");
Expand Down Expand Up @@ -61,8 +71,8 @@ impl Packets {
}

pub fn push(&mut self,
tv_sec: libc::time_t,
tv_usec: libc::suseconds_t,
tv_sec: time_t,
tv_usec: suseconds_t,
caplen: u32,
len: u32,
data: &[u8]) {
Expand Down Expand Up @@ -163,8 +173,8 @@ fn test_raw_fd_api() {
let data: Vec<u8> = (0..191).cycle().take(N_PACKETS * 1024).collect();
let mut packets = Packets::new();
for i in 0..N_PACKETS {
packets.push(1460408319 + i as libc::time_t,
1000 + i as libc::suseconds_t,
packets.push(1460408319 + i as time_t,
1000 + i as suseconds_t,
1024,
1024,
&data[i * 1024..(i + 1) * 1024]);
Expand Down