1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
|
#!/bin/sh
################################################################################
# SPDX license identifier: MPL-2.0
#
# Copyright (C) 2016, Advanced Driver Information Technology
# This code is developed by Advanced Driver Information Technology.
# Copyright of Advanced Driver Information Technology, Bosch and DENSO.
#
# This file is part of COVESA Project DLT - Diagnostic Log and Trace.
#
# This Source Code Form is subject to the terms of the
# Mozilla Public License (MPL), v. 2.0.
# If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# For further information see http://www.covesa.org/.
################################################################################
################################################################################
#file : dlt_multinode_test.sh
#
#Description : Smoke testing for multinode feature of DLT
#
#Author Name : Onkar Palkar
# Jeevan Ramakant Nagvekar
#Email Id : onkar.palkar@wipro.com
# jeevan.nagvekar1@wipro.com
#
#History : 31/07/2018
################################################################################
ipaddr=127.0.0.1
#
# Function: -getOSname()
#
# Description -Retrieves OS name
#
getOSname()
{
OS="`uname`"
}
#
# Function: -cleanup()
#
# Description -Delete the dlt_test folder if it already present
# -Check weather required binaries are avaiable or not
# -Restore dlt_gateway.conf file
#
# Return -Zero on success
# -Non zero on failure
#
cleanup()
{
tmpPath=/tmp
tmpFolder=dlt_test
gatewayFolderName=gateway
passiveFolderName=passive
tmpPassiveDIR=tmpPassive
tmpLogFile=log_multinode.txt
tmpLogAsciFile=log_multinode_a.txt
if [ "$OS" = "QNX" ]
then
PIDOF()
{
slay -p $1 > /dev/null
if [ $? -eq '0' ]
then
return 1
else
return 0
fi
}
KILLALL()
{
slay -9 -f $1 > /dev/null
if [ $? -eq '0' ]
then
return 1
else
return 0
fi
}
else
PIDOF()
{
pidof $1 > /dev/null
return $?
}
KILLALL()
{
killall $1 > /dev/null
return $?
}
fi
cd $tmpPath
PIDOF "dlt-daemon"
if [ $? -eq '0' ]
then
KILLALL "dlt-daemon"
if [ $? -ne '0' ]
then
echo "Failed to kill daemons"
return 1
fi
fi
PIDOF "dlt-receive"
if [ $? -eq '0' ]
then
KILLALL "dlt-receive"
if [ $? -ne '0' ]
then
echo "Failed to kill dlt-receive"
return 1
fi
fi
PIDOF "dlt-convert"
if [ $? -eq '0' ]
then
KILLALL "dlt-convert"
if [ $? -ne '0' ]
then
echo "Failed to kill dlt-convert"
return 1
fi
fi
rm -rf $tmpPath/$tmpFolder >/dev/null
return 0
}
#
# Function: -setupTest()
#
# Description -Create one gateway and passive folder
# -Create and add dlt.conf and dlt_gateway.conf file in the gateway folder
# -Create and add dlt.conf file in the passive folder
#
# Return -Zero on success
# -Non zero on failure
#
setupTest()
{
which dlt-daemon > /dev/null
if [ $? -ne '0' ]
then
echo "dlt-daemon is not available"
return 1
fi
which dlt-example-user > /dev/null
if [ $? -ne '0' ]
then
echo "dlt-example-user is not available"
return 1
fi
which dlt-receive > /dev/null
if [ $? -ne '0' ]
then
echo "dlt-receive is not available"
return 1
fi
mkdir -p $tmpPath/$tmpFolder
if [ $? -ne '0' ]
then
echo "Error in creating dlt_test folder"
return 1
fi
mkdir -p $tmpPath/$tmpFolder/$gatewayFolderName
if [ $? -ne '0' ]
then
echo "Error in creating gateway folder"
return 1
fi
touch $tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
if [ $? -ne '0' ]
then
echo "Error in creating dlt.conf file"
return 1
fi
echo "SendContextRegistration = 1" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "ECUId = ECU1" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "GatewayMode = 1" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "SharedMemorySize = 100000" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "LoggingMode = 0" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "LoggingLevel = 6" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "LoggingFilename = /tmp/dlt.log" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "TimeOutOnSend = 4" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "RingbufferMinSize = 500000" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "RingbufferMaxSize = 10000000" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "RingbufferStepSize = 500000" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "ControlSocketPath = /tmp/dlt-ctrl.sock" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
echo "GatewayConfigFile = $tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf" >> $tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf
touch $tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf
if [ $? -ne '0' ]
then
echo "Error in creating dlt_gateway file"
return 1
fi
echo "[PassiveNode1]" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf
echo "IPaddress=$ipaddr">>$tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf
echo "Port=3495" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf
echo "EcuID=ECU2" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf
echo "Connect=OnStartup" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf
echo "Timeout=10" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf
echo "NOFiles=1" >>$tmpPath/$tmpFolder/$gatewayFolderName/dlt_gateway.conf
mkdir -p $tmpPath/$tmpFolder/$passiveFolderName
if [ $? -ne '0' ]
then
echo "Error in creating passive folder"
return 1
fi
touch $tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
if [ $? -ne '0' ]
then
echo "Error in creating dlt.conf file"
return 1
fi
echo "SendContextRegistration = 1" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "ECUId = ECU2" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "SharedMemorySize = 100000" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "LoggingMode = 0" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "LoggingLevel = 6" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "LoggingFilename = /tmp/dlt.log" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "TimeOutOnSend = 4" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "RingbufferMinSize = 500000" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "RingbufferMaxSize = 10000000" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "RingbufferStepSize = 500000" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
echo "ControlSocketPath = /tmp/dlt-ctrl.sock" >>$tmpPath/$tmpFolder/$passiveFolderName/dlt.conf
mkdir -p $tmpPath/$tmpFolder/$tmpPassiveDIR
if [ $? -ne '0' ]
then
echo "Error while creating tempPassive folder"
return 1
fi
return 0
}
#
# Function: -startDaemons()
#
# Description -Start dlt-daemon as passive node
# -Start dlt-daemon as gateway node
#
# Return -Zero on success
# -Non zero on failure
#
startDaemons()
{
dlt-daemon -c $tmpPath/$tmpFolder/$passiveFolderName/dlt.conf -p 3495 -t $tmpPath/$tmpFolder/$tmpPassiveDIR -d > /dev/null
dlt-daemon -c $tmpPath/$tmpFolder/$gatewayFolderName/dlt.conf -p 3490 -d > /dev/null
return 0
}
#
# Function: -startExample()
#
# Description -Start dlt-example-user on passive node
#
# Return -Zero on success
# -Non zero on failure
#
startExample()
{
export DLT_PIPE_DIR=$tmpPath/$tmpFolder/$tmpPassiveDIR
dlt-example-user MultiNodeTesting > /dev/null &
return 0
}
#
# Function: -starReceive()
#
# Description -Start dlt-receive
#
# Return -Zero on success
# -Non zero on failure
#
startReceive()
{
dlt-receive -o $tmpPath/$tmpFolder/$tmpLogFile localhost &
return 0
}
#
# Function: -verifyTest()
#
# Description -Start dlt-convert
# -check weather msg sent by passive node are available in logs or not
#
# Return -Zero on success
# -Non zero on failure
#
verifyTest()
{
dlt-convert -a $tmpPath/$tmpFolder/$tmpLogFile > $tmpPath/$tmpFolder/$tmpLogAsciFile
cat $tmpPath/$tmpFolder/$tmpLogAsciFile | grep -F "ECU2" > /dev/null
if [ $? -eq '0' ]
then
return 0
else
return 1
fi
}
#main function
########################################################################################
getOSname
cleanup
if [ $? -ne '0' ]
then
echo "getIpAdd() failed"
cleanup
return 1
fi
setupTest
if [ $? -ne '0' ]
then
echo "setupTest() failed"
cleanup
return 1
fi
startDaemons
if [ $? -ne '0' ]
then
echo "startDaemons() failed"
cleanup
return 1
fi
startExample
if [ $? -ne '0' ]
then
echo "startExample() failed"
cleanup
return 1
fi
#wait for 1 sec before starting dlt-receive to start dlt-example-user application properly
sleep 1
startReceive
if [ $? -ne '0' ]
then
echo "startReceive() failed"
cleanup
return 1
fi
#Wait for 1 sec to collect messages sent by application at gateway
sleep 1
verifyTest
if [ $? -eq '0' ]
then
echo "Test Passed"
else
echo "Test Failed"
fi
cleanup
|