+function test_relayd_env()
+{
+ local working_dir
+ local cwd
+ local pid
+
+ working_dir=$(mktemp -d)
+ working_dir=$(realpath "$(mktemp -d)")
+
+ diag "Test lttng-relayd change working directory from env. variable"
+
+ export LTTNG_RELAYD_WORKING_DIRECTORY=${working_dir}
+ start_lttng_relayd_opt 1 "-b" ""
+
+ pid=$(pgrep "$RELAYD_MATCH")
+ ok $? "Found lttng-relayd"
+
+ cwd=$(readlink "/proc/$pid/cwd")
+
+ is "$cwd" "$working_dir" "Working directory changed"
+
+ stop_lttng_relayd
+ rm -rf "$working_dir"
+ unset LTTNG_RELAYD_WORKING_DIRECTORY
+}
+
+function test_relayd_cmdline_overwrite_env()
+{
+ local working_dir_env
+ local working_dir_cmdline
+ local cwd
+ local pid
+
+ working_dir_env=$(realpath "$(mktemp -d)")
+ working_dir_cmdline=$(realpath "$(mktemp -d)")
+
+ diag "Test lttng-relayd change working directory command line overwrite env variable"
+
+ export LTTNG_RELAYD_WORKING_DIRECTORY=${working_dir_env}
+ start_lttng_relayd_opt 1 "-b" "--working-dir ${working_dir_cmdline}"
+
+ pid=$(pgrep "$RELAYD_MATCH")
+ ok $? "Found lttng-relayd"
+
+ cwd=$(readlink "/proc/$pid/cwd")
+
+ is "$cwd" "$working_dir_cmdline" "Working directory is the one from command line"
+
+ stop_lttng_relayd
+ rm -rf "$working_dir_env" "$working_dir_cmdline"
+ unset LTTNG_RELAYD_WORKING_DIRECTORY
+}
+