summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorStefan Vacek <stefan.vacek@intel.com>2015-08-26 17:28:54 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2015-10-07 10:35:41 +0200
commitc3b53f8805236cb7c72eb62ef04866f34de33103 (patch)
tree956eec44e2d0b2ec309904f15321565a3fae4e3d /src/tests
parent2f334a851fa1b39cab74724f3d0a0565f86c27b4 (diff)
downloadDLT-daemon-c3b53f8805236cb7c72eb62ef04866f34de33103.tar.gz
Add env-var to set initial log-levels
name of environment variable: DLT_INITIAL_LOG_LEVEL Syntax: <apid1>:<ctid1>:<loglevel1>;<apid2>:<ctid2>:<loglevel2>;... apid: application id (up to 4 chars), if empty all applications will match ctid: context id (up to 4 chars), if empty all contexts will match loglevel: either -1..6 or a symbolic name (default, off, fatal, error, warning, info, debug, verbose) Examples: DLT_INITIAL_LOG_LEVEL=TEST:LOG:0 -> turn off logging for appid TEST and contextid LOG DLT_INITIAL_LOG_LEVEL=:LOG:warn -> for contexts with name "LOG" set log-level to warning (3) DLT_INITIAL_LOG_LEVEL=::VERBOSE -> set log-level of all contexts to VERBOSE DLT_INITIAL_LOG_LEVEL=::VERBOSE;TEST:LOG:3 -> set log-level of all contexts to VERBOSE except TEST:LOG, set this to WARNING dlt-example-user: add option -l to specify log-level to be used when sending messages Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
Diffstat (limited to 'src/tests')
-rwxr-xr-xsrc/tests/dlt-test-change-ll-through-env.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/tests/dlt-test-change-ll-through-env.sh b/src/tests/dlt-test-change-ll-through-env.sh
new file mode 100755
index 0000000..0a469cc
--- /dev/null
+++ b/src/tests/dlt-test-change-ll-through-env.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+# check if dlt-daemon is running
+daemon_running=`/usr/bin/ps -C dlt-daemon | wc -l`
+daemon_pid=0
+
+if [ "$daemon_running" -lt "2" ]; then
+ echo "No daemon running, starting one myself"
+ /usr/bin/dlt-daemon > /tmp/dlt_daemon_dlt_receiver_test.txt &
+ daemon_pid=$!
+ echo "daemon pid: " ${daemon_pid}
+else
+ echo "dlt-daemon already running"
+fi
+
+# create a directory in /tmp where all logs will be stored
+output_dir=`mktemp -d /tmp/DLT_TESTING_XXXXXX`
+echo "Using directory " ${output_dir}
+
+# start dlt-receive (in background) and store PID
+echo "Starting dlt-receive"
+/usr/bin/dlt-receive -o ${output_dir}/dlt_test.dlt localhost &
+dlt_receive_pid=$!
+disown
+
+# start dlt-example-user to create some logs
+# sleep time: 100ms
+# number of messages: 10
+/usr/bin/dlt-example-user -d 100 -n 10 TEST_MESSAGE_ONE
+
+# stop dlt-receive
+kill ${dlt_receive_pid}
+
+# show content of /tmp
+echo "log-file after first run"
+ls -l ${output_dir}
+
+# start dlt-receive (in background) and store PID
+echo "Starting dlt-receive"
+/usr/bin/dlt-receive -o ${output_dir}/dlt_test_no_log.dlt localhost &
+dlt_receive_pid=$!
+disown
+
+# start dlt-example-user to create some logs, disable logging through environment variable
+DLT_INITIAL_LOG_LEVEL=::-1 /usr/bin/dlt-example-user -d 100 -n 10 TEST_MESSAGE_TWO
+
+# show content of /tmp, log should not contain log messages from dlt-example-user (TEST_MESSAGE_TWO)
+kill ${dlt_receive_pid}
+echo "log-file after second run"
+ls -l ${output_dir}
+
+# directory will not be cleaned up
+echo "Used directory " ${output_dir}
+
+
+if [ "${daemon_pid}" -ne "0" ]; then
+ sleep 1
+ kill ${daemon_pid}
+fi