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

Fix wdk sys ci tests #23

Merged
merged 3 commits into from
Mar 1, 2024
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
5 changes: 2 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ jobs:
with:
tool: cargo-expand

# FIXME: wdk-sys layout tests fail, but only on github hosted runner
- name: Run Cargo Test
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-sys
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }}

- name: Run Cargo Test (--features nightly)
if: matrix.rust_toolchain == 'nightly'
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-sys --features nightly
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --features nightly
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ To maintain the quality of code, tests and tools are required to pass before con

**_Functional Correctness:_**

* `cargo test --locked --workspace --exclude sample-*`
* To test `nightly` features: `cargo +nightly test --locked --workspace --exclude sample-* --features nightly`
* `cargo test --locked`
* To test `nightly` features: `cargo +nightly test --locked --features nightly`

**_Static Analysis and Linting:_**

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The crates in this repository are available from [`crates.io`](https://crates.io

```rust
fn main() -> Result<(), wdk_build::ConfigError> {
wdk_build::Config::from_env_auto()?.configure_binary_build();
wdk_build::Config::from_env_auto()?.configure_binary_build()?;
Ok(())
}
```
Expand Down
2 changes: 1 addition & 1 deletion crates/sample-kmdf-driver/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// License: MIT OR Apache-2.0

fn main() -> Result<(), wdk_build::ConfigError> {
wdk_build::Config::from_env_auto()?.configure_binary_build();
wdk_build::Config::from_env_auto()?.configure_binary_build()?;
Ok(())
}
2 changes: 1 addition & 1 deletion crates/wdk-build/src/cargo_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ fn configure_wdf_build_output_dir(target_arg: &Option<String>, cargo_make_cargo_
output_dir += "/debug";
} else {
output_dir += "/";
output_dir += &cargo_make_cargo_profile;
output_dir += cargo_make_cargo_profile;
}

output_dir
Expand Down
6 changes: 5 additions & 1 deletion crates/wdk-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ impl Config {
///
/// This consists mainly of linker setting configuration. This must be
/// called from a Cargo build script of the binary being built
pub fn configure_binary_build(&self) {
pub fn configure_binary_build(&self) -> Result<(), ConfigError> {
self.configure_library_build()?;

// Linker arguments derived from Microsoft.Link.Common.props in Ni(22H2) WDK
println!("cargo:rustc-cdylib-link-arg=/NXCOMPAT");
println!("cargo:rustc-cdylib-link-arg=/DYNAMICBASE");
Expand Down Expand Up @@ -609,6 +611,8 @@ impl Config {
println!("cargo:rustc-cdylib-link-arg=/SUBSYSTEM:WINDOWS");
}
}

Ok(())
}

/// Serializes this [`Config`] and exports it via the Cargo
Expand Down
1 change: 0 additions & 1 deletion crates/wdk-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,5 @@ fn main() -> anyhow::Result<()> {
generate_wdf(&out_path, config.clone())?;
}

config.configure_library_build()?;
Ok(config.export_config()?)
}
7 changes: 7 additions & 0 deletions crates/wdk-sys/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
use crate::types::{NTSTATUS, POOL_FLAGS, PVOID, PWDF_OBJECT_ATTRIBUTES};

#[allow(non_upper_case_globals)]
#[rustversion::attr(
any(
all(not(nightly), since(1.79)),
all(nightly, since(2024-02-09)),
),
allow(clippy::manual_c_str_literals)
)]
#[allow(clippy::unreadable_literal)]
mod bindings {
// allow wildcards for types module since underlying c code relies on all
Expand Down
12 changes: 11 additions & 1 deletion crates/wdk-sys/src/test_stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! into scope by introducing `wdk-sys` with the `test-stubs` feature in the
//! `dev-dependencies` of the crate's `Cargo.toml`

use crate::{DRIVER_OBJECT, NTSTATUS, PCUNICODE_STRING};
use crate::{DRIVER_OBJECT, NTSTATUS, PCUNICODE_STRING, ULONG, WDFFUNC};

/// Stubbed version of `DriverEntry` Symbol so that test targets will compile
///
Expand All @@ -20,3 +20,13 @@ pub unsafe extern "system" fn driver_entry_stub(
) -> NTSTATUS {
0
}

/// Stubbed version of `WdfFunctions_01033` Symbol so that test targets will
/// compile
#[no_mangle]
pub static mut WdfFunctions_01033: *const WDFFUNC = core::ptr::null();

/// Stubbed version of `WdfFunctionCount` Symbol so that test targets will
/// compile
#[no_mangle]
pub static mut WdfFunctionCount: ULONG = 0;
7 changes: 7 additions & 0 deletions crates/wdk-sys/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
),
allow(clippy::pub_underscore_fields)
)]
#[rustversion::attr(
any(
all(not(nightly), since(1.79)),
all(nightly, since(2024-02-09)),
),
allow(clippy::ref_as_ptr)
)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::too_many_arguments)]
#[allow(clippy::too_many_lines)]
Expand Down
Loading