Skip to content

Commit

Permalink
Merge pull request #245 from smartdevicelink/develop
Browse files Browse the repository at this point in the history
Release 8.1.0
  • Loading branch information
jacobkeeler authored Apr 13, 2022
2 parents 08354ae + 2645fc1 commit 2040ca3
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 51 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ If version is not specified `20` will be used by default.

By default ATF reads the following parameters from `Default` configuration (`./modules/configuration/`).

Config File | Config Parameter | Cmd Argument | Description
----------------------|---------------------------------|--------------|-----------------------------------------
base_config.lua | config.SDL | | SDL binary name
base_config.lua | config.reportPath | --report | Path to reports and logs
base_config.lua | config.pathToSDL | --sdl-core | Path to SDL binaries
base_config.lua | config.pathToSDLInterfaces | --sdl-api | Path to SDL APIs
connection_config.lua | config.remoteConnection.enabled | | Defines if remote connection is enabled
Config File | Config Parameter | Cmd Argument | Description
----------------------|---------------------------------|-------------------|-----------------------------------------
base_config.lua | config.SDL | | SDL binary name
base_config.lua | config.reportPath | --report | Path to reports and logs
base_config.lua | config.pathToSDL | --sdl-core | Path to SDL binaries
base_config.lua | config.pathToSDLSource | --sdl-src | Path to SDL Core
base_config.lua | config.pathToSDLMobileInterface | --sdl-mobile-api | Path to SDL MOBILE API
base_config.lua | config.pathToSDLHMIInterface | --sdl-hmi-api | Path to SDL HMI API
connection_config.lua | config.remoteConnection.enabled | | Defines if remote connection is enabled

### Priorities

Expand Down Expand Up @@ -127,7 +129,9 @@ Being in `atf_build/bin` folder run the command:
- [OPTION] - is one or more of available options:
- --sdl-core <path> - path to SDL binaries
- --config <folder> - name of the folder with configuration
- --sdl-api <path> - path to SDL APIs
- --sdl-src <path> - path to SDL Core
- --sdl-mobile-api <path> - path to SDL MOBILE API
- --sdl-hmi-api <path> - path to SDL HMI API
- --report <path> - path to report and logs
- --sdl-log [ACTION] - how to collect SDL logs:
'yes' - (default) always save, 'no' - do not save, 'fail' - save if script failed or aborted
Expand Down
2 changes: 1 addition & 1 deletion atf_parallels/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG openssl_lib_ver

RUN apt-get update && apt-get -q -y install \
locales sudo libssl${openssl_lib_ver} libssl-dev libusb-1.0-0 libbluetooth3 openssl liblua5.2-0 psmisc \
libexpat1 sqlite3 libqt5websockets5 net-tools iproute2 \
libexpat1 sqlite3 libqt5websockets5 net-tools iproute2 gdb \
libssl-doc- libusb-1.0-doc- autotools-dev- binutils- build-essential- bzip2- cpp- \
dpkg-dev- fakeroot- manpages- manpages-dev- qttranslations5-l10n- xdg-user-dirs- xml-core- dbus-

Expand Down
2 changes: 1 addition & 1 deletion atf_parallels/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ echo "export LANG=en_US.UTF-8" >> /home/developer/.profile
mkdir /tmp/corefiles
chown developer /tmp/corefiles
chgrp developer /tmp/corefiles
echo '/tmp/corefiles/core.%e.%p.%t' > /proc/sys/kernel/core_pattern
echo '/tmp/corefiles/core.sdl.%p.%t' > /proc/sys/kernel/core_pattern

cd /home/developer/sdl/atf
sudo -E -u developer ./start.sh "$@"
61 changes: 47 additions & 14 deletions modules/atf/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,30 @@ local function convert_ms(milliseconds)
end

