Skip to content

Commit

Permalink
Merge pull request #179 from smartdevicelink/develop
Browse files Browse the repository at this point in the history
Release 6.0.0
  • Loading branch information
ShobhitAd authored Oct 30, 2019
2 parents 6e52740 + 37da7ab commit e7b44f3
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 57 deletions.
10 changes: 9 additions & 1 deletion modules/SDL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,15 @@ local function updateSDLLogProperties()
},
{
name = "log4j.appender.TelnetLogging.layout.ConversionPattern",
value = "%%-5p [%%d{yyyy-MM-dd HH-mm:ss,SSS}][%%t][%%c] %%F:%%L %%M: %%m"
value = "%%-5p [%%d{yyyy-MM-dd HH:mm:ss,SSS}][%%t][%%c] %%F:%%L %%M: %%m"
},
{
name = "log4j.appender.TransportManagerLogFile",
value = "SafeFileAppender\nlog4j.appender.TransportManagerLogFile.Threshold=OFF"
},
{
name = "log4j.appender.ProtocolFordHandlingLogFile",
value = "SafeFileAppender\nlog4j.appender.ProtocolFordHandlingLogFile.Threshold=OFF"
}
}

Expand Down
16 changes: 7 additions & 9 deletions modules/atf_logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ local controlMessagesHB = {}
controlMessagesHB[ford_constants.FRAME_INFO.HEARTBEAT] = "Heartbeat"
controlMessagesHB[ford_constants.FRAME_INFO.HEARTBEAT_ACK] = "HeartbeatACK"

Logger.mobile_log_format = "%s (%s) [%s, sessionId: %s, version: %s, frameType: %s, "
.. "encryption: %s, serviceType: %s, frameInfo: %s, messageId: %s, binaryDataSize: %s] : %s \n"
Logger.hmi_log_format = "%s (%s) : %s \n"
Logger.mobile_log_format = "%s [%s] [%s, sessionId: %s, version: %s, frameType: %s, "
.. "encryption: %s, serviceType: %s, frameInfo: %s, messageId: %s, binaryDataSize: %s] : %s \n\n"
Logger.hmi_log_format = "%s [%s] %s \n"

local rpc_function_id

Expand Down Expand Up @@ -93,7 +93,7 @@ function Logger.formated_time(without_date)
if without_date == true then
return qdatetime.get_datetime("hh:mm:ss,zzz")
end
return qdatetime.get_datetime("dd MM yyyy hh:mm:ss, zzz")
return qdatetime.get_datetime("dd-MM-yyyy hh:mm:ss,zzz")
end

