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
srinivasgtl authored and Bhanu Prakash committed Dec 17, 2024
1 parent 797aca3 commit 329c86f
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 52 deletions.
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"args": [ "--config", "example_rack_config.yml",
"--deviceConfig", "deviceConfig.yml"],
"console": "integratedTerminal"
},
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"stopAtEntry": false,
"externalConsole": false,
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/bin/hal_test",
"environment": [ {"name": "LD_LIBRARY_PATH", "value":"${workspaceFolder}/bin/"} ],
"args": [ "-l", "${workspaceFolder}/logs/", "-p", "${workspaceFolder}/profiles/sink/Sink_AudioSettings.yaml" ],
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
29 changes: 16 additions & 13 deletions host/tests/classes/hdmiCEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def __init__(self, moduleConfigProfileFile :str, session=None, targetWorkspace="
None
"""
self.moduleName = "hdmiCEC"
self.testConfigFile = os:.path.join(dir_path, "hdmiCEC_testConfig.yml")
self.testSuite = "L3 hdmicec - Sink"
self.testConfigFile = os.path.join(dir_path, "hdmiCEC_testConfig.yml")
self.testSuite = "L3 HDMICEC Sink Functions"

# Load configurations for device profile and menu
self.moduleConfigProfile = ConfigRead( moduleConfigProfileFile , self.moduleName)
Expand Down Expand Up @@ -146,7 +146,7 @@ def removeLogicalAddress(self, logicalAddress:int):
Remove logical address.
Args:
logicalAddress (int): The Logical address of the DUT that should be removed.
logicalAddress (int): The Logical address of the DUT that should be removed.
Returns:
None
Expand Down Expand Up @@ -190,8 +190,6 @@ 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:[.*\]"
physicalAddress = self.searchPattern(result, typeStatusPattern)
Expand All @@ -200,7 +198,7 @@ def getPhysicalAddress(self):

def cecTransmitCmd(self, sourceLogicalAddress:int, destLogicalAddress:int, cecCommand:int, cecData:list=None):
"""
Transmit/Broadcast the CEC command and data to the respective destination.
Transmit/Broadcast the CEC command and data to the respective destination.
Args:
None.
Expand Down Expand Up @@ -233,8 +231,8 @@ def cecTransmitCmd(self, sourceLogicalAddress:int, destLogicalAddress:int, cecCo
{
"query_type": "direct",
"query": "Enter Databyte",
"input": str(byte)
})
"input": str(byte)
})

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

Expand All @@ -257,16 +255,21 @@ def __del__(self):
shell = InteractiveShell()
shell.open()

platformProfile = dir_path + "/../../../profiles/sink/Sink_AudioSettings.yaml"
platformProfile = dir_path + "/../../../profiles/sink/sink_hdmiCEC.yaml"

# test the class assuming that it's optional
test = dsAudioClass(platformProfile, shell)
test = hdmiCECClass(platformProfile, shell)

# Initialize the hdmiCEC module
test.initialise()
ports = test.getSupportedPorts()

test.enablePort(ports[0][0], ports[0][1])
test.disablePort(ports[0][0], ports[0][1])
# Add the logical Address. For now 0 only.
test.addLogicalAddress(0)

# Get Physical Address
physicalAddress = test.getPhysicalAddress()

# Close the device
test.terminate()

shell.close()
9 changes: 5 additions & 4 deletions host/tests/hdmiCEC_L3_Tests/hdmiCECHelperClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@

dir_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(dir_path, "../../"))
sys.path.append(os.path.join(dir_path, "../"))

from raft.framework.plugins.ut_raft.configRead import ConfigRead
from raft.framework.plugins.ut_raft.utUserResponse import utUserResponse
from raft.framework.plugins.ut_raft import utHelperClass
from raft.framework.core.logModule import logModule
from classes.hdmCEC import hdmiCECClass
from classes.hdmiCEC import hdmiCECClass

class hdmiCECHelperClass(utHelperClass):

Expand All @@ -45,7 +46,7 @@ def __init__(self, testName:str, qcId:str, log:logModule=None ):
log (class, optional): Parent log class. Defaults to None.
"""
self.testName = ""
self.testSetupPath = os.path.join(dir_path, "hdmiCEC__L3_testSetup.yml")
self.testSetupPath = os.path.join(dir_path, "hdmiCEC_L3_testSetup.yml")
self.moduleName = "hdmiCEC"
self.rackDevice = "dut"

Expand Down Expand Up @@ -130,7 +131,7 @@ def testPrepareFunction(self):


# Run Prerequisites listed in the test setup configuration file
self.testRunPrerequisites()
#self.testRunPrerequisites()

# Create the hdmiCEC class
self.testhdmiCEC = hdmiCECClass(self.moduleConfigProfileFile, self.hal_session, self.targetWorkspace)
Expand All @@ -139,7 +140,7 @@ def testPrepareFunction(self):

def testEndFunction(self, powerOff=True):
# Clean the assets downloaded to the device
self.testCleanAssets()
#self.testCleanAssets()

# Clean up the hdmiCEC instance
del self.testhdmiCEC
Expand Down
14 changes: 14 additions & 0 deletions host/tests/hdmiCEC_L3_Tests/hdmiCECTestCommands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
hdmiCEC:
test01_TransmitSingleStandbyCommandandValidateAck:
- command: "0x36" # Standby
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
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"
4 changes: 0 additions & 4 deletions host/tests/hdmiCEC_L3_Tests/hdmiCEC_L3_testSetup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ hdmiCEC: # Prefix must always exist
assets:
device:
test01_TransmitSingleStandbyCommandandValidateAck:
<<: *defaults
test02_BroadcastStandbyCommand:
<<: *defaults
test03_TransmitOSDCommandandValidateAck:
<<: *defaults
test04_TransmitLargerOSDCommandRepeatedlyandValidate:
<<: *defaults
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from hdmiCECHelperClass import hdmiCECHelperClass
from raft.framework.core.logModule import logModule
from raft.framework.plugins.ut_raft.configRead import ConfigRead

class hdmiCEC_test01_TransmitSingleStandbyCommandandValidateAck(hdmiCECHelperClass):
"""
Expand All @@ -50,14 +51,21 @@ def __init__(self, log:logModule=None):
self.testName = "test01_TransmitSingleStanbyCommandandValidateAck"
self.qcID = '1'

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
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:
Expand All @@ -69,7 +77,7 @@ def testVerifyStanbyStatus(self, ack, manual=False):
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 {port}? (Y/N):")
return self.testUserResponse.getUserYN(f"Is Stanby Command honored? (Y/N):")
else :
#TODO: Add automation verification methods
return False
Expand All @@ -79,7 +87,7 @@ def testFunction(self):
The main test function that Transmits the Stanby Command and checks the ACK and validates it.
This function:
- Send a standby command to a device that is connected on the CEC network and get the ack.
- Send a standby command to a device that is connected on the CEC network and get the ack.
- User to confirm whether the targetted device had recieved this command or not.
Returns:
Expand All @@ -89,17 +97,36 @@ def testFunction(self):
# Initialize the hdmiCEC module
self.testhdmiCEC.initialise()

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

# Transmit Standby command to a specific destination address
self.testhdmiCEC.cecTransmitCmd(0,3,65,[0])
self.cecDevices = [1,2,3]#self.cecAdapter.listDevices()

#Verify the test result
result = self.testVerifyStandbyStatus(ack, True)
for device in self.cecDevices:
logicalAddress = 1#int(device["address"].split('.')[0])

# Remove the Logical Address
self.testhdmiCEC.removeLogicalAddress(0)
# 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()

#Verify the test result
result = self.testVerifyStanbyStatus(logicalAddress, True)

self.log.stepResult()

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

# Terminate dsAudio Module
self.testdsAudio.terminate()
Expand Down
26 changes: 5 additions & 21 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,36 +113,20 @@ int main(int argc, char** argv)
}
optind = 1; //Reset argv[] element pointer for further processing
#endif

/* Register tests as required, then call the UT-main to support switches and triggering */
UT_init( argc, argv );

status = ut_kvp_getStringField(ut_kvp_profile_getInstance(), "hdmicec/type", szReturnedString, UT_KVP_MAX_ELEMENT_SIZE);
if (status == UT_KVP_STATUS_SUCCESS ) {
UT_LOG_DEBUG("Device Type: %s", szReturnedString);
}
else {
UT_LOG_ERROR("Failed to get the platform Device Type");
return -1;
}

register_hdmicec_hal_common_l1_tests();
#ifdef VCOMPONENT
register_vcomponent_tests(pProfilePath);
test_l3_hdmi_cec_driver_register (pValidationProfilePath);
#endif

if(strncmp(szReturnedString,"source",UT_KVP_MAX_ELEMENT_SIZE) == 0) {
register_hdmicec_hal_source_l1_tests ();
register_hdmicec_hal_source_l2_tests ();
}

if(strncmp(szReturnedString,"sink",UT_KVP_MAX_ELEMENT_SIZE) == 0) {
register_hdmicec_hal_sink_l1_tests ();
register_hdmicec_hal_sink_l2_tests ();
register_hdmicec_hal_source_l1_tests ();
register_hdmicec_hal_source_l2_tests ();
register_hdmicec_hal_sink_l1_tests ();
register_hdmicec_hal_sink_l2_tests ();
register_hdmicec_hal_sink_l3_tests ();
}

UT_run_tests();

#ifdef VCOMPONENT
Expand Down

0 comments on commit 329c86f

Please sign in to comment.