Skip to content

Commit

Permalink
gh #44 Updated test cases to use cec adaptor
Browse files Browse the repository at this point in the history
  • Loading branch information
bhanucbp committed Dec 9, 2024
1 parent e6f055c commit 376d8f2
Show file tree
Hide file tree
Showing 9 changed files with 599 additions and 430 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ export HAL_LIB_DIR
build: $(SETUP_SKELETON_LIBS)
echo "SETUP_SKELETON_LIBS $(SETUP_SKELETON_LIBS)"
@echo UT [$@]
make -C ./ut-core framework
make -C ./ut-core test

make -C ./ut-core TARGET=${TARGET}
rm -rf $(BIN_DIR)/lib$(HAL_LIB).so
rm -rf $(ROOT_DIR)/libs/lib$(HAL_LIB).so
#Build against the real library leads to the SOC library dependency also.SOC lib dependency cannot be specified in the ut Makefile, since it is supposed to be common across may platforms. So in order to over come this situation, creating a template skelton library with empty templates so that the template library wont have any other Soc dependency. And in the real platform mount copy bind with the actual library will work fine.
skeleton:
echo $(CC)
Expand Down
45 changes: 13 additions & 32 deletions host/tests/classes/hdmiCEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, moduleConfigProfileFile :str, session=None, targetWorkspace="
Returns:
None
"""
self.moduleName = "hdmiCEC"
self.moduleName = "hdmicec"
self.testConfigFile = os.path.join(dir_path, "hdmiCEC_testConfig.yml")
self.testSuite = "L3 HDMICEC Sink Functions"

Expand Down Expand Up @@ -105,7 +105,7 @@ def initialise(self):
Returns:
None
"""
result = self.utMenu.select( self.testSuite, "L3_Init_HdmiCec")
result = self.utMenu.select( self.testSuite, "Init HDMI CEC")

def terminate(self):
"""
Expand All @@ -117,7 +117,7 @@ def terminate(self):
Returns:
None
"""
result = self.utMenu.select(self.testSuite, "L3_Close_HdmiCec_Sink")
result = self.utMenu.select(self.testSuite, "Close HDMI CEC")

