fix: separate cargo target-dirs to avoid parallel lock contention, add pam smoke test
This commit is contained in:
20
meson.build
20
meson.build
@@ -20,24 +20,25 @@ resources = gnome.compile_resources(
|
|||||||
c_name: 'ahfail'
|
c_name: 'ahfail'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Each cargo target uses its own --target-dir to avoid parallel lock contention.
|
||||||
cargo_target = custom_target(
|
cargo_target = custom_target(
|
||||||
'ahfail-cargo-build',
|
'ahfail-cargo-build',
|
||||||
input: ['crates/ahfail-gtklock/src/lib.rs', 'Cargo.toml'],
|
input: ['crates/ahfail-gtklock/src/lib.rs', 'Cargo.toml'],
|
||||||
output: ['libahfail_module.a'],
|
output: ['libahfail_module.a'],
|
||||||
command: [
|
command: [
|
||||||
'sh', '-c', 'cargo build --release -p ahfail-gtklock --target-dir "@OUTDIR@/target" && cp "@OUTDIR@/target/release/libahfail_module.a" "@OUTPUT@"'
|
'sh', '-c', 'cargo build --release -p ahfail-gtklock --target-dir "@OUTDIR@/target-gtklock" && cp "@OUTDIR@/target-gtklock/release/libahfail_module.a" "@OUTPUT@"'
|
||||||
],
|
],
|
||||||
build_by_default: true
|
build_by_default: true
|
||||||
)
|
)
|
||||||
|
|
||||||
# PAM module (.so with C ABI — no resources needed, Cargo self-contained)
|
# PAM module (.so with C ABI — no GResources needed, Cargo self-contained via build.rs)
|
||||||
pam_cargo = custom_target(
|
pam_cargo = custom_target(
|
||||||
'ahfail-pam-cargo-build',
|
'ahfail-pam-cargo-build',
|
||||||
input: ['crates/ahfail-pam/src/lib.rs', 'Cargo.toml'],
|
input: ['crates/ahfail-pam/src/lib.rs', 'Cargo.toml'],
|
||||||
output: ['libahfail_pam.so'],
|
output: ['libahfail_pam.so'],
|
||||||
command: [
|
command: [
|
||||||
'sh', '-c',
|
'sh', '-c',
|
||||||
'cargo build --release -p ahfail-pam --target-dir "@OUTDIR@/target" && cp "@OUTDIR@/target/release/libahfail_pam.so" "@OUTPUT@"'
|
'cargo build --release -p ahfail-pam --target-dir "@OUTDIR@/target-pam" && cp "@OUTDIR@/target-pam/release/libahfail_pam.so" "@OUTPUT@"'
|
||||||
],
|
],
|
||||||
build_by_default: true,
|
build_by_default: true,
|
||||||
install: true,
|
install: true,
|
||||||
@@ -45,14 +46,14 @@ pam_cargo = custom_target(
|
|||||||
install_mode: 'rwxr-xr-x'
|
install_mode: 'rwxr-xr-x'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Display binary (embeds GResources via its own build.rs)
|
# Display binary (embeds GResources via its own build.rs using glib-compile-resources)
|
||||||
display_cargo = custom_target(
|
display_cargo = custom_target(
|
||||||
'ahfail-display-cargo-build',
|
'ahfail-display-cargo-build',
|
||||||
input: ['crates/ahfail-display/src/main.rs', 'Cargo.toml'],
|
input: ['crates/ahfail-display/src/main.rs', 'Cargo.toml'],
|
||||||
output: ['ahfail-display'],
|
output: ['ahfail-display'],
|
||||||
command: [
|
command: [
|
||||||
'sh', '-c',
|
'sh', '-c',
|
||||||
'cargo build --release -p ahfail-display --target-dir "@OUTDIR@/target" && cp "@OUTDIR@/target/release/ahfail-display" "@OUTPUT@"'
|
'cargo build --release -p ahfail-display --target-dir "@OUTDIR@/target-display" && cp "@OUTDIR@/target-display/release/ahfail-display" "@OUTPUT@"'
|
||||||
],
|
],
|
||||||
build_by_default: true,
|
build_by_default: true,
|
||||||
install: true,
|
install: true,
|
||||||
@@ -81,3 +82,12 @@ smoke = executable(
|
|||||||
)
|
)
|
||||||
|
|
||||||
test('module symbols', smoke)
|
test('module symbols', smoke)
|
||||||
|
|
||||||
|
# PAM module smoke test: dlopen libahfail_pam.so and verify pam_sm_authenticate is exported.
|
||||||
|
pam_smoke = executable(
|
||||||
|
'pam_smoke_test',
|
||||||
|
'tests/pam_smoke_test.c',
|
||||||
|
dependencies: [cc.find_library('dl', required: true)]
|
||||||
|
)
|
||||||
|
|
||||||
|
test('pam symbols', pam_smoke, args: [pam_cargo[0]])
|
||||||
|
|||||||
18
tests/pam_smoke_test.c
Normal file
18
tests/pam_smoke_test.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include <dlfcn.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf(stderr, "Usage: %s <libahfail_pam.so>\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
void *lib = dlopen(argv[1], RTLD_NOW);
|
||||||
|
if (!lib) { fprintf(stderr, "dlopen: %s\n", dlerror()); return 1; }
|
||||||
|
if (!dlsym(lib, "pam_sm_authenticate")) {
|
||||||
|
fprintf(stderr, "pam_sm_authenticate not found\n");
|
||||||
|
dlclose(lib);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
dlclose(lib);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user