Skip to content

Commit

Permalink
move tests to bind9 crate
Browse files Browse the repository at this point in the history
  • Loading branch information
balliegojr committed Jan 11, 2025
1 parent 88630b0 commit 464975b
Show file tree
Hide file tree
Showing 43 changed files with 478 additions and 495 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Clippy
run: cargo clippy --all-features -- -D warnings
run: cargo clippy --workspace --exclude bind9-tests --all-features -- -D warnings

test-dev:
name: Test Dev on ${{ matrix.os }}
Expand All @@ -28,9 +28,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --workspace --exclude simple-dns-fuzz --verbose --all-features
run: cargo build --workspace --exclude simple-dns-fuzz --exclude bind9-tests --verbose --all-features
- name: Run tests
run: cargo test --workspace --exclude simple-dns-fuzz --verbose --all-features
run: cargo test --workspace --exclude simple-dns-fuzz --exclude bind9-tests --verbose --all-features

test-release:
name: Test Release on ${{ matrix.os }}
Expand All @@ -42,9 +42,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --workspace --exclude simple-dns-fuzz --verbose --release --all-features
run: cargo build --workspace --exclude simple-dns-fuzz --exclude bind9-tests --verbose --release --all-features
- name: Run tests
run: cargo test --workspace --exclude simple-dns-fuzz --verbose --release --all-features
run: cargo test --workspace --exclude simple-dns-fuzz --exclude bind9-tests --verbose --release --all-features

fuzzing:
name: Fuzz
Expand All @@ -63,3 +63,17 @@ jobs:
run: |
cd simple-dns
cargo fuzz run packet_parse -- -max_total_time=300
text-bind-check:
name: Test Bind9 check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install bind9
run: sudo apt-get install bind9-dev
- name: Build
run: cargo build --verbose --all-features
- name: Run tests
run: |
cd simple-dns/bind9-tests
cargo test --verbose
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
resolver = "2"

members = ["simple-dns", "simple-mdns", "simple-dns/fuzz", "bind9-sys"]
members = ["simple-dns", "simple-mdns", "simple-dns/fuzz", "bind9-tests"]

10 changes: 0 additions & 10 deletions bind9-sys/Cargo.toml

This file was deleted.

9 changes: 0 additions & 9 deletions bind9-sys/src/dummy.rs

This file was deleted.

9 changes: 0 additions & 9 deletions bind9-sys/src/lib.rs

This file was deleted.

12 changes: 12 additions & 0 deletions bind9-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "bind9-tests"
version = "0.1.0"
edition = "2021"
publish = false

[build-dependencies]
bindgen = "0.70.1"

[dependencies]
simple-dns = { path = "../simple-dns" }
base64 = "0.22.1"
12 changes: 4 additions & 8 deletions bind9-sys/build.rs → bind9-tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ use std::path::{Path, PathBuf};
fn main() {
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs");

if cfg!(feature = "bind9-check") {
println!("cargo:rustc-link-lib=dns");
println!("cargo:rustc-link-lib=isc");
println!("cargo:rustc-link-lib=atomic");
println!("cargo:rustc-link-lib=dns");
println!("cargo:rustc-link-lib=isc");
println!("cargo:rustc-link-lib=atomic");

generate_bindings(&out_path);
} else {
std::fs::File::create(&out_path).expect("Failed to create bindings.rs");
}
generate_bindings(&out_path);
}

fn generate_bindings(out_path: &Path) {
Expand Down
4 changes: 4 additions & 0 deletions bind9-sys/src/bind9.rs → bind9-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(clippy::all)]

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

Expand Down Expand Up @@ -108,6 +109,9 @@ unsafe fn buffer_init(buffer: &mut [u8]) -> isc_buffer_t {
b
}

#[cfg(test)]
mod rr_tests;

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

0 comments on commit 464975b

Please sign in to comment.