36 lines
967 B
Rust
36 lines
967 B
Rust
// SPDX-FileCopyrightText: 2022 Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
mod common;
|
|
|
|
use {
|
|
anyhow::{bail, Result},
|
|
libc::{freeaddrinfo, gai_strerror, getaddrinfo},
|
|
};
|
|
|
|
#[test]
|
|
#[should_panic(expected = "not yet implemented")]
|
|
fn nss_module_is_loaded() {
|
|
common::setup().unwrap();
|
|
|
|
let hostname = std::ffi::CString::new("gnome.org").unwrap();
|
|
unsafe {
|
|
let mut addr = std::ptr::null_mut();
|
|
match getaddrinfo(
|
|
hostname.as_ptr(),
|
|
std::ptr::null(),
|
|
std::ptr::null(),
|
|
&mut addr,
|
|
) {
|
|
0 => freeaddrinfo(addr),
|
|
status => {
|
|
let error = std::ffi::CStr::from_ptr(gai_strerror(status));
|
|
panic!(
|
|
"Unable to resolve hostname, getaddrinfo returned {}",
|
|
error.to_str().unwrap()
|
|
)
|
|
}
|
|
}
|
|
};
|
|
}
|