summaryrefslogtreecommitdiff
path: root/src/test/test-util.c
diff options
context:
space:
mode:
authorJakub Filak <jfilak@redhat.com>2014-11-19 11:01:19 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-21 00:32:02 +0100
commitad450c3e0418fe23e2896e581575cb06564ca29a (patch)
tree3f85df33ef5f286f750f904c5b6dc05aa336c838 /src/test/test-util.c
parent1c6eb4e36bf88015d0bbe8fae417622e6132b864 (diff)
util: add functions getting proc cwd and root
/proc/[pid]/cwd and /proc/[pid]/root are symliks to corresponding directories The added functions returns values of that symlinks.
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r--src/test/test-util.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 01e10c9fc1..b33e15aef0 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -490,13 +490,14 @@ static void test_u64log2(void) {
static void test_get_process_comm(void) {
struct stat st;
- _cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL;
+ _cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL, *cwd = NULL, *root = NULL;
unsigned long long b;
pid_t e;
uid_t u;
gid_t g;
dev_t h;
int r;
+ pid_t me;
if (stat("/proc/1/comm", &st) == 0) {
assert_se(get_process_comm(1, &a) >= 0);
@@ -532,6 +533,16 @@ static void test_get_process_comm(void) {
log_info("pid1 gid: "GID_FMT, g);
assert_se(g == 0);
+ me = getpid();
+
+ r = get_process_cwd(me, &cwd);
+ assert_se(r >= 0 || r == -EACCES);
+ log_info("pid1 cwd: '%s'", cwd);
+
+ r = get_process_root(me, &root);
+ assert_se(r >= 0 || r == -EACCES);
+ log_info("pid1 root: '%s'", root);
+
assert_se(get_ctty_devnr(1, &h) == -ENOENT);
getenv_for_pid(1, "PATH", &i);