def addLogicalAddress(self, logicalAddress:int):
"""
Expand All @@ -137,11 +137,9 @@ def addLogicalAddress(self, logicalAddress:int):
"input": str(logicalAddress)
}
]
result = self.utMenu.select(self.testSuite, "Add Logical Address", promptWithAnswers)


result = self.utMenu.select(self.testSuite, "L3_AddLogicalAddress", promptWithAnswers)

def removeLogicalAddress(self, logicalAddress:int):
def removeLogicalAddress(self):
"""
Remove logical address.
Expand All @@ -151,17 +149,7 @@ def removeLogicalAddress(self, logicalAddress:int):
Returns:
None
"""
promptWithAnswers = [
{
"query_type": "direct",
"query": "Enter Logical Address to Remove:",
"input": str(logicalAddress)
}
]

result = self.utMenu.select(self.testSuite, "L3_RemoveLogicalAddressHdmiCec_Sink", promptWithAnswers)


result = self.utMenu.select(self.testSuite, "Remove Logical Address")

def getLogicalAddress(self):
"""
Expand All @@ -173,13 +161,12 @@ def getLogicalAddress(self):
Returns:
int: Logical address of the device.
"""
result = self.utMenu.select( self.testSuite, "L3_GetLogicalAddress")
connectionStatusPattern = r"HdmiCecGetLogicalAddress\(IN: handle: [.*\], OUT: logicalAddress: [.*\]), status: [.*\])"
result = self.utMenu.select( self.testSuite, "Get Logical Address")
connectionStatusPattern = r"Result HdmiCecGetLogicalAddress\(IN:handle:[.*\], OUT:logicalAddress:[.*\]) HDMI_CEC_STATUS:[.*\])"
logicalAddress = self.searchPattern(result, connectionStatusPattern)

return logicalAddress


def getPhysicalAddress(self):
"""
Retrieve the Physical Address of the DUT.
Expand All @@ -190,13 +177,13 @@ def getPhysicalAddress(self):
Returns:
int: Physical Address of the DUT.
"""
result = self.utMenu.select( self.testSuite, "L3_GetPhyiscalAddress")
typeStatusPattern = r"HdmiCecGetPhysicalAddress\(IN: handle: [.*\], physicalAddress: [.*\]), status:[.*\]"
result = self.utMenu.select( self.testSuite, "Get Phyiscal Address")
typeStatusPattern = r"Result HdmiCecGetPhysicalAddress\(IN:handle:[.*\], OUT:physicalAddress:[.*\]) HDMI_CEC_STATUS:[.*\]"
physicalAddress = self.searchPattern(result, typeStatusPattern)

return physicalAddress

def cecTransmitCmd(self, sourceLogicalAddress:int, destLogicalAddress:int, cecCommand:int, cecData:list=None):
def cecTransmitCmd(self, destLogicalAddress:int, cecCommand:int, cecData:list=None):
"""
Transmit/Broadcast the CEC command and data to the respective destination.
Expand All @@ -208,19 +195,14 @@ def cecTransmitCmd(self, sourceLogicalAddress:int, destLogicalAddress:int, cecCo
"""

promptWithAnswers = [
{
"query_type": "direct",
"query": "Enter a valid Source Logical Address:",
"input": str(sourceLogicalAddress)
},
{
"query_type": "direct",
"query": "Enter a valid Destination Logical Address:",
"input": str(destLogicalAddress)
},
{
"query_type": "direct",
"query": "Enter CEC Command:",
"query": "Enter CEC Command (in hex):",
"input": str(cecCommand)
},
]
Expand All @@ -234,8 +216,7 @@ def cecTransmitCmd(self, sourceLogicalAddress:int, destLogicalAddress:int, cecCo
"input": str(byte)
})

result = self.utMenu.select( self.testSuite, "L3_TransmitCecCommand",promptWithAnswers)

result = self.utMenu.select( self.testSuite, "Transmit CEC Command",promptWithAnswers)

def __del__(self):
"""
Expand Down
17 changes: 8 additions & 9 deletions host/tests/classes/hdmiCEC_testConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# * limitations under the License.
# *
#* ******************************************************************************
hdmiCEC:
hdmicec:
description: "hdmi CEC testing profile / menu system for UT"
test:
artifacts:
Expand Down Expand Up @@ -56,11 +56,10 @@ hdmiCEC:
2:
name: "L3 hdmicec - Sink"
tests:
- "L3_Init_HdmiCec"
- "L3_AddLogicalAddress"
- "L3_GetLogicalAddress"
- "L3_TransmitCecCommand"
- "L3_ReceiveCecCommand"
- "L3_GetPhyiscalAddress"
- "L3_RemoveLogicalAddressHdmiCec_Sink"
- "L3_Close_HdmiCec_Sink"
- "Init HDMI CEC"
- "Add Logical Address"
- "Get Logical Address"
- "Transmit CEC Command"
- "Get Phyiscal Address"
- "Remove Logical Address"
- "Close HDMI CEC"
2 changes: 1 addition & 1 deletion host/tests/hdmiCEC_L3_Tests/hdmiCECHelperClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, testName:str, qcId:str, log:logModule=None ):
"""
self.testName = ""
self.testSetupPath = os.path.join(dir_path, "hdmiCEC_L3_testSetup.yml")
self.moduleName = "hdmiCEC"
self.moduleName = "hdmicec"
self.rackDevice = "dut"

super().__init__(testName, qcId, log)
Expand Down
21 changes: 11 additions & 10 deletions host/tests/hdmiCEC_L3_Tests/hdmiCECTestCommands.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
hdmiCEC:
test01_TransmitSingleStandbyCommandandValidateAck:
test01_TransmitCECCommands:
- command: "0x04" # Image View on
payload:
responses:
- command: "0x36" # Standby
payload:
responses:
- type: "power_status"
loop_devices: true # Apply this response to all devices in the device map
payload: "[:sender]:90:[:power_status]" # Response pattern with placeholders
description: "Devices report their power status"
- command: "0x8F" # Request Power Status
- command: "0x9F" # Get CEC version
payload:
responses:
- type: "power_status_response"
loop_devices: true # Apply this response to all devices in the device map
payload: "[:sender]:90:[:power_status]" # Response pattern with placeholders
description: "Devices respond with their current power status"
- type: "Get CEC Version"
loop_devices: false # Apply this response to all devices in the device map
payload: "" # Response pattern with placeholders
description: "Device request for CEC version"
2 changes: 1 addition & 1 deletion host/tests/hdmiCEC_L3_Tests/hdmiCEC_L3_testSetup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#* ******************************************************************************


hdmiCEC: # Prefix must always exist
hdmicec: # Prefix must always exist
description: "hdmiCEC test setup"
assets:
device:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from raft.framework.core.logModule import logModule
from raft.framework.plugins.ut_raft.configRead import ConfigRead

class hdmiCEC_test01_TransmitSingleStandbyCommandandValidateAck(hdmiCECHelperClass):
class hdmiCEC_test01_TransmitCECCommands(hdmiCECHelperClass):
"""
Test class to enable, disable, and verify the status of audio ports on a device.
Expand All @@ -48,39 +48,15 @@ def __init__(self, log:logModule=None):
None
"""
# Class variables
self.testName = "test01_TransmitSingleStanbyCommandandValidateAck"
self.testName = "test01_TransmitCECCommands"
self.qcID = '1'
self.sourceLogicalAddress = 0

self.testCECCommands = os.path.join(dir_path, "hdmiCECTestCommands.yml")
hdmicec = ConfigRead(self.testCECCommands, "hdmiCEC")
self.cecCommands = hdmicec.fields.get("test01_TransmitSingleStandbyCommandandValidateAck")
for command in self.cecCommands:
cec = command.get("command")
payload = command.get("payload")
print(cec, payload)
super().__init__(self.testName, self.qcID, log)

#TODO: Current version supports only manual verification.
def testVerifyStanbyStatus(self, ack, manual=False):
"""
Verifies the CEC Transmit Status through the result and also through the manual input.
For manual verification, it prompts the user to confirm if CEC data is received by the destination
device and the action has been performed.
Args:
ack(str): Ack result as printed on the test. Need to check that proper ACK is received.
(bool, optional): Flag to indicate if manual verification should be used.
Defaults to False for automation, True for manual.
self.cecCommands = hdmicec.fields.get(self.testName)