--- Check message is it HMI tract
Expand Down Expand Up @@ -123,7 +123,7 @@ end
-- @tparam string tract Tract information
-- @tparam string message String representation of message from mobile application to SDL
function Logger:MOBtoSDL(tract, message)
local log_str = string.format(Logger.mobile_log_format,"MOB->SDL ", Logger.formated_time(),
local log_str = string.format(Logger.mobile_log_format,"MOB->SDL", Logger.formated_time(),
get_function_name(message), message.sessionId, message.version, message.frameType,
message.encryption, message.serviceType, message.frameInfo, message.messageId, getBinaryDataSize(message.binaryData), message.payload)
if is_hmi_tract(tract, message) then
Expand Down Expand Up @@ -167,7 +167,7 @@ end
-- @tparam string tract Tract information
-- @tparam string message String representation of message from HMI to SDL
function Logger:HMItoSDL(tract, message)
local log_str = string.format(Logger.hmi_log_format, "HMI->SDL", Logger.formated_time(), message)
local log_str = string.format(Logger.hmi_log_format, "HMI->SDL", Logger.formated_time(), message .. "\n")
if is_hmi_tract(tract, message) then
self.atf_log_file:write(log_str)
end
Expand Down Expand Up @@ -244,18 +244,16 @@ function Logger.init_log(script_name)
return Logger
end

--- Store auxiliary message about start of new test step of test scenario into ATF log file (only if `config.excludeReport` is set to `false`)
--- Store auxiliary message about start of new test step of test scenario into ATF log file
-- @tparam string test_case Test step name
function Logger.LOGTestCaseStart(test_case)
if config.excludeReport then return end
Logger:StartTestCase(test_case)
end

--- Store message on baasis on tract information into ATF log file
-- @tparam string tract Tract information
-- @tparam string message String representation of message
function Logger.LOG(tract, message)
if config.excludeReport then return end
Logger[tract](Logger, tract, message)
end

Expand Down
22 changes: 11 additions & 11 deletions modules/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ config.ShowTimeInConsole = true
--- Flag which defines whether ATF performs validation of Mobile and HMI messages by API
config.ValidateSchema = true
--- Flag which defines whether ATF ignores collecting of reports
config.excludeReport = false
config.excludeReport = true
--- Flag which defines whether ATF creates full ATF logs (with json files and service messages)
config.storeFullATFLogs = true
--- Flag which defines whether ATF stores full SDLCore logs
Expand All @@ -86,8 +86,8 @@ config.application1 =
{
syncMsgVersion =
{
majorVersion = 5,
minorVersion = 1
majorVersion = 6,
minorVersion = 0
},
appName = "Test Application",
isMediaApplication = true,
Expand All @@ -114,8 +114,8 @@ config.application2 =
{
syncMsgVersion =
{
majorVersion = 5,
minorVersion = 1
majorVersion = 6,
minorVersion = 0
},
appName = "Test Application2",
isMediaApplication = true,
Expand All @@ -142,8 +142,8 @@ config.application3 =
{
syncMsgVersion =
{
majorVersion = 5,
minorVersion = 1
majorVersion = 6,
minorVersion = 0
},
appName = "Test Application3",
isMediaApplication = true,
Expand All @@ -170,8 +170,8 @@ config.application4 =
{
syncMsgVersion =
{
majorVersion = 5,
minorVersion = 1
majorVersion = 6,
minorVersion = 0
},
appName = "Test Application4",
isMediaApplication = true,
Expand All @@ -198,8 +198,8 @@ config.application5 =
{
syncMsgVersion =
{
majorVersion = 5,
minorVersion = 1
majorVersion = 6,
minorVersion = 0
},
appName = "Test Application5",
isMediaApplication = true,
Expand Down
6 changes: 5 additions & 1 deletion modules/expectations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ function Expectations.Expectation(name, connection)
else
error("Expectation:Times() must be called with number or Cardinality argument")
end
if self.timesLE == 0 and self.timesGE == 0 then
self.isDelayNeedsToBeApplied = true
end
return self
end

Expand Down Expand Up @@ -170,7 +173,8 @@ function Expectations.Expectation(name, connection)
actions = { }, -- Sequence of actions to be executed when complied
pinned = false, -- True if the expectation is pinned
list = nil, -- ExpectationsList the expectation belongs to
isAtLeastOneFail = false -- True if at least one validation fails
isAtLeastOneFail = false, -- True if at least one validation fails
isDelayNeedsToBeApplied = false -- True if delay for zero occurrence expectation needs to be applied
}

setmetatable(e, mt)
Expand Down
1 change: 1 addition & 0 deletions modules/mobile_session_impl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ function mt.__index:StopRPC()
return ret
:Do(function(_, _)
self.security:unregisterAllSecureServices()
self.security:unregisterSessionSecurity()
end)
end

Expand Down
22 changes: 12 additions & 10 deletions modules/protocol_handler/protocol_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function ProtocolHandler.ProtocolHandler()
local ret =
{
buffer = "",
frames = { }
frames = { },
totalSize = { }
}
setmetatable(ret, mt)
return ret
Expand Down Expand Up @@ -276,24 +277,25 @@ function mt.__index:Parse(binary, validateJson, frameHandler)
or msg._technical.decryptionStatus == securityConstants.SECURITY_STATUS.ERROR then
table.insert(res, msg)
else
local key = "s"..msg.sessionId.."m"..msg.messageId
if msg.frameType == constants.FRAME_TYPE.CONTROL_FRAME then
table.insert(res, msg)
elseif msg.frameType == constants.FRAME_TYPE.FIRST_FRAME then
self.frames[msg.messageId] = ""
self.totalSize = msg.size
self.frames[key] = ""
self.totalSize[key] = msg.size
elseif msg.frameType == constants.FRAME_TYPE.SINGLE_FRAME then
if isBinaryDataHasHeader(msg) then
parseBinaryHeader(msg, validateJson)
end
table.insert(res, msg)
elseif msg.frameType == constants.FRAME_TYPE.CONSECUTIVE_FRAME then
self.frames[msg.messageId] = self.frames[msg.messageId] .. msg.binaryData
self.totalSize = self.totalSize + msg.size
self.frames[key] = self.frames[key] .. msg.binaryData
self.totalSize[key] = self.totalSize[key] + msg.size
if msg.frameInfo == constants.FRAME_INFO.LAST_FRAME then
msg.binaryData = self.frames[msg.messageId]
msg.size = self.totalSize
self.frames[msg.messageId] = nil
self.totalSize = nil
msg.binaryData = self.frames[key]
msg.size = self.totalSize[key]
self.frames[key] = nil
self.totalSize[key] = nil
if isBinaryDataHasHeader(msg) then
parseBinaryHeader(msg, validateJson)
end
Expand Down Expand Up @@ -369,7 +371,7 @@ function mt.__index:Compose(message)
-- Create message firstframe
local firstFrameMessage = {
version = message.version,
encryption = message.encryption,
encryption = false, -- 1st frame has to be always unencrypted
frameType = constants.FRAME_TYPE.FIRST_FRAME,
serviceType = message.serviceType,
frameInfo = 0,
Expand Down
4 changes: 4 additions & 0 deletions modules/security/security_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ function security_mt.__index:registerSessionSecurity()
end
end

function security_mt.__index:unregisterSessionSecurity()
SecurityManager.mobileSecurities[self.session.sessionId.get()] = nil
end

--- Register service into mobile session security. Service assumed as secure
-- @tparam number service Service number
function security_mt.__index:registerSecureService(service)
Expand Down
46 changes: 21 additions & 25 deletions modules/testbase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,7 @@ function control.runNextCase()
end
atf_logger.LOGTestCaseStart(Test.current_case_name)
testcase(Test)
--- Perform delay for the time defined in 'zeroOccurrenceTimeout' configuration parameter
-- Create expectation on a custom event and then raise this event after timeout
-- @tparam Connection pConnection Network connection (Mobile or HMI)
local function wait(pConnection)
local timeout = config.zeroOccurrenceTimeout
local event = events.Event()
event.level = 3
event.matches = function(event1, event2) return event1 == event2 end

local ret = Expectation("Wait", pConnection)
ret.event = event
ret:Timeout(timeout + 5000)
event_dispatcher:AddEvent(pConnection, event, ret)
Test:AddExpectation(ret)
--- Raise an event
local function toRun()
event_dispatcher:RaiseEvent(pConnection, event)
end
Test:RunAfter(toRun, timeout)
end

for _, v in Test.expectations_list:List() do
if v.timesLE == 0 and v.timesGE == 0 then
wait(v.connection)
end
end

else
if SDL.autoStarted then
Expand Down Expand Up @@ -203,6 +178,27 @@ local function CheckStatus()
critical(SDL.exitOnCrash)
SDL:DeleteFile()
end
--- Perform delay for the time defined in 'zeroOccurrenceTimeout' configuration parameter
-- Create expectation on a custom event and then raise this event after timeout
-- @tparam Connection pConnection Network connection (Mobile or HMI)
local function wait(pConnection)
local timeout = config.zeroOccurrenceTimeout
local event = events.Event()
event.level = 3
event.matches = function(event1, event2) return event1 == event2 end
local ret = Expectation("Wait", pConnection)
ret.event = event
ret:Timeout(timeout + 5000)
event_dispatcher:AddEvent(pConnection, event, ret)
Test:AddExpectation(ret)
Test:RunAfter(function() event_dispatcher:RaiseEvent(pConnection, event) end, timeout)
end
for _, v in Test.expectations_list:List() do
if v.isDelayNeedsToBeApplied then
v.isDelayNeedsToBeApplied = false
wait(v.connection)
end
end
if Test.expectations_list:Any(function(e) return not e.status end) then return end
for _, e in ipairs(Test.expectations_list) do
if e.status ~= SUCCESS then
Expand Down

0 comments on commit e7b44f3

Please sign in to comment.