Mercurial > crates > systemd-socket
view tests/systemd.rs @ 13:f740dadd2948
Added enable_systemd feature
This feature makes systemd support optional, on by default. While it may
seem strange that this feature exists, it makes sense for authors of
applications who want to make systemd optional. Thanks to this feature
the interface stays the same, it just fails to parse `systemd://`
addresses with a helpful error message.
author | Martin Habovstiak <martin.habovstiak@gmail.com> |
---|---|
date | Thu, 03 Dec 2020 16:34:09 +0100 |
parents | 9731ff589d9c |
children | bc76507dd878 |
line wrap: on
line source
// This integration test requires presence of systemd-socket-activate 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 = "systemd://secret_socket_of_satoshi_nakamoto"; fn spawn_slave(program_name: &OsStr) -> io::Result<Child> { Command::new("systemd-socket-activate") .arg("-l") .arg("127.0.0.1:4242") .arg("--fdname=secret_socket_of_satoshi_nakamoto") .arg("--setenv=SYSTEMD_SOCKET_INTEGRATION_TEST=slave") .arg(program_name) .spawn() } } #[test] #[cfg_attr(not(all(linux, feature = "enable_systemd")), should_panic)] fn main() { comm::main::<Test>(); }