Expand "invalid buffer" negative integration tests
[platform/core/system/dlog.git] / tests / dlog_cpu.in
1 #!/bin/sh
2
3 # We don't do that here
4 exec 2> /dev/null
5
6 # Initialization inspired by dlog_test.in, TODO: unify somehow
7 if [ $# -ne 1 ]; then
8         echo "usage: $0 pipe|logger"
9         exit 1
10 fi
11
12 if [ "$1" = "pipe" ]; then
13         type="pipe"
14 elif [ "$1" = "logger" ]; then
15         type="logger"
16 else
17         echo "usage: $0 pipe|logger"
18         exit 1
19 fi
20
21 NEEDS_TO_QUIT=0
22 capsh --print | grep Current | grep cap_syslog > /dev/null || { echo "*** ERROR: cap_syslog missing"; NEEDS_TO_QUIT=1; }
23 mount | grep ' / ' | grep rw > /dev/null || { echo "*** ERROR: root not mounted read-write"; NEEDS_TO_QUIT=1; }
24 [ $NEEDS_TO_QUIT -eq 0 ] || exit 1
25
26 export DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.cpu"
27 PATH=$PATH:@libexecdir@/libdlog/
28
29 LOGGER=-1
30 TEST=-1
31 RUNTIME_FILTERS_DIR="/tmp/dlog-filters/"
32 WRITER_DIR="/tmp/dlog-writers/"
33
34 cleanup() {
35         [ $LOGGER -ne -1 ] && kill $LOGGER > /dev/null 2>&1
36         [ $TEST -ne -1 ] && kill $TEST > /dev/null 2>&1
37         [ -d $RUNTIME_FILTERS_DIR ] && rm -rf $RUNTIME_FILTERS_DIR
38         [ -d $WRITER_DIR ] && rm -rf $WRITER_DIR
39 }
40 trap cleanup 0
41
42 mkdir -p "$RUNTIME_FILTERS_DIR"
43 mkdir -p "$WRITER_DIR"
44
45 dlog_logger &
46 LOGGER=$!
47 sleep 1
48 (while :; do dlogsend -c 1000 -b main -t DLOG_CPU_TEST1 hi; sleep 0.1; done) &
49 TEST=$!
50 sleep 10
51 ps --no-headers --quick-pid $LOGGER --format %cpu