3 # Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 SESSIOND_CLIENT_SOCK_PATH
="/tmp/.test-sessiond-client"
23 SESSIOND_APPS_SOCK_PATH
="/tmp/.test-sessiond-apps"
24 SESSIOND_BIN
="$PWD/../../ltt-sessiond/ltt-sessiond"
25 LTTNG_BIN
="$PWD/../../lttng/lttng"
26 #SESSIOND_ARGS="-c $SESSIOND_CLIENT_SOCK_PATH -a $SESSIOND_APPS_SOCK_PATH"
28 SESSION_ID_REGEX
="[[:alnum:]]{8}-[[:alnum:]]{4}-[[:alnum:]]{4}-[[:alnum:]]{4}-[[:alnum:]]{12}"
32 echo "[+] Shuting down session daemon..."
37 # Exec $1, check error code.
38 # If 0, return output, else, stop execution
39 # and return and error.
40 function check_ret_code
()
43 printf "\n!STOPPING!\n"
48 # Create session with $1 and return output.
49 function lttng_create_session
()
51 local command="$LTTNG_BIN -c $1"
55 # Extract session UUID
56 if [[ "$ret" =~
$SESSION_ID_REGEX ]]; then
57 LTTNG_SESSION_ID
="$BASH_REMATCH"
61 # List sessions and return output.
62 function lttng_list_session
()
64 local command="$LTTNG_BIN --list-sessions"
65 local ret
=$
(lttng_command
"$command")
67 if [[ "$result" =~
$session_id ]]; then
71 printf "Missing $session_id!\n"
77 function test_destroy_session
()
79 local command="$LTTNG_BIN -d $LTTNG_SESSION_ID"
81 check_ret_code
$LTTNG_RET_CODE
82 echo "[+] Destroy session: PASSED!"
85 function test_one_session
()
87 lttng_create_session
"test1"
88 check_ret_code
$LTTNG_RET_CODE
89 echo "[+] Session creation: PASSED!"
92 function test_session_same_name
()
94 lttng_create_session
"test-same"
95 lttng_create_session
"test-same"
96 if [ $LTTNG_RET_CODE -ne 1 ]; then
97 echo "[-] Session with the same name: FAILED!"
98 printf "Two session having the same name NOT ALLOWED\n"
101 echo "[+] Session with the same name: PASSED!"
104 if [ ! -x $SESSIOND_BIN ]; then
105 echo "Please use make before test execution"
109 # Daemonized by the -d
110 .
/$SESSIOND_BIN $SESSIOND_ARGS -d
111 echo "[+] Session daemon started"
113 pid
=$
(pidof lt-ltt-sessiond
)
114 if [ -z "$pid" ]; then
115 echo "[-] Can't found session daemon"
116 .
/$SESSIOND_BIN $SESSIOND_ARGS
119 echo "[+] Got the session daemon pid $pid"
121 printf "=== Starting tests ===\n"
127 test_session_same_name