--- Check mandatory files existence for testing
-- Checks: SDL Core binary, HMI and MObile API files
-- Checks: SDL Core binary, HMI and Mobile API files
-- Stop ATF execution in case any error
local function check_required_fields()
local function check_api_exists(interface_path, api_file)
if (not is_file_exists(interface_path..api_file)) and
(not is_file_exists(interface_path.."/"..api_file)) then
print("ERROR: "..api_file.." file is not accessible at the specified path: "..interface_path)
os.exit(1)
end
end
if not config.remoteConnection.enabled then
if (not is_file_exists(config.pathToSDL..config.SDL)) and
(not is_file_exists(config.pathToSDL.."/" .. config.SDL)) then
print("ERROR: SDL is not accessible at the specified path: "..config.pathToSDL)
os.exit(1)
end
end
if config.pathToSDLInterfaces~="" and config.pathToSDLInterfaces~=nil then
if (not is_file_exists(config.pathToSDLInterfaces.."MOBILE_API.xml")) and
(not is_file_exists(config.pathToSDLInterfaces.."/MOBILE_API.xml")) then
print("ERROR: XML files are not accessible at the specified path: "..config.pathToSDLInterfaces)
os.exit(1)
end

if (config.pathToSDLMobileInterface~="" and config.pathToSDLMobileInterface~=nil) and
(config.pathToSDLHMIInterface~="" and config.pathToSDLHMIInterface~=nil) then
check_api_exists(config.pathToSDLMobileInterface, "MOBILE_API.xml")
check_api_exists(config.pathToSDLHMIInterface, "HMI_API.xml")
else
print "\27[33m WARNING: Parameter pathToSDLInterfaces is not specified, default APIs are used \27[0m"
print "\27[33m WARNING: Parameters pathToSDLMobileInterface and pathToSDLHMIInterface (or pathToSDLSource) are not specified, default APIs are used \27[0m"
end
end

Expand Down Expand Up @@ -262,10 +268,32 @@ function Util.commandLine.sdl_core(str)
config.pathToSDL = str
end

--- Overwrite property pathToSDLInterfaces in configuration of ATF
--- Overwrite property pathToSDLSource (and pathToSDLMobileInterface and pathToSDLHMIInterface if undefined)
-- in configuration of ATF
-- @tparam string str Value
function Util.commandLine.sdl_src(str)
config.pathToSDLSource = str

if (config.pathToSDLSource~="" and config.pathToSDLSource~=nil) then
if (config.pathToSDLMobileInterface=="" or config.pathToSDLMobileInterface==nil) then
config.pathToSDLMobileInterface = config.pathToSDLSource..config.defaultPathToMobileInterface
end
if (config.pathToSDLHMIInterface=="" or config.pathToSDLHMIInterface==nil) then
config.pathToSDLHMIInterface = config.pathToSDLSource..config.defaultPathToHMIInterface
end
end
end

--- Overwrite property pathToSDLMobileInterface in configuration of ATF
-- @tparam string str Value
function Util.commandLine.sdl_interfaces(str)
config.pathToSDLInterfaces = str
function Util.commandLine.sdl_mobile_api(str)
config.pathToSDLMobileInterface = str
end

--- Overwrite property pathToSDLHMIInterface in configuration of ATF
-- @tparam string str Value
function Util.commandLine.sdl_hmi_api(str)
config.pathToSDLHMIInterface = str
end

--- Overwrite property SecurityProtocol in configuration of ATF
Expand Down Expand Up @@ -326,12 +354,17 @@ local function copy_file(file, newfile)
end

local function copy_interfaces()
if config.pathToSDLInterfaces ~= "" and config.pathToSDLInterfaces ~= nil then
local mobile_api = config.pathToSDLInterfaces .. '/MOBILE_API.xml'
local hmi_api = config.pathToSDLInterfaces .. '/HMI_API.xml'
local function copy_files(mobile_interface_path, hmi_interface_path)
local mobile_api = mobile_interface_path .. '/MOBILE_API.xml'
local hmi_api = hmi_interface_path .. '/HMI_API.xml'
copy_file(mobile_api, 'data/MOBILE_API.xml')
copy_file(hmi_api, 'data/HMI_API.xml')
end

