From 9a87d36eb3f3da8bfdd7fa0375a7b90db4c678a0 Mon Sep 17 00:00:00 2001 From: Shravan Vasista Date: Thu, 11 Jun 2026 15:48:48 +0530 Subject: [PATCH 1/7] fix: update WDK build number range and add test for missing sample flag in InfVerif --- .../src/actions/build/package_task.rs | 8 +-- crates/cargo-wdk/src/actions/build/tests.rs | 58 ++++++++++++++++++- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/crates/cargo-wdk/src/actions/build/package_task.rs b/crates/cargo-wdk/src/actions/build/package_task.rs index 7bd2f3299..40adede64 100644 --- a/crates/cargo-wdk/src/actions/build/package_task.rs +++ b/crates/cargo-wdk/src/actions/build/package_task.rs @@ -10,7 +10,7 @@ use std::{ ffi::{CStr, CString}, marker::PhantomData, - ops::RangeFrom, + ops::RangeInclusive, path::{Path, PathBuf}, result::Result, }; @@ -43,9 +43,9 @@ pub enum SignMode { }, } -// FIXME: This range is inclusive of 25798. Update with range end after /sample -// flag is added to InfVerif CLI -const MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE: RangeFrom = 25798..; +// InfVerif in WDK builds in this range is bugged and does not contain the +// /sample flag. +const MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE: RangeInclusive = 25798..=26100; const WDR_TEST_CERT_STORE: &str = "WDRTestCertStore"; const WDR_LOCAL_TEST_CERT: &str = "WDRLocalTestCert"; const STAMPINF_VERSION_ENV_VAR: &str = "STAMPINF_VERSION"; diff --git a/crates/cargo-wdk/src/actions/build/tests.rs b/crates/cargo-wdk/src/actions/build/tests.rs index de615a525..0d4e4fed5 100644 --- a/crates/cargo-wdk/src/actions/build/tests.rs +++ b/crates/cargo-wdk/src/actions/build/tests.rs @@ -213,12 +213,51 @@ pub fn given_a_driver_project_when_sample_class_is_true_then_it_builds_successfu let cargo_build_output = create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); + let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_default_package_task_steps(driver_name, driver_type, target_arch, verify_signature) - .expect_detect_wdk_build_number(25100u32); + .expect_detect_wdk_build_number(28000u32); + + assert_build_action_run_with_env_is_success( + &cwd, + profile, + None, + verify_signature, + sample_class, + test_build_action, + ); +} + +#[test] +pub fn given_sample_class_and_wdk_build_with_missing_sample_flag_then_infverif_is_skipped() { + // Input CLI args + let cwd = PathBuf::from("C:\\tmp"); + let profile = None; + let target_arch = CpuArchitecture::Amd64; + let verify_signature = false; + let sample_class = true; + + // Driver project data + let driver_type = "KMDF"; + let driver_name = "sample-kmdf"; + let driver_version = "0.0.1"; + let wdk_metadata = get_cargo_metadata_wdk_metadata(driver_type, 1, 33); + let (workspace_member, package) = + get_cargo_metadata_package(&cwd, driver_name, driver_version, Some(&wdk_metadata)); + + let cargo_build_output = + create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); + // WDK build 26100 is within the range whose InfVerif is missing the + // /sample flag, so InfVerif is skipped entirely for the sample class. + let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) + .set_up_standalone_driver_project((workspace_member, package)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) + .expect_package_task_steps_without_infverif(driver_name, target_arch, verify_signature) + .expect_detect_wdk_build_number(26100u32); assert_build_action_run_with_env_is_success( &cwd, @@ -1914,6 +1953,20 @@ impl TestBuildAction { driver_type: &str, target_arch: CpuArchitecture, verify_signature: bool, + ) -> Self { + let cwd = self.cwd.clone(); + self.expect_package_task_steps_without_infverif(driver_name, target_arch, verify_signature) + .expect_infverif(driver_name, &cwd, driver_type, None) + } + + /// Sets up all package-task expectations except `infverif`. Useful for + /// asserting the sample-class path where `InfVerif` is skipped for WDK + /// builds whose `InfVerif` is missing the `/sample` flag. + fn expect_package_task_steps_without_infverif( + self, + driver_name: &str, + target_arch: CpuArchitecture, + verify_signature: bool, ) -> Self { let cwd = self.cwd.clone(); let expected_certmgr_output = get_certmgr_success_output(); @@ -1932,8 +1985,7 @@ impl TestBuildAction { .expect_makecert(&cwd, None) .expect_copy_self_signed_cert_file_to_package_folder(driver_name, &cwd, true) .expect_signtool_sign_driver_binary_sys_file(driver_name, &cwd, None) - .expect_signtool_sign_cat_file(driver_name, &cwd, None) - .expect_infverif(driver_name, &cwd, driver_type, None); + .expect_signtool_sign_cat_file(driver_name, &cwd, None); if !verify_signature { return expectations; } From 59e0e34bff2b3697674c0892e3de26854108d451 Mon Sep 17 00:00:00 2001 From: Shravan Vasista Date: Thu, 11 Jun 2026 16:06:25 +0530 Subject: [PATCH 2/7] fix: correct typo in comments regarding `/samples` flag in InfVerif --- crates/cargo-wdk/src/actions/build/package_task.rs | 2 +- crates/cargo-wdk/src/actions/build/tests.rs | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/cargo-wdk/src/actions/build/package_task.rs b/crates/cargo-wdk/src/actions/build/package_task.rs index 40adede64..51e3f671a 100644 --- a/crates/cargo-wdk/src/actions/build/package_task.rs +++ b/crates/cargo-wdk/src/actions/build/package_task.rs @@ -44,7 +44,7 @@ pub enum SignMode { } // InfVerif in WDK builds in this range is bugged and does not contain the -// /sample flag. +// /samples flag. const MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE: RangeInclusive = 25798..=26100; const WDR_TEST_CERT_STORE: &str = "WDRTestCertStore"; const WDR_LOCAL_TEST_CERT: &str = "WDRLocalTestCert"; diff --git a/crates/cargo-wdk/src/actions/build/tests.rs b/crates/cargo-wdk/src/actions/build/tests.rs index 0d4e4fed5..407ad3e42 100644 --- a/crates/cargo-wdk/src/actions/build/tests.rs +++ b/crates/cargo-wdk/src/actions/build/tests.rs @@ -250,8 +250,6 @@ pub fn given_sample_class_and_wdk_build_with_missing_sample_flag_then_infverif_i let cargo_build_output = create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); - // WDK build 26100 is within the range whose InfVerif is missing the - // /sample flag, so InfVerif is skipped entirely for the sample class. let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) @@ -1959,9 +1957,6 @@ impl TestBuildAction { .expect_infverif(driver_name, &cwd, driver_type, None) } - /// Sets up all package-task expectations except `infverif`. Useful for - /// asserting the sample-class path where `InfVerif` is skipped for WDK - /// builds whose `InfVerif` is missing the `/sample` flag. fn expect_package_task_steps_without_infverif( self, driver_name: &str, From 65f804d31be30a7f4a9c69cbc9114a2c58295323 Mon Sep 17 00:00:00 2001 From: Shravan Vasista Date: Thu, 11 Jun 2026 20:07:47 +0530 Subject: [PATCH 3/7] fix: update InfVerif samples flag --- crates/cargo-wdk/src/actions/build/package_task.rs | 6 +++++- crates/cargo-wdk/src/actions/build/tests.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/cargo-wdk/src/actions/build/package_task.rs b/crates/cargo-wdk/src/actions/build/package_task.rs index 51e3f671a..b98c863db 100644 --- a/crates/cargo-wdk/src/actions/build/package_task.rs +++ b/crates/cargo-wdk/src/actions/build/package_task.rs @@ -552,7 +552,11 @@ impl<'a> PackageTask<'a> { warn!("InfVerif skipped for samples class. WDK Build: {wdk_build_number}"); return Ok(()); } - "/msft" + if wdk_build_number > *MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE.end() { + "/samples" + } else { + "/msft" + } } else { "" }; diff --git a/crates/cargo-wdk/src/actions/build/tests.rs b/crates/cargo-wdk/src/actions/build/tests.rs index 407ad3e42..2ee0628d1 100644 --- a/crates/cargo-wdk/src/actions/build/tests.rs +++ b/crates/cargo-wdk/src/actions/build/tests.rs @@ -2979,7 +2979,7 @@ impl TestBuildAction { expected_infverif_args.push("/u".to_string()); } if self.sample_class { - expected_infverif_args.push("/msft".to_string()); + expected_infverif_args.push("/samples".to_string()); } let expected_infverif_command: &'static str = "infverif"; let expected_driver_name_underscored = driver_name.replace('-', "_"); From cd65e66127a0339feba0b3b31a5f902f08732be7 Mon Sep 17 00:00:00 2001 From: Shravan Vasista Date: Sun, 14 Jun 2026 15:57:50 +0530 Subject: [PATCH 4/7] fix: improve InfVerif tests for samples flag handling --- crates/cargo-wdk/src/actions/build/tests.rs | 70 ++++++++++++++++----- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/crates/cargo-wdk/src/actions/build/tests.rs b/crates/cargo-wdk/src/actions/build/tests.rs index 2ee0628d1..66c94eed8 100644 --- a/crates/cargo-wdk/src/actions/build/tests.rs +++ b/crates/cargo-wdk/src/actions/build/tests.rs @@ -213,13 +213,52 @@ pub fn given_a_driver_project_when_sample_class_is_true_then_it_builds_successfu let cargo_build_output = create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); + let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) + .set_up_standalone_driver_project((workspace_member, package)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) + .expect_package_task_steps_without_infverif(driver_name, target_arch, verify_signature) + .expect_infverif(driver_name, &cwd, driver_type, Some("/samples"), None) + .expect_detect_wdk_build_number(26101u32); + + assert_build_action_run_with_env_is_success( + &cwd, + profile, + None, + verify_signature, + sample_class, + test_build_action, + ); +} +#[test] +pub fn given_sample_class_and_wdk_build_before_sample_flag_range_then_infverif_runs_with_msft() { + // Input CLI args + let cwd = PathBuf::from("C:\\tmp"); + let profile = None; + let target_arch = CpuArchitecture::Amd64; + let verify_signature = false; + let sample_class = true; + + // Driver project data + let driver_type = "KMDF"; + let driver_name = "sample-kmdf"; + let driver_version = "0.0.1"; + let wdk_metadata = get_cargo_metadata_wdk_metadata(driver_type, 1, 33); + let (workspace_member, package) = + get_cargo_metadata_package(&cwd, driver_name, driver_version, Some(&wdk_metadata)); + + let cargo_build_output = + create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); + // WDK build 25100 is below the range with the bugged InfVerif and predates + // the /samples flag, so InfVerif runs with /msft for the sample class. let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) - .expect_default_package_task_steps(driver_name, driver_type, target_arch, verify_signature) - .expect_detect_wdk_build_number(28000u32); + .expect_package_task_steps_without_infverif(driver_name, target_arch, verify_signature) + .expect_infverif(driver_name, &cwd, driver_type, Some("/msft"), None) + .expect_detect_wdk_build_number(25100u32); assert_build_action_run_with_env_is_success( &cwd, @@ -445,7 +484,7 @@ pub fn given_a_driver_project_when_self_signed_exists_then_it_should_skip_callin .expect_copy_self_signed_cert_file_to_package_folder(driver_name, &cwd, true) .expect_signtool_sign_driver_binary_sys_file(driver_name, &cwd, None) .expect_signtool_sign_cat_file(driver_name, &cwd, None) - .expect_infverif(driver_name, &cwd, "KMDF", None) + .expect_infverif(driver_name, &cwd, "KMDF", None, None) .expect_signtool_verify_driver_binary_sys_file(driver_name, &cwd, None) .expect_signtool_verify_cat_file(driver_name, &cwd, None); @@ -500,7 +539,7 @@ pub fn given_a_driver_project_when_final_package_dir_exists_then_it_should_skip_ .expect_copy_self_signed_cert_file_to_package_folder(driver_name, &cwd, true) .expect_signtool_sign_driver_binary_sys_file(driver_name, &cwd, None) .expect_signtool_sign_cat_file(driver_name, &cwd, None) - .expect_infverif(driver_name, &cwd, "KMDF", None); + .expect_infverif(driver_name, &cwd, "KMDF", None, None); assert_build_action_run_with_env_is_success( &cwd, @@ -768,7 +807,7 @@ pub fn given_a_driver_project_when_certmgr_command_execution_fails_then_package_ .expect_copy_map_file_to_package_folder(driver_name, &cwd, true) .expect_stampinf(driver_name, &cwd, target_arch, None) .expect_inf2cat(driver_name, &cwd, target_arch, None) - .expect_infverif(driver_name, &cwd, driver_type, None) + .expect_infverif(driver_name, &cwd, driver_type, None, None) .expect_self_signed_cert_file_exists(&cwd, false) .expect_certmgr_exists_check(Some(expected_output)); @@ -828,7 +867,7 @@ pub fn given_a_driver_project_when_makecert_command_execution_fails_then_package .expect_copy_map_file_to_package_folder(driver_name, &cwd, true) .expect_stampinf(driver_name, &cwd, target_arch, None) .expect_inf2cat(driver_name, &cwd, target_arch, None) - .expect_infverif(driver_name, &cwd, driver_type, None) + .expect_infverif(driver_name, &cwd, driver_type, None, None) .expect_self_signed_cert_file_exists(&cwd, false) .expect_certmgr_exists_check(None) .expect_makecert(&cwd, Some(expected_output)); @@ -889,7 +928,7 @@ pub fn given_a_driver_project_when_signtool_command_execution_fails_then_package .expect_copy_map_file_to_package_folder(driver_name, &cwd, true) .expect_stampinf(driver_name, &cwd, target_arch, None) .expect_inf2cat(driver_name, &cwd, target_arch, None) - .expect_infverif(driver_name, &cwd, driver_type, None) + .expect_infverif(driver_name, &cwd, driver_type, None, None) .expect_self_signed_cert_file_exists(&cwd, false) .expect_certmgr_exists_check(None) .expect_makecert(&cwd, None) @@ -952,7 +991,7 @@ pub fn given_a_driver_project_when_infverif_command_execution_fails_then_package .expect_copy_map_file_to_package_folder(driver_name, &cwd, true) .expect_stampinf(driver_name, &cwd, target_arch, None) .expect_inf2cat(driver_name, &cwd, target_arch, None) - .expect_infverif(driver_name, &cwd, driver_type, Some(expected_output)); + .expect_infverif(driver_name, &cwd, driver_type, None, Some(expected_output)); let build_action = initialize_build_action( &cwd, @@ -1281,7 +1320,7 @@ pub fn given_a_workspace_with_multiple_driver_and_non_driver_projects_when_cwd_i .expect_signtool_sign_cat_file(driver_name_1, &workspace_root_dir, None) .expect_signtool_verify_driver_binary_sys_file(driver_name_1, &workspace_root_dir, None) .expect_signtool_verify_cat_file(driver_name_1, &workspace_root_dir, None) - .expect_infverif(driver_name_1, &workspace_root_dir, "KMDF", None); + .expect_infverif(driver_name_1, &workspace_root_dir, "KMDF", None, None); assert_build_action_run_with_env_is_success( &cwd, @@ -1954,7 +1993,7 @@ impl TestBuildAction { ) -> Self { let cwd = self.cwd.clone(); self.expect_package_task_steps_without_infverif(driver_name, target_arch, verify_signature) - .expect_infverif(driver_name, &cwd, driver_type, None) + .expect_infverif(driver_name, &cwd, driver_type, None, None) } fn expect_package_task_steps_without_infverif( @@ -2008,7 +2047,7 @@ impl TestBuildAction { .expect_copy_map_file_to_package_folder(driver_name, &cwd, true) .expect_stampinf(driver_name, &cwd, target_arch, None) .expect_inf2cat(driver_name, &cwd, target_arch, None) - .expect_infverif(driver_name, &cwd, driver_type, None) + .expect_infverif(driver_name, &cwd, driver_type, None, None) } fn expect_default_package_task_steps_for_workspace( @@ -2036,7 +2075,7 @@ impl TestBuildAction { .expect_copy_self_signed_cert_file_to_package_folder(driver_name, &cwd, true) .expect_signtool_sign_driver_binary_sys_file(driver_name, &cwd, None) .expect_signtool_sign_cat_file(driver_name, &cwd, None) - .expect_infverif(driver_name, &cwd, driver_type, None); + .expect_infverif(driver_name, &cwd, driver_type, None, None); if !verify_signature { return expectations; } @@ -2970,6 +3009,7 @@ impl TestBuildAction { driver_name: &str, driver_dir: &Path, driver_type: &str, + expected_sample_flag: Option<&str>, override_output: Option, ) -> Self { let mut expected_infverif_args = vec!["/v".to_string()]; @@ -2978,8 +3018,10 @@ impl TestBuildAction { } else { expected_infverif_args.push("/u".to_string()); } - if self.sample_class { - expected_infverif_args.push("/samples".to_string()); + if self.sample_class + && let Some(sample_flag) = expected_sample_flag + { + expected_infverif_args.push(sample_flag.to_string()); } let expected_infverif_command: &'static str = "infverif"; let expected_driver_name_underscored = driver_name.replace('-', "_"); From 6bfa32ae4015dde162ad70ab079c1cc8c18ab604 Mon Sep 17 00:00:00 2001 From: Shravan Vasista Date: Mon, 15 Jun 2026 08:17:21 +0530 Subject: [PATCH 5/7] fix: remove comments regarding InfVerif and /samples flag in tests --- crates/cargo-wdk/src/actions/build/tests.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/cargo-wdk/src/actions/build/tests.rs b/crates/cargo-wdk/src/actions/build/tests.rs index 66c94eed8..97ba8e871 100644 --- a/crates/cargo-wdk/src/actions/build/tests.rs +++ b/crates/cargo-wdk/src/actions/build/tests.rs @@ -250,8 +250,6 @@ pub fn given_sample_class_and_wdk_build_before_sample_flag_range_then_infverif_r let cargo_build_output = create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); - // WDK build 25100 is below the range with the bugged InfVerif and predates - // the /samples flag, so InfVerif runs with /msft for the sample class. let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) From b68cac2336113ffacede70b4ec348ef300ad75c8 Mon Sep 17 00:00:00 2001 From: Shravan Vasista Date: Fri, 3 Jul 2026 14:06:16 +0530 Subject: [PATCH 6/7] fix: update infverif sample flag handling and adjust test expectations --- .../src/actions/build/package_task.rs | 1 + crates/cargo-wdk/src/actions/build/tests.rs | 51 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/crates/cargo-wdk/src/actions/build/package_task.rs b/crates/cargo-wdk/src/actions/build/package_task.rs index b98c863db..5fb8f6785 100644 --- a/crates/cargo-wdk/src/actions/build/package_task.rs +++ b/crates/cargo-wdk/src/actions/build/package_task.rs @@ -552,6 +552,7 @@ impl<'a> PackageTask<'a> { warn!("InfVerif skipped for samples class. WDK Build: {wdk_build_number}"); return Ok(()); } + // Use the `/samples` flag after the range and the `/msft` flag before the range if wdk_build_number > *MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE.end() { "/samples" } else { diff --git a/crates/cargo-wdk/src/actions/build/tests.rs b/crates/cargo-wdk/src/actions/build/tests.rs index 0f82188f9..2993bc231 100644 --- a/crates/cargo-wdk/src/actions/build/tests.rs +++ b/crates/cargo-wdk/src/actions/build/tests.rs @@ -64,7 +64,7 @@ pub fn given_a_driver_project_when_default_values_are_provided_then_it_builds_su let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_default_package_task_steps(driver_name, "KMDF", target_arch, verify_signature); @@ -99,7 +99,7 @@ pub fn given_a_driver_project_when_profile_is_release_then_it_builds_successfull create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_default_package_task_steps(driver_name, "KMDF", target_arch, verify_signature); @@ -140,7 +140,7 @@ pub fn given_a_driver_project_when_target_arch_is_arm64_then_it_builds_successfu let test_build_action = &TestBuildAction::new(cwd.clone(), profile, Some(target_arch), sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_default_package_task_steps(driver_name, "KMDF", target_arch, verify_signature); assert_build_action_run_with_env_is_success( @@ -182,7 +182,7 @@ pub fn given_a_driver_project_when_profile_is_release_and_target_arch_is_arm64_t let test_build_action = &TestBuildAction::new(cwd.clone(), profile, Some(target_arch), sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_default_package_task_steps(driver_name, "KMDF", target_arch, verify_signature); assert_build_action_run_with_env_is_success( @@ -216,7 +216,7 @@ pub fn given_a_driver_project_when_sample_class_is_true_then_it_builds_successfu create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 26101u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_package_task_steps_without_infverif(driver_name, target_arch, verify_signature) .expect_infverif(driver_name, &cwd, driver_type, Some("/samples"), None) @@ -253,11 +253,11 @@ pub fn given_sample_class_and_wdk_build_before_sample_flag_range_then_infverif_r create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25797u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_package_task_steps_without_infverif(driver_name, target_arch, verify_signature) .expect_infverif(driver_name, &cwd, driver_type, Some("/msft"), None) - .expect_detect_wdk_build_number(25100u32); + .expect_detect_wdk_build_number(25797u32); assert_build_action_run_with_env_is_success( &cwd, @@ -290,7 +290,7 @@ pub fn given_sample_class_and_wdk_build_with_missing_sample_flag_then_infverif_i create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 26100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_package_task_steps_without_infverif(driver_name, target_arch, verify_signature) .expect_detect_wdk_build_number(26100u32); @@ -326,7 +326,7 @@ pub fn given_a_driver_project_when_verify_signature_is_true_then_it_builds_succe create_cargo_build_output_json(driver_name, driver_version, &cwd, None, profile); let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_default_package_task_steps(driver_name, driver_type, target_arch, verify_signature); @@ -363,7 +363,7 @@ pub fn given_a_driver_project_when_sign_mode_is_off_then_signing_and_verificatio let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .with_sign_mode(SignMode::Off) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_package_task_steps_with_sign_mode_off(driver_name, driver_type, target_arch); @@ -400,7 +400,7 @@ pub fn given_a_driver_project_when_locked_is_set_then_it_is_forwarded_to_cargo_i let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .with_locked(true) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_default_package_task_steps(driver_name, driver_type, target_arch, verify_signature); @@ -466,7 +466,7 @@ pub fn given_a_driver_project_when_self_signed_exists_then_it_should_skip_callin let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_final_package_dir_exists(driver_name, &cwd, true) .expect_inx_file_exists(driver_name, &cwd, true) @@ -520,7 +520,7 @@ pub fn given_a_driver_project_when_final_package_dir_exists_then_it_should_skip_ let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_final_package_dir_exists(driver_name, &cwd, false) .expect_dir_created(driver_name, &cwd, true) @@ -572,7 +572,7 @@ pub fn given_a_driver_project_when_inx_file_do_not_exist_then_package_should_fai let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_inx_file_exists(driver_name, &cwd, false); @@ -621,7 +621,7 @@ pub fn given_a_driver_project_when_copy_of_an_artifact_fails_then_the_package_sh let test_build_action = &TestBuildAction::new(cwd.clone(), profile, Some(target_arch), sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_final_package_dir_exists(driver_name, &cwd, true) .expect_inx_file_exists(driver_name, &cwd, true) .expect_rename_driver_binary_dll_to_sys(driver_name, &cwd) @@ -672,7 +672,7 @@ pub fn given_a_driver_project_when_stampinf_command_execution_fails_then_package let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_final_package_dir_exists(driver_name, &cwd, true) .expect_inx_file_exists(driver_name, &cwd, true) @@ -733,7 +733,7 @@ pub fn given_a_driver_project_when_inf2cat_command_execution_fails_then_package_ let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_final_package_dir_exists(driver_name, &cwd, true) .expect_inx_file_exists(driver_name, &cwd, true) @@ -795,7 +795,7 @@ pub fn given_a_driver_project_when_certmgr_command_execution_fails_then_package_ let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_final_package_dir_exists(driver_name, &cwd, true) .expect_inx_file_exists(driver_name, &cwd, true) @@ -855,7 +855,7 @@ pub fn given_a_driver_project_when_makecert_command_execution_fails_then_package let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_final_package_dir_exists(driver_name, &cwd, true) .expect_inx_file_exists(driver_name, &cwd, true) @@ -916,7 +916,7 @@ pub fn given_a_driver_project_when_signtool_command_execution_fails_then_package let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_final_package_dir_exists(driver_name, &cwd, true) .expect_inx_file_exists(driver_name, &cwd, true) @@ -979,7 +979,7 @@ pub fn given_a_driver_project_when_infverif_command_execution_fails_then_package let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc(&cwd, target_arch, None) .expect_final_package_dir_exists(driver_name, &cwd, true) .expect_inx_file_exists(driver_name, &cwd, true) @@ -1026,7 +1026,7 @@ pub fn given_a_non_driver_project_when_default_values_are_provided_with_no_wdk_m let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, None); + .expect_default_build_task_steps(driver_name, None, 25100u32); assert_build_action_run_is_success( &cwd, @@ -1053,7 +1053,7 @@ pub fn given_a_invalid_driver_project_with_partial_wdk_metadata_when_valid_defau let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_with_custom_toml(&cargo_toml_metadata) - .expect_default_build_task_steps(driver_name, None); + .expect_default_build_task_steps(driver_name, None, 25100u32); let build_action = initialize_build_action( &cwd, @@ -1101,7 +1101,7 @@ pub fn given_a_driver_project_when_target_arch_is_not_provided_and_probing_cargo let test_build_action = &TestBuildAction::new(cwd.clone(), profile, None, sample_class) .set_up_standalone_driver_project((workspace_member, package)) - .expect_default_build_task_steps(driver_name, Some(cargo_build_output)) + .expect_default_build_task_steps(driver_name, Some(cargo_build_output), 25100u32) .expect_probe_target_arch_using_cargo_rustc( &cwd, CpuArchitecture::Amd64, @@ -1993,9 +1993,10 @@ impl TestBuildAction { self, driver_name: &str, cargo_build_output: Option, + wdk_build_number: u32, ) -> Self { let cwd = self.cwd.clone(); - self.expect_detect_wdk_build_number(25100u32) + self.expect_detect_wdk_build_number(wdk_build_number) .expect_root_manifest_exists(&cwd, true) .expect_cargo_build(driver_name, &cwd, cargo_build_output) } From 32bd21d2ae032d97d5477960e45054df1d5d8a37 Mon Sep 17 00:00:00 2001 From: Shravan Vasista Date: Tue, 14 Jul 2026 18:08:21 +0530 Subject: [PATCH 7/7] fix: refine infverif flag handling based on WDK build number range and update related tests --- .../src/actions/build/package_task.rs | 25 +++++++++---------- crates/cargo-wdk/src/actions/build/tests.rs | 7 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/cargo-wdk/src/actions/build/package_task.rs b/crates/cargo-wdk/src/actions/build/package_task.rs index 5fb8f6785..d6475e0c3 100644 --- a/crates/cargo-wdk/src/actions/build/package_task.rs +++ b/crates/cargo-wdk/src/actions/build/package_task.rs @@ -544,19 +544,18 @@ impl<'a> PackageTask<'a> { fn run_infverif(&self) -> Result<(), PackageTaskError> { let additional_args = if self.sample_class { let wdk_build_number = self.wdk_build.detect_wdk_build_number()?; - if MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE.contains(&wdk_build_number) { - debug!( - "InfVerif in WDK Build {wdk_build_number} is bugged and does not contain the \ - /samples flag." - ); - warn!("InfVerif skipped for samples class. WDK Build: {wdk_build_number}"); - return Ok(()); - } - // Use the `/samples` flag after the range and the `/msft` flag before the range - if wdk_build_number > *MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE.end() { - "/samples" - } else { - "/msft" + match wdk_build_number { + n if MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE.contains(&n) => { + debug!( + "InfVerif in WDK Build {wdk_build_number} is bugged and does not contain \ + the /samples flag." + ); + warn!("InfVerif skipped for samples class. WDK Build: {wdk_build_number}"); + return Ok(()); + } + // Use the `/samples` flag after the range and the `/msft` flag before the range + n if n > *MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE.end() => "/samples", + _ => "/msft", } } else { "" diff --git a/crates/cargo-wdk/src/actions/build/tests.rs b/crates/cargo-wdk/src/actions/build/tests.rs index 2993bc231..2aeee353e 100644 --- a/crates/cargo-wdk/src/actions/build/tests.rs +++ b/crates/cargo-wdk/src/actions/build/tests.rs @@ -196,7 +196,8 @@ pub fn given_a_driver_project_when_profile_is_release_and_target_arch_is_arm64_t } #[test] -pub fn given_a_driver_project_when_sample_class_is_true_then_it_builds_successfully() { +pub fn given_sample_class_is_true_and_wdk_build_is_above_range_then_infverif_runs_with_samples_flag() + { // Input CLI args let cwd = PathBuf::from("C:\\tmp"); let profile = None; @@ -233,7 +234,7 @@ pub fn given_a_driver_project_when_sample_class_is_true_then_it_builds_successfu } #[test] -pub fn given_sample_class_and_wdk_build_before_sample_flag_range_then_infverif_runs_with_msft() { +pub fn given_sample_class_is_true_and_wdk_build_below_range_then_infverif_runs_with_msft_flag() { // Input CLI args let cwd = PathBuf::from("C:\\tmp"); let profile = None; @@ -270,7 +271,7 @@ pub fn given_sample_class_and_wdk_build_before_sample_flag_range_then_infverif_r } #[test] -pub fn given_sample_class_and_wdk_build_with_missing_sample_flag_then_infverif_is_skipped() { +pub fn given_sample_class_is_true_and_wdk_build_within_range_then_infverif_is_skipped() { // Input CLI args let cwd = PathBuf::from("C:\\tmp"); let profile = None;