summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dlt_test_receiver.c31
-rw-r--r--tests/mod_system_logger/Makefile7
-rw-r--r--tests/mod_system_logger/mod_system_logger.c36
-rwxr-xr-xtests/start_filetransfer_test.sh12
-rwxr-xr-xtests/start_system_logger_test.sh44
-rwxr-xr-xtests/start_systemd_journal_test.sh6
6 files changed, 128 insertions, 8 deletions
diff --git a/tests/dlt_test_receiver.c b/tests/dlt_test_receiver.c
index 46b194b..c17716a 100644
--- a/tests/dlt_test_receiver.c
+++ b/tests/dlt_test_receiver.c
@@ -97,6 +97,7 @@ typedef struct {
int bvalue;
int filetransfervalue;
int systemjournalvalue;
+ int systemloggervalue;
char ecuid[4];
int ohandle;
DltFile file;
@@ -125,6 +126,7 @@ void usage()
printf(" -y Serial device mode\n");
printf(" -f Activate filetransfer test case\n");
printf(" -s Activate systemd journal test case\n");
+ printf(" -l Activate system logger test case");
printf(" -b baudrate Serial device baudrate (Default: 115200)\n");
printf(" -e ecuid Set ECU ID (Default: RECV)\n");
printf(" -o filename Output messages in new DLT file\n");
@@ -153,7 +155,7 @@ int main(int argc, char* argv[])
/* Fetch command line arguments */
opterr = 0;
- while ((c = getopt (argc, argv, "vshyfa:o:e:b:")) != -1)
+ while ((c = getopt (argc, argv, "vshyfla:o:e:b:")) != -1)
switch (c)
{
case 'v':
@@ -181,6 +183,11 @@ int main(int argc, char* argv[])
dltdata.systemjournalvalue = 1;
break;
}
+ case 'l':
+ {
+ dltdata.systemloggervalue = 1;
+ break;
+ }
case 'o':
{
dltdata.ovalue = optarg;
@@ -406,6 +413,28 @@ int dlt_receive_filetransfer_callback(DltMessage *message, void *data)
}
}
+ if(dltdata->systemloggervalue)
+ {
+ dlt_message_print_ascii(message, text, DLT_RECEIVE_TEXTBUFSIZE, dltdata->vflag);
+ // 1st find the relevant packages
+ char * tmp = message->extendedheader->ctid;
+ tmp[4] = '\0';
+ const char * substring = text;
+ const char * founding = "Test Systemlogger";
+ int length = strlen(founding);
+ if( strcmp( tmp , (const char *) "PROC") == 0)
+ {
+ substring = strstr(text, founding);
+ while (substring != NULL)
+ {
+ result ++;
+ substring +=length;
+ if(result == 1000)
+ exit(159);
+ }
+ }
+ }
+
/* if file output enabled write message */
if (dltdata->ovalue)
{
diff --git a/tests/mod_system_logger/Makefile b/tests/mod_system_logger/Makefile
new file mode 100644
index 0000000..fbe0d48
--- /dev/null
+++ b/tests/mod_system_logger/Makefile
@@ -0,0 +1,7 @@
+obj-m := mod_system_logger.o
+KDIR := /lib/modules/$(shell uname -r)/build
+PWD := $(shell pwd)
+default:
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
+clean:
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
diff --git a/tests/mod_system_logger/mod_system_logger.c b/tests/mod_system_logger/mod_system_logger.c
new file mode 100644
index 0000000..1d31fdb
--- /dev/null
+++ b/tests/mod_system_logger/mod_system_logger.c
@@ -0,0 +1,36 @@
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+int i;
+
+static int system_proc_show(struct seq_file *m, void *v) {
+ for(i=0; i<1000; i++)
+ seq_printf(m, "Test Systemlogger %i\n",i);
+ return 0;
+}
+
+static int system_proc_open(struct inode *inode, struct file *file) {
+ return single_open(file, system_proc_show, NULL);
+}
+
+static const struct file_operations system_proc_fops = {
+ .owner = THIS_MODULE,
+ .open = system_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static int __init system_proc_init(void) {
+ proc_create("systemlogger", 0, NULL, &system_proc_fops);
+ return 0;
+}
+
+static void __exit system_proc_exit(void) {
+ remove_proc_entry("systemlogger", NULL);
+}
+
+MODULE_LICENSE("GPL");
+module_init(system_proc_init);
+module_exit(system_proc_exit);
diff --git a/tests/start_filetransfer_test.sh b/tests/start_filetransfer_test.sh
index c139fb1..cafc705 100755
--- a/tests/start_filetransfer_test.sh
+++ b/tests/start_filetransfer_test.sh
@@ -1,22 +1,22 @@
#!/bin/bash
+
file="testfile_filetransfer.txt"
fullpath="$(pwd)/testfile_filetransfer.txt"
-
#start dlt-daemon
dlt-daemon &
+sleep 1
#start dlt-test-receiver
./../build/tests/dlt_test_receiver -f localhost &
+sleep 1
#send file to daemon
dlt-example-filetransfer $fullpath &
-
-
+sleep 1
+#create md5 sum
md5_1=($(md5sum $file))
md5_2=($(md5sum /tmp/$file))
-
-
echo $md5_1
echo $md5_2
-
+#verify the sums
tput setaf 1
if [ $md5_1 == $md5_2 ]
then
diff --git a/tests/start_system_logger_test.sh b/tests/start_system_logger_test.sh
new file mode 100755
index 0000000..e470b92
--- /dev/null
+++ b/tests/start_system_logger_test.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+#enable logging of files and setup
+sudo sed -i 's/LogFileEnable = 0/LogFileEnable = 1/g' /usr/local/etc/dlt-system.conf
+echo "# TEST LOG TO SYSTEMLOGGER_PROC" | sudo tee -a /usr/local/etc/dlt-system.conf
+echo "LogFileFilename = /proc/systemlogger" | sudo tee -a /usr/local/etc/dlt-system.conf
+echo "LogFileMode = 1" | sudo tee -a /usr/local/etc/dlt-system.conf
+echo "LogFileTimeDelay = 3" | sudo tee -a /usr/local/etc/dlt-system.conf
+echo "LogFileContextId = PROC" | sudo tee -a /usr/local/etc/dlt-system.conf
+#comile the kernel module for system logging
+cd mod_system_logger
+make
+cd ..
+#enable mod
+sudo insmod mod_system_logger/mod_system_logger.ko
+#start dlt-daemon
+dlt-daemon &
+sleep 1
+#start dlt-system
+dlt-system &
+sleep 1
+#start dlt-receiver
+../build/tests/dlt_test_receiver -l localhost &
+sleep 1
+pid=$!
+wait $pid
+exitcode=$?
+#kill processes and remove mod
+pkill dlt-daemon
+pkill dlt-system
+sudo rmmod mod_system_logger
+cd mod_system_logger
+make clean
+cd ..
+# if exit code == 159 , test successfull
+tput setaf 1
+if [ $exitcode == 159 ]; then
+ echo "System Logger tests successfull."
+else
+ echo "System Logger tests failed."
+ echo "Maybe missing kernel-heaers"
+ echo "for compiling the test module"
+fi
+tput setaf 7
diff --git a/tests/start_systemd_journal_test.sh b/tests/start_systemd_journal_test.sh
index bdac21c..aecac47 100755
--- a/tests/start_systemd_journal_test.sh
+++ b/tests/start_systemd_journal_test.sh
@@ -4,13 +4,16 @@
mkdir ../build
cd ../build/
cmake -DWITH_SYSTEMD_JOURNAL=ON ..
-make && sudo make install
+make
+sudo make install
#enable SYSTEMD_JOURNAL in config file
sudo vim -esnc '%s/JournalEnable = 0/JournalEnable = 1/g|:wq' /usr/local/etc/dlt-system.conf
#start dlt-daemon
dlt-daemon &
+sleep 1
#start dlt_system
dlt-system &
+sleep 1
#send 10 times "DLT SYSTEM JOURNAL TEST"
for i in {1..1000}
do
@@ -18,6 +21,7 @@ do
done
#start receiver
./../build/tests/dlt_test_receiver -s localhost &
+sleep 1
pid=$!
wait $pid
exitcode=$?