if (config.pathToSDLMobileInterface~="" and config.pathToSDLMobileInterface~=nil) and
(config.pathToSDLHMIInterface~="" and config.pathToSDLHMIInterface~=nil) then
copy_files(config.pathToSDLMobileInterface, config.pathToSDLHMIInterface)
end
end

--- Runner
Expand Down
18 changes: 15 additions & 3 deletions modules/configuration/base_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@ config.defaultProtocolVersion = 3
config.pathToSDL = ""
--- Define path to SDL Policy database
config.pathToSDLPolicyDB = "policy.sqlite"
--- Define path to SDL interfaces
-- Example: "/home/user/sdl_panasonic/src/components/interfaces"
config.pathToSDLInterfaces = ""
--- Define path to SDL source
-- Example: "/home/user/sdl_core"
config.pathToSDLSource = ""
--- Define default path to the mobile interface folder
-- Used in conjunction with pathToSDLSource (pathToSDLSource..defaultPathToMobileInterface)
config.defaultPathToMobileInterface = "/tools/rpc_spec"
--- Define default path to the HMI interface folder
-- Used in conjunction with pathToSDLSource (pathToSDLSource..defaultPathToHMIInterface)
config.defaultPathToHMIInterface = "/src/components/interfaces"
--- Define path to SDL MOBILE interface
-- Example: "/home/user/sdl_core/tools/rpc_spec"
config.pathToSDLMobileInterface = ""
--- Define path to SDL HMI interface
-- Example: "/home/user/sdl_core/src/components/interfaces"
config.pathToSDLHMIInterface = ""
--- Define SDL modification
config.SDL = "smartDeviceLinkCore"
--- Flag which defines behavior of ATF on SDL crash
Expand Down
4 changes: 3 additions & 1 deletion modules/launch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ util.commandLine.declare_long_opt("--heartbeat", util.commandLine.consts.Require
util.commandLine.declare_long_opt("--sdl-core", util.commandLine.consts.RequiredArgument, "Path to folder with SDL binary")
util.commandLine.declare_long_opt("--report-mark", util.commandLine.consts.RequiredArgument, "Marker of testing report")
util.commandLine.declare_long_opt("--security-protocol", util.commandLine.consts.RequiredArgument, "Security protocol type")
util.commandLine.declare_long_opt("--sdl-interfaces", util.commandLine.consts.RequiredArgument, "Path to folder with APIs")
util.commandLine.declare_long_opt("--sdl-src", util.commandLine.consts.RequiredArgument, "Path to folder with sdl core")
util.commandLine.declare_long_opt("--sdl-mobile-api", util.commandLine.consts.RequiredArgument, "Path to folder with MOBILE API")
util.commandLine.declare_long_opt("--sdl-hmi-api", util.commandLine.consts.RequiredArgument, "Path to folder with HMI API")

local script_files = util.commandLine.parse_cmdl()
if (#script_files > 0) then
Expand Down
10 changes: 5 additions & 5 deletions modules/protocol_handler/protocol_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ local function rpcPayload(msg)
bit32.rshift(bit32.band(msg.rpcFunctionId, 0xff0000), 16),
bit32.rshift(bit32.band(msg.rpcFunctionId, 0xff00), 8),
bit32.band(msg.rpcFunctionId, 0xff)) ..
int32ToBytes(uint32ToInt32(msg.rpcCorrelationId)) ..
int32ToBytes(uint32ToInt32(msg.rpcCorrelationId or 0)) ..
int32ToBytes(#msg.payload) ..
msg.payload .. msg.binaryData

Expand Down Expand Up @@ -166,17 +166,17 @@ local function hasToBuildBinaryHeader(message)
if message.frameType == constants.FRAME_TYPE.CONTROL_FRAME then
return false
end
if isHandshakeBinaryData(message.serviceType, message.rpcType, message.rpcFunctionId)
or isInternalErrorQuery(message.serviceType, message.rpcType, message.rpcFunctionId) then
return true
end
if message.payload then
if message.serviceType == constants.SERVICE_TYPE.RPC
or message.serviceType == constants.SERVICE_TYPE.BULK_DATA then
return true
end
return false
end
if isHandshakeBinaryData(message.serviceType, message.rpcType, message.rpcFunctionId, 0)
or isInternalErrorQuery(message.serviceType, message.rpcType, message.rpcFunctionId, 0) then
return true
end
return false
end

Expand Down
43 changes: 34 additions & 9 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ show_help() {
echo "[OPTION] - one or more options:"
echo " --sdl-core - path to SDL binaries"
echo " --config - name of configuration"
echo " --sdl-api - path to SDL APIs"
echo " --sdl-src - path to SDL Core"
echo " --sdl-mobile-api - path to SDL MOBILE API"
echo " --sdl-hmi-api - path to SDL HMI API"
echo " --report - path to report and logs"
echo " --sdl-log [ACTION] - how to collect SDL logs"
echo " 'yes' - always save (default), 'no' - do not save, 'fail' - save if script failed or aborted"
Expand Down Expand Up @@ -152,8 +154,14 @@ parse_arguments() {
--report)
REPORT_PATH="$ARG_VAL"
;;
--sdl-api)
SDL_API="$ARG_VAL"
--sdl-src)
SDL_SRC="$ARG_VAL"
;;
--sdl-mobile-api)
SDL_MOBILE_API="$ARG_VAL"
;;
--sdl-hmi-api)
SDL_HMI_API="$ARG_VAL"
;;
-j|--jobs)
JOBS="$ARG_VAL"
Expand Down Expand Up @@ -205,7 +213,9 @@ print_parameters() {
dbg "REPORT_PATH: "$REPORT_PATH
dbg "SDL_PROCESS_NAME: "$SDL_PROCESS_NAME
dbg "SDL_CORE: "$SDL_CORE
dbg "SDL_API: "$SDL_API
dbg "SDL_SRC: "$SDL_SRC
dbg "SDL_MOBILE_API: "$SDL_MOBILE_API
dbg "SDL_HMI_API: "$SDL_HMI_API
dbg "IS_REMOTE_ENABLED: "$IS_REMOTE_ENABLED
dbg "SAVE_SDL_LOG: "$SAVE_SDL_LOG
dbg "SAVE_SDL_CORE_DUMP: "$SAVE_SDL_CORE_DUMP
Expand Down Expand Up @@ -274,7 +284,9 @@ build_parameters() {
set_param SDL_PROCESS_NAME "config.SDL" ${CONFIG_PATH}/base_config.lua
set_param REPORT_PATH "config.reportPath" ${CONFIG_PATH}/base_config.lua
set_param SDL_CORE "config.pathToSDL" ${CONFIG_PATH}/base_config.lua
set_param SDL_API "config.pathToSDLInterfaces" ${CONFIG_PATH}/base_config.lua
set_param SDL_SRC "config.pathToSDLSource" ${CONFIG_PATH}/base_config.lua
set_param SDL_MOBILE_API "config.pathToSDLMobileInterface" ${CONFIG_PATH}/base_config.lua
set_param SDL_HMI_API "config.pathToSDLHMIInterface" ${CONFIG_PATH}/base_config.lua
set_param IS_REMOTE_ENABLED "config.remoteConnection.enabled" ${CONFIG_PATH}/connection_config.lua
print_parameters "specific config"
fi
Expand All @@ -284,7 +296,9 @@ build_parameters() {
set_param SDL_PROCESS_NAME "config.SDL" ${CONFIG_PATH}/base_config.lua
set_param REPORT_PATH "config.reportPath" ${CONFIG_PATH}/base_config.lua
set_param SDL_CORE "config.pathToSDL" ${CONFIG_PATH}/base_config.lua
set_param SDL_API "config.pathToSDLInterfaces" ${CONFIG_PATH}/base_config.lua
set_param SDL_SRC "config.pathToSDLSource" ${CONFIG_PATH}/base_config.lua
set_param SDL_MOBILE_API "config.pathToSDLMobileInterface" ${CONFIG_PATH}/base_config.lua
set_param SDL_HMI_API "config.pathToSDLHMIInterface" ${CONFIG_PATH}/base_config.lua
set_param IS_REMOTE_ENABLED "config.remoteConnection.enabled" ${CONFIG_PATH}/connection_config.lua
print_parameters "base config"

Expand All @@ -307,8 +321,16 @@ check_parameters() {
echo "Path to SDL binaries was not specified"
exit 1
fi
if [ ! -d $SDL_API ]; then
echo "Invalid path to APIs was specified"
if [ ! -d $SDL_SRC ]; then
echo "Invalid path to SDL source was specified: ${SDL_SRC}"
exit 1
fi
if [ ! -d $SDL_MOBILE_API ]; then
echo "Invalid path to MOBILE API was specified: ${SDL_MOBILE_API}"
exit 1
fi
if [ ! -d $SDL_HMI_API ]; then
echo "Invalid path to HMI API was specified: ${SDL_HMI_API}"
exit 1
fi
if [ ! -d $SDL_CORE ] && [ $IS_REMOTE_ENABLED = false ]; then
Expand All @@ -324,7 +346,9 @@ build_atf_options() {
if [ -n "$CONFIG" ]; then OPTIONS="$OPTIONS --config=${CONFIG}"; fi
if [ -n "$SDL_CORE" ]; then OPTIONS="$OPTIONS --sdl-core=${SDL_CORE}"; fi
if [ -n "$REPORT_PATH" ]; then OPTIONS="$OPTIONS --report-path=${REPORT_PATH}"; fi
if [ -n "$SDL_API" ]; then OPTIONS="$OPTIONS --sdl-interfaces=${SDL_API}"; fi
if [ -n "$SDL_SRC" ]; then OPTIONS="$OPTIONS --sdl-src=${SDL_SRC}"; fi
if [ -n "$SDL_MOBILE_API" ]; then OPTIONS="$OPTIONS --sdl-mobile-api=${SDL_MOBILE_API}"; fi
if [ -n "$SDL_HMI_API" ]; then OPTIONS="$OPTIONS --sdl-hmi-api=${SDL_HMI_API}"; fi
if [ $IS_REMOTE_ENABLED = true ] && [ $SAVE_SDL_LOG = yes ]; then OPTIONS="$OPTIONS --storeFullSDLLogs"; fi

dbg "= OPTIONS:"$OPTIONS
Expand All @@ -335,6 +359,7 @@ create_report_folder() {
dbg "Func" "create_report_folder" "Enter"
REPORT_PATH_TS=${REPORT_PATH}/$(date +"%Y-%m-%d_%H-%M-%S.%3N")
mkdir -p ${REPORT_PATH_TS}
mkdir -p /tmp/corefiles
dbg "Func" "create_report_folder" "Exit"
}

Expand Down
22 changes: 17 additions & 5 deletions tools/runners/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,23 @@ copy_sdl_logs() {
mv $SDL_LOG ${REPORT_PATH_TS_SCRIPT}/
fi
fi
if [ $SAVE_SDL_CORE_DUMP = yes ] || ( [ $SAVE_SDL_CORE_DUMP = fail ] && [ $is_script_failed == true ] ); then
local SDL_CORE_PATH="/tmp/corefiles"
if [ -d $SDL_CORE_PATH ] && [ "$(ls -A $SDL_CORE_PATH)" ]; then
mv $SDL_CORE_PATH/* ${REPORT_PATH_TS_SCRIPT}/
fi
local SDL_CORE_PATH="/tmp/corefiles"
if [ -d $SDL_CORE_PATH ] && [ "$(ls -A $SDL_CORE_PATH)" ]; then
for FILE in "$(find $SDL_CORE_PATH -type f)"; do
echo "Creating backtrace from file:" $(basename ${FILE})
gdb --batch \
-iex "cd $SDL_CORE" \
-iex "set pagination off" \
-iex "set solib-search-path ." \
-ex "info threads" \
-ex "thread apply all bt" \
$SDL_PROCESS_NAME ${FILE} &> ${REPORT_PATH_TS_SCRIPT}/Backtrace_$(basename ${FILE}).txt
if [ $SAVE_SDL_CORE_DUMP = yes ] || ( [ $SAVE_SDL_CORE_DUMP = fail ] && [ $is_script_failed == true ] ); then
mv ${FILE} ${REPORT_PATH_TS_SCRIPT}/
else
rm -f ${FILE}
fi
done
fi
}
Expand Down
24 changes: 20 additions & 4 deletions tools/runners/parallels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ _path_sdl="$SDL_CORE"
_path_atf="$ATF_PATH"
_test_result_path="$REPORT_PATH_TS"
_testfile="$TEST_TARGET"
_path_sdl_api="$SDL_API"
_path_sdl_mobile_api="$SDL_MOBILE_API"
_path_sdl_hmi_api="$SDL_HMI_API"
_path_sdl_src="$SDL_SRC"
_path_3rd_party="$THIRD_PARTY"
_save_sdl_log="$SAVE_SDL_LOG"
_save_sdl_core_dump="$SAVE_SDL_CORE_DUMP"
Expand Down Expand Up @@ -117,11 +119,25 @@ function prepare_atf {
cp -r $(realpath ./$dir) $atf_tmp_ts_dir/
done

if [ -n "$_path_sdl_api" ]; then cp $_path_sdl_api/*.xml $atf_tmp_dir/data; fi

local config_file=$atf_tmp_dir/modules/configuration/base_config.lua

if [ -n "$_path_sdl_src" ]; then
if [ -z "$_path_sdl_mobile_api" ]; then
default_mobile_api_dir=$(fgrep "config.defaultPathToMobileInterface" $config_file | sed 's/config.defaultPathToMobileInterface\s=\s"//;s/"$//')
_path_sdl_mobile_api=$(realpath "${_path_sdl_src}/${default_mobile_api_dir}")
fi
if [ -z "$_path_sdl_hmi_api" ]; then
default_hmi_api_dir=$(fgrep "config.defaultPathToHMIInterface" $config_file | sed 's/config.defaultPathToHMIInterface\s=\s"//;s/"$//')
_path_sdl_hmi_api=$(realpath "${_path_sdl_src}/${default_hmi_api_dir}")
fi
sed -i '/^config.pathToSDLSource\ =/c\config.pathToSDLSource=""' $config_file
fi
if [ -n "$_path_sdl_mobile_api" ]; then cp $_path_sdl_mobile_api/*.xml $atf_tmp_dir/data; fi
if [ -n "$_path_sdl_hmi_api" ]; then cp $_path_sdl_hmi_api/*.xml $atf_tmp_dir/data; fi

sed -i '/^config.pathToSDL\ =/c\config.pathToSDL="/home/developer/sdl/bin"' $config_file
sed -i '/^config.pathToSDLInterfaces\ =/c\config.pathToSDLInterfaces="/home/developer/sdl/atf/data"' $config_file
sed -i '/^config.pathToSDLMobileInterface\ =/c\config.pathToSDLMobileInterface="/home/developer/sdl/atf/data"' $config_file
sed -i '/^config.pathToSDLHMIInterface\ =/c\config.pathToSDLHMIInterface="/home/developer/sdl/atf/data"' $config_file
sed -i '/^config.reportPath\ =/c\config.reportPath="/home/developer/sdl/TestingReports"' $config_file
}

Expand Down

0 comments on commit 2040ca3

Please sign in to comment.