Skip to content

Commit

Permalink
gh #247 Python update (Need to test)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarthikeyanR470 committed Nov 13, 2024
1 parent 28dc451 commit d04a29b
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 83 deletions.
30 changes: 14 additions & 16 deletions host/tests/L3_TestCases/dsVideoDevice/dsVideoDeviceHelperClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,24 @@ def __init__(self, testName:str, qcId:str, log:logModule=None ):
self.hal_session = self.dut.getConsoleSession("ssh_hal_test")
self.player_session = self.dut.getConsoleSession("ssh_player")

player = self.cpe.get("test").get("player")

deviceTestSetup = self.cpe.get("test")
socVendor = self.cpe.get("soc_vendor")

# Create player Class
self.testPlayer = utPlayer(self.player_session, player)
self.testPlayer = utPlayer(self.player_session, socVendor)

# Create user response Class
self.testUserResponse = utUserResponse()

# Get path to device profile file
self.deviceProfile = os.path.join(dir_path, self.cpe.get("test").get("profile"))

self.deviceDownloadPath = self.cpe.get("target_directory")
self.moduleConfigProfileFile = os.path.join(dir_path, deviceTestSetup.get("profile"))

self.targetWorkspace = self.cpe.get("target_directory")
self.targetWorkspace = os.path.join(self.targetWorkspace, self.moduleName)
self.streamDownloadURL = deviceTestSetup.get("streams_download_url")


def testDownloadAssets(self):
"""
Expand All @@ -87,17 +93,13 @@ def testDownloadAssets(self):

test = self.testSetup.get("assets").get("device").get(self.testName)

# Download test artifacts to device
url = test.get("artifacts")
if url is not None:
self.downloadToDevice(url, self.deviceDownloadPath, self.rackDevice)

# Download test streams to device
self.StreamUrl = test.get("streams")
if(self.StreamUrl and len(self.StreamUrl) == 1):
self.downloadToDevice(self.StreamUrl, self.deviceDownloadPath, self.rackDevice)
self.downloadToDevice(self.StreamUrl, self.targetWorkspace, self.rackDevice)
for streampath in self.StreamUrl:
self.testStreams.append(os.path.join(self.deviceDownloadPath, os.path.basename(streampath)))
self.testStreams.append(os.path.join(self.targetWorkspace, os.path.basename(streampath)))

def testDownloadSingleStream(self, stream_url) -> str:
"""
Expand Down Expand Up @@ -149,11 +151,6 @@ def testRunPrerequisites(self):
for cmd in cmds:
self.writeCommands(cmd)

# Run commands as part of test prerequisites
prerequisite_cmds = self.cpe.get("test").get("player").get("prerequisites")
if prerequisite_cmds is not None:
for expcmd in prerequisite_cmds:
self.writeCommands(expcmd)

def testPrepareFunction(self):
"""
Expand All @@ -175,12 +172,13 @@ def testPrepareFunction(self):
self.testRunPrerequisites()

# Create the dsVideoDevice class
self.testdsVideoDevice = dsVideoDeviceClass(self.deviceProfile, self.hal_session)
self.testdsVideoDevice = dsVideoDeviceClass(self.moduleConfigProfileFile, self.hal_session, self.targetWorkspace)

return True

def testEndFunction(self, powerOff=True):
# Clean up the dsVideoDevice instance
self.testCleanAssets()
del self.testdsVideoDevice

def testExceptionCleanUp (self):
Expand Down
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
dsVideoDeviceSummerLog = logModule("dsVideoDeviceSummerLog_Sink", level=logModule.INFO)

testDirectory = Path(dir_path)

# Find all test modules in the directory
test_modules = sorted(testDirectory.glob("dsVideoDevice_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(dsVideoDeviceSummerLog)
test_instance.run(False)

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

if __name__ == '__main__':
Runall_L3()
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/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 = ["test1", "test3", "test4"]

# Summery log for all the tests
dsVideoDeviceSummerLog = logModule("dsVideoDeviceSummerLog_Source", level=logModule.INFO)

testDirectory = Path(dir_path)

# Find all test modules in the directory
test_modules = sorted(testDirectory.glob("dsVideoDevice_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(dsVideoDeviceSummerLog)
test_instance.run(False)

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

if __name__ == '__main__':
Runall_L3()
Original file line number Diff line number Diff line change
@@ -1,55 +1,59 @@
# this file is generated by the testing suites, when a new test is modified, this configuration file will be filled out and updated.
#location: https://github.com/rdkcentral/rdk-halif-test-device_settings/tree/3.1.2/assets/
#** *****************************************************************************
# *
# * 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.
# *
#* ******************************************************************************

dsVideoDevice: # Prefix must always exist
dsVideoDevice:
description: "dsVideoDevice Device Settings test setup"
assets:
device:
defaults: &defaults
artifacts:
- "<URL Path>/dsVideoDevice//bin/hal_test"
- "<URL Path>/dsVideoDevice//bin/libut_control.so"
- "<URL Path>/dsVideoDevice/profiles/sink/Sink_4K_VideoDevice.yaml"
- "<URL Path>/dsVideoDevice/bin/run.sh"
execute:
- "chmod +x <Path on Device>/dsVideodevice/hal_test"
- "chmod +x <Path on Device>/dsVideodevice/run.sh"
- "ln -s /usr/lib/libds-hal.so <Path on Device>/dsVideodevice/libdshal.so"
streams:
test1_FrameratePrePostChangeCallBack_Verify:
<<: *defaults
streams:
- "<URL Path>/streams/scrolling_text_fast_3840x2160_23.98fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_24fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_25fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_29.97fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_30fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_50fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_59.94fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_60fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_23.98fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_24fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_25fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_29.97fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_30fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_50fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_59.94fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_60fps.mp4"
test2_ZoomMode:
<<: *defaults
streams:
- "<URL Path>/streams/scrolling_text_fast_1920x1080_60fps.mp4"
- "/streams/scrolling_text_fast_1920x1080_60fps.mp4"
test3_SetDisplayFramerate:
<<: *defaults
streams:
- "<URL Path>/streams/scrolling_text_fast_3840x2160_23.98fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_24fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_25fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_29.97fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_30fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_50fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_59.94fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_60fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_23.98fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_24fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_25fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_29.97fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_30fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_50fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_59.94fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_60fps.mp4"
test4_FRFMode:
<<: *defaults
streams:
- "<URL Path>/streams/scrolling_text_fast_3840x2160_23.98fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_24fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_25fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_29.97fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_30fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_50fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_59.94fps.mp4"
- "<URL Path>/streams/scrolling_text_fast_3840x2160_60fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_23.98fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_24fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_25fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_29.97fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_30fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_50fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_59.94fps.mp4"
- "/streams/scrolling_text_fast_3840x2160_60fps.mp4"
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
sys.path.append(os.path.join(dir_path, "../../"))

from L3_TestCases.dsVideoDevice.dsVideoDeviceHelperClass import dsVideoDeviceHelperClass
from raft.framework.core.logModule import logModule

class dsVideoDevice_test1_FrameratePreChangeCallback_Verify(dsVideoDeviceHelperClass):
class dsVideoDevice_test1_FrameratePrePostChangeCallback_Verify(dsVideoDeviceHelperClass):
"""
Class to verify display framerate change pre and post callback .
Expand All @@ -43,7 +44,7 @@ class dsVideoDevice_test1_FrameratePreChangeCallback_Verify(dsVideoDeviceHelperC
rackDevice (str): Identifier for the device under test.
"""

def __init__(self):
def __init__(self, log:logModule=None):
"""
Initializes the test1_FrameratePrePostChangeCallBack_Verify test .
Expand All @@ -52,7 +53,7 @@ def __init__(self):
"""
self.testName = "test1_FrameratePrePostChangeCallBack_Verify"
self.qcID = '1'
super().__init__(self.testName, self.qcID)
super().__init__(self.testName, self.qcID, log)


def checkDeviceStatus(self, manual=False):
Expand Down Expand Up @@ -83,7 +84,6 @@ def testFunction(self):
bool: Final result of the test.
"""

self.log.testStart(self.testName, self.qcID)

# Initialize the dsVideoDevice module
self.testdsVideoDevice.initialise(self.testdsVideoDevice.getDeviceType())
Expand Down Expand Up @@ -127,5 +127,7 @@ def testFunction(self):
return result

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

0 comments on commit d04a29b

Please sign in to comment.