Returns:
bool: True if ACK verification succeeds, False otherwise.Also True if Manual test is Y and Flase if N
"""
if manual == True:
return self.testUserResponse.getUserYN(f"Is Stanby Command honored? (Y/N):")
else :
#TODO: Add automation verification methods
return False
super().__init__(self.testName, self.qcID, log)

def testFunction(self):
"""
Expand All @@ -97,44 +73,41 @@ def testFunction(self):
# Initialize the hdmiCEC module
self.testhdmiCEC.initialise()

# Add the logical Address. For now 0 only.
self.testhdmiCEC.addLogicalAddress(0)
# Add the logical Address.
self.testhdmiCEC.addLogicalAddress(self.sourceLogicalAddress)

self.cecDevices = [1,2,3]#self.cecAdapter.listDevices()
self.cecDevices = self.cecAdapter.listDevices()

for device in self.cecDevices:
logicalAddress = 1#int(device["address"].split('.')[0])
logicalAddress = device["logical address"]

# To bypass sending the message to TV
if logicalAddress == 0 or logicalAddress == 14:
continue

# self.log.stepStart(f'HdmiCecTx(IN: handle: [0x%0X], IN: length: [%d], result: [%d], status:[%d]')

for command in self.cecCommands:
cec = command.get("command")
payload = command.get("payload")
#result = self.cecAdapter.startMonitoring()
#print(result)

# Transmit Standby command to a specific destination address
self.testhdmiCEC.cecTransmitCmd(0, logicalAddress,cec,payload)
#self.cecAdapter.stopMonitoring()
self.testhdmiCEC.cecTransmitCmd(logicalAddress, cec, payload)

self.log.stepStart(f'HdmiCecTx Source: {self.sourceLogicalAddress} Destination: {logicalAddress} CEC OPCode: {cec} Payload: {payload}')

#Verify the test result
result = self.testVerifyStanbyStatus(logicalAddress, True)
result = self.cecAdapter.checkTransmitStatus(self.sourceLogicalAddress, logicalAddress, cec, payload)

self.log.stepResult()
self.log.stepResult(result, f'HdmiCecTx Source: {self.sourceLogicalAddress} Destination: {logicalAddress} CEC OPCode: {cec} Payload: {payload}')

# Remove the Logical Address
self.testhdmiCEC.removeLogicalAddress(0)
# Remove the Logical Address
self.testhdmiCEC.removeLogicalAddress()

# Terminate dsAudio Module
self.testdsAudio.terminate()
self.testhdmiCEC.terminate()

return result

if __name__ == '__main__':
summerLogName = os.path.splitext(os.path.basename(__file__))[0] + "_summery"
summeryLog = logModule(summerLogName, level=logModule.INFO)
test = hdmiCEC_test01_TransmitSingleStandbyCommandandValidateAck(summeryLog)
test = hdmiCEC_test01_TransmitCECCommands(summeryLog)
test.run(False)
Loading

0 comments on commit 376d8f2

Please sign in to comment.