annotate libpam-sys/libpam-sys-test/tests/runner.rs @ 139:33b9622ed6d2

Remove redundant memory management in nonstick::libpam; fix UB. - Uses the libpam-sys-helpers BinaryPayload / OwnedBinaryPayload structs to handle memory management and parsing for Linux-PAM binary messages. - Gets rid of the (technically) undefined behavior in PtrPtrVec due to pointer provenance. - Don't check for malloc failing. It won't, even if it does. - Formatting/cleanups/etc.
author Paul Fisher <paul@pfish.zone>
date Thu, 03 Jul 2025 23:57:49 -0400
parents 88627c057709
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
1 #![allow(unused_imports)]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
2
137
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
3 macro_rules! include_test {
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
4 ($file:literal) => {
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
5 include!(concat!(env!("OUT_DIR"), "/", $file));
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
6 };
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
7 }
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
8
139
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
9 #[allow(
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
10 dead_code,
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
11 non_camel_case_types,
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
12 non_upper_case_globals,
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
13 clippy::unnecessary_cast
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
14 )]
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
15 mod constants {
137
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
16 mod generated {
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
17 include_test!("bindgen.rs");
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
18 }
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
19
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
20 include_test!("constant_test.rs");
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
21
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
22 #[test]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
23 fn test_constants() {
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
24 main()
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
25 }
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
26 }
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
27
139
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
28 #[allow(
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
29 clippy::disallowed_names,
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
30 clippy::needless_range_loop,
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
31 clippy::nonminimal_bool
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
32 )]
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
33 mod ctest {
133
32b2a545ca3e Add functions and constants from openpam.h.
Paul Fisher <paul@pfish.zone>
parents: 131
diff changeset
34 use libc::*;
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
35 use libpam_sys::*;
137
88627c057709 Add Sun PAM functions from Illumos headers.
Paul Fisher <paul@pfish.zone>
parents: 136
diff changeset
36 include_test!("ctest.rs");
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
37
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
38 #[test]
139
33b9622ed6d2 Remove redundant memory management in nonstick::libpam; fix UB.
Paul Fisher <paul@pfish.zone>
parents: 137
diff changeset
39 #[cfg_attr(miri, ignore)]
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
40 fn test_c() {
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
41 main();
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
42 }
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 127
diff changeset
43 }