test: split out test-pidfd-util from test-process-util
The tested function pidfd_get_inode_id_self_cached() is provided by pidfd-util.c. Let's introduce a new unit test for the file.
This commit is contained in:
@@ -171,6 +171,7 @@ simple_tests += files(
|
||||
'test-path-lookup.c',
|
||||
'test-path-util.c',
|
||||
'test-percent-util.c',
|
||||
'test-pidfd-util.c',
|
||||
'test-pidref.c',
|
||||
'test-plymouth-util.c',
|
||||
'test-pressure.c',
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "errno-util.h"
|
||||
#include "format-util.h"
|
||||
#include "pidfd-util.h"
|
||||
#include "process-util.h"
|
||||
#include "tests.h"
|
||||
|
||||
TEST(pidfd_get_inode_id_self_cached) {
|
||||
int r;
|
||||
|
||||
log_info("pid=" PID_FMT, getpid_cached());
|
||||
|
||||
uint64_t id;
|
||||
r = pidfd_get_inode_id_self_cached(&id);
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
log_info("pidfdid not supported");
|
||||
else {
|
||||
assert(r >= 0);
|
||||
log_info("pidfdid=%" PRIu64, id);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_TEST_MAIN(LOG_DEBUG);
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "log.h"
|
||||
#include "namespace-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "pidfd-util.h"
|
||||
#include "pidref.h"
|
||||
#include "process-util.h"
|
||||
#include "procfs-util.h"
|
||||
@@ -1075,21 +1074,6 @@ TEST(pidref_from_same_root_fs) {
|
||||
ASSERT_OK_ZERO(pidref_from_same_root_fs(&child2, &self));
|
||||
}
|
||||
|
||||
TEST(pidfd_get_inode_id_self_cached) {
|
||||
int r;
|
||||
|
||||
log_info("pid=" PID_FMT, getpid_cached());
|
||||
|
||||
uint64_t id;
|
||||
r = pidfd_get_inode_id_self_cached(&id);
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
log_info("pidfdid not supported");
|
||||
else {
|
||||
assert(r >= 0);
|
||||
log_info("pidfdid=%" PRIu64, id);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(getenv_for_pid) {
|
||||
_cleanup_strv_free_ char **copy_env = NULL;
|
||||
pid_t pid = getpid_cached();
|
||||
|
||||
Reference in New Issue
Block a user