diff libpam-sys/libpam-sys-test/build.rs @ 124:f469b8d9ad78 default tip

Add tests for the original X/SSO constants list.
author Paul Fisher <paul@pfish.zone>
date Mon, 30 Jun 2025 04:54:38 -0400
parents 9e05e44050d0
children
line wrap: on
line diff
--- a/libpam-sys/libpam-sys-test/build.rs	Mon Jun 30 04:26:44 2025 -0400
+++ b/libpam-sys/libpam-sys-test/build.rs	Mon Jun 30 04:54:38 2025 -0400
@@ -9,41 +9,38 @@
     let config = match PamImpl::CURRENT {
         PamImpl::LinuxPam => TestConfig {
             headers: vec![
-                "security/_pam_types.h".into(),
-                "security/pam_appl.h".into(),
-                "security/pam_ext.h".into(),
-                "security/pam_modules.h".into(),
+                "<security/_pam_types.h>",
+                "<security/pam_appl.h>",
+                "<security/pam_ext.h>",
+                "<security/pam_modules.h>",
             ],
             ignore_consts: vec![
-                "__LINUX_PAM__".into(),
-                "__LINUX_PAM_MINOR__".into(),
-                "PAM_AUTHTOK_RECOVER_ERR".into(),
+                "__LINUX_PAM__",
+                "__LINUX_PAM_MINOR__",
+                "PAM_AUTHTOK_RECOVER_ERR",
             ],
             ..Default::default()
         },
         PamImpl::OpenPam => TestConfig {
             headers: vec![
-                "security/pam_types.h".into(),
-                "security/openpam.h".into(),
-                "security/pam_appl.h".into(),
-                "security/pam_constants.h".into(),
+                "<security/pam_types.h>",
+                "<security/openpam.h>",
+                "<security/pam_appl.h>",
+                "<security/pam_constants.h>",
             ],
-            ignore_consts: vec![
-                "OPENPAM_VERSION".into(),
-                "OPENPAM_RELEASE".into(),
-                "PAM_SOEXT".into(),
-            ],
+            ignore_consts: vec!["OPENPAM_VERSION", "OPENPAM_RELEASE", "PAM_SOEXT"],
             ..Default::default()
         },
         PamImpl::Sun => TestConfig {
-            headers: vec![
-                "security/pam_appl.h".into(),
-                "security/pam_modules.h".into(),
-            ],
-            block_headers: vec!["sys/.*".into()],
+            headers: vec!["<security/pam_appl.h>", "<security/pam_modules.h>"],
+            block_headers: vec!["sys/.*"],
             ..Default::default()
         },
-        PamImpl::XSso => Default::default(),
+        PamImpl::XSso => TestConfig {
+            headers: vec!["\"xsso_constants.h\""],
+            ignore_consts: vec!["PAM_CRED_PRELIM_CHECK"],
+            ..Default::default()
+        },
         other => panic!("Unknown PAM implementation {other:?}"),
     };
     generate_const_test(&config);
@@ -100,9 +97,9 @@
 
 #[derive(Default)]
 struct TestConfig {
-    headers: Vec<String>,
-    block_headers: Vec<String>,
-    ignore_consts: Vec<String>,
+    headers: Vec<&'static str>,
+    block_headers: Vec<&'static str>,
+    ignore_consts: Vec<&'static str>,
 }
 
 impl TestConfig {
@@ -110,12 +107,14 @@
         let vec: Vec<_> = self
             .headers
             .iter()
-            .map(|h| format!("#include <{h}>\n"))
+            .map(|h| format!("#include {h}\n"))
             .collect();
         vec.join("")
     }
 
     fn should_check_const(&self, item: &ItemConst) -> bool {
-        !self.ignore_consts.contains(&item.ident.to_string())
+        !self
+            .ignore_consts
+            .contains(&item.ident.to_string().as_ref())
     }
 }