view tests/ordinary.rs @ 24:1941e9d9819c

Fix unsound manipulation of env vars Modifying env vars in multi-threaded process is unsound but this crate was neither checking the number of threads nor mark its functions as `unsafe`. This change fixes it by both adding a check and adding an `unsafe` function that can bypass that check if needed.
author Martin Habovstiak <martin.habovstiak@gmail.com>
date Fri, 28 Feb 2025 13:52:31 +0100
parents 66c0e10c89fc
children cfef4593e207
line wrap: on
line source

use std::io;
use std::ffi::OsStr;
use std::process::{Command, Child};

mod comm;

enum Test {}

impl comm::Test for Test {
    const SOCKET_ADDR: &'static str = "localhost:4242";

    fn spawn_slave(program_name: &OsStr) -> io::Result<Child> {
        Command::new(program_name)
            .env("SYSTEMD_SOCKET_INTEGRATION_TEST", "slave")
            .spawn()
    }
}

#[test]
fn main() {
    comm::main::<Test>();
}