Skip to content

Commit

Permalink
gh #44 L3 test case development
Browse files Browse the repository at this point in the history
Added python file to run all tests
Used monitor function to get the adaptor logs
  • Loading branch information
bhanucbp committed Dec 12, 2024
1 parent 743bc49 commit 2104b00
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 35 deletions.
7 changes: 2 additions & 5 deletions host/tests/hdmiCEC_L3_Tests/hdmiCECHelperClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,12 @@ def __init__(self, testName:str, qcId:str, log:logModule=None ):
log (logModule, optional): Parent log module instance for logging. Defaults to None.
"""
self.testName = ""
self.testSetupPath = os.path.join(dir_path, "hdmiCEC_L3_testSetup.yml")
self.moduleName = "hdmicec"
self.rackDevice = "dut"

# Initialize the base helper class
super().__init__(testName, qcId, log)

# Load test setup configuration
self.testSetup = ConfigRead(self.testSetupPath, self.moduleName)

# Open Sessions hal test
self.hal_session = self.dut.getConsoleSession("ssh_hal_test")

Expand All @@ -80,7 +76,6 @@ def __init__(self, testName:str, qcId:str, log:logModule=None ):
self.testCECCommands = os.path.join(dir_path, "hdmiCECTestCommands.yml")
hdmicec = ConfigRead(self.testCECCommands, self.moduleName)
self.cecCommands = hdmicec.fields.get(self.testName)
self.hdmiCECController = self.dut.hdmiCECController

def testPrepareFunction(self):
"""
Expand All @@ -100,5 +95,7 @@ def testPrepareFunction(self):

def testEndFunction(self, powerOff=True):

super().testEndFunction(powerOff)
# Clean up the hdmiCEC instance
del self.testhdmiCEC

73 changes: 73 additions & 0 deletions host/tests/hdmiCEC_L3_Tests/hdmiCEC_L3_Runall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python3
#** *****************************************************************************
# *
# * If not stated otherwise in this file or this component's LICENSE file the
# * following copyright and licenses apply:
# *
# * Copyright 2024 RDK Management
# *
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# * You may obtain a copy of the License at
# *
# *
# http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *
#* ******************************************************************************

import os
import sys
import importlib
from pathlib import Path

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, "../"))
sys.path.append(os.path.join(dir_path, "../raft"))

from raft.framework.core.logModule import logModule

def Runall_L3():
skipTests = []
# Summery log for all the tests
hdmiCECSummerLog = logModule("hdmiCEC_Sink", level=logModule.INFO)

testDirectory = Path(dir_path)

# Find all test modules in the directory
test_modules = sorted(testDirectory.glob("hdmiCEC_test*.py"))

# Run each test by dynamically importing and instantiating
for test_module_path in test_modules:
# Construct module name from file name, excluding .py extension
module_name = test_module_path.stem
skip = False
for skipTest in skipTests:
if skipTest in module_name:
skip = True
break
if skip:
continue
try:
# Dynamically import the module
module = importlib.import_module(module_name)

# Dynamically access the test class from the module
# Assuming each test file has only one class named the same as the module
test_class = getattr(module, module_name)

# Instantiate and run the test
test_instance = test_class(hdmiCECSummerLog)
test_instance.run(False)

except (ImportError, AttributeError) as e:
hdmiCECSummerLog.error(f"Failed to import {module_name}: {e}")

if __name__ == '__main__':
Runall_L3()
29 changes: 0 additions & 29 deletions host/tests/hdmiCEC_L3_Tests/hdmiCEC_L3_testSetup.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import os
import sys
import time

# Append the current and parent directory paths to sys.path for module imports
dir_path = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -32,7 +33,6 @@
# Importing helper classes and modules for HDMI-CEC testing and logging
from hdmiCECHelperClass import hdmiCECHelperClass
from raft.framework.core.logModule import logModule
from raft.framework.plugins.ut_raft.configRead import ConfigRead

class hdmiCEC_test01_TransmitCECCommands(hdmiCECHelperClass):
"""
Expand Down Expand Up @@ -86,6 +86,8 @@ def testFunction(self):
# Final test result
finalResult = True

self.hdmiCECController.startMonitoring()

for device in self.cecDevices:
logicalAddress = device["logical address"]

Expand All @@ -107,6 +109,8 @@ def testFunction(self):
# Transmit the CEC command
self.testhdmiCEC.cecTransmitCmd(destinationLogicalAddress, cec, payload)

time.sleep(2)

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

# Validate the transmission
Expand All @@ -116,6 +120,8 @@ def testFunction(self):

finalResult &= result

self.hdmiCECController.stopMonitoring()

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def testFunction(self):
# Get the logical address of the HDMI-CEC adapter
cecAdapterLogicalAddress = self.cecAdaptor["logical address"]

self.hdmiCECController.startMonitoring()
finalResult = True
for command in self.cecCommands:
result = False
Expand Down Expand Up @@ -160,6 +161,8 @@ def testFunction(self):

finalResult &= result

self.hdmiCECController.stopMonitoring()

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

Expand Down

0 comments on commit 2104b00

Please sign in to comment.