summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorStefan Vacek <stefan.vacek@intel.com>2015-08-26 13:59:13 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2015-10-07 10:35:09 +0200
commit133a8bd48b42bb4714ad4472c89277db6dd4f88d (patch)
tree83b5e3602c83ab5213a84b556b6ef95ea02c8d8c /src/tests
parentc7d765971913568a7d701bfb8a8444bc882ccbf1 (diff)
downloadDLT-daemon-133a8bd48b42bb4714ad4472c89277db6dd4f88d.tar.gz
Restrict dlt-receive to write max. n-bytes
- dlt-receive gets a new parameter to restrict the maximum size of the written file. When the limit is exceeded, a new file is opened - testscript (bash) in src/tests provided to demonstrate functionality Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
Diffstat (limited to 'src/tests')
-rwxr-xr-xsrc/tests/dlt-test-receiver-multiple-files.sh72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/tests/dlt-test-receiver-multiple-files.sh b/src/tests/dlt-test-receiver-multiple-files.sh
new file mode 100755
index 0000000..013cbe6
--- /dev/null
+++ b/src/tests/dlt-test-receiver-multiple-files.sh
@@ -0,0 +1,72 @@
+#!/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 -g -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.dlt localhost &
+dlt_receive_pid=$!
+disown
+
+# start dlt-example-user to create some logs (use different number of messages)
+/usr/bin/dlt-example-user -d 100 -n 20 TEST_MESSAGE_TWO
+
+# show content of /tmp --> original file was overwritten
+kill ${dlt_receive_pid}
+echo "log-file after second run"
+ls -l ${output_dir}
+
+# start dlt-receive with small maximum file size (in background) and store PID
+echo "Starting dlt-receive"
+/usr/bin/dlt-receive -o ${output_dir}/dlt_test.dlt -c 3K localhost &
+dlt_receive_pid=$!
+disown
+
+# start dlt-example-user to create some logs (use even more messages then before)
+/usr/bin/dlt-example-user -d 20 -n 500 TEST_MESSAGE_THREE
+
+# show content of /tmp --> multiple files were created, the original file was preserved
+echo "log-file after third run (should show multiple files)"
+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