test_AtomSampleViewer_main_suite.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. import logging
  7. import os
  8. import subprocess
  9. import pytest
  10. import ly_test_tools.environment.process_utils as process_utils
  11. import ly_test_tools.launchers.platforms.base
  12. logger = logging.getLogger(__name__)
  13. class AtomSampleViewerException(Exception):
  14. """Custom Exception class for AtomSampleViewer tests."""
  15. pass
  16. @pytest.mark.parametrize('launcher_platform', ['windows'])
  17. @pytest.mark.parametrize("project", ["AtomSampleViewer"])
  18. @pytest.mark.parametrize('rhi', ['dx12', 'vulkan'])
  19. @pytest.mark.usefixtures("clean_atomsampleviewer_logs", "atomsampleviewer_log_monitor")
  20. class TestAutomationMainSuite:
  21. def test_AutomatedReviewTestSuite(self, request, workspace, launcher_platform, rhi, atomsampleviewer_log_monitor):
  22. # Script call setup.
  23. test_script = '_FullTestSuite_.bv.lua'
  24. test_script_path = os.path.join(workspace.paths.project(), 'scripts', test_script)
  25. if not os.path.exists(test_script_path):
  26. raise AtomSampleViewerException(f'Test script does not exist in path: {test_script_path}')
  27. cmd = os.path.join(workspace.paths.build_directory(),
  28. 'AtomSampleViewerStandalone.exe '
  29. f'--project-path={workspace.paths.project()} '
  30. f'--rhi {rhi} '
  31. f'--runtestsuite scripts/{test_script}c '
  32. '--exitontestend')
  33. def teardown():
  34. process_utils.kill_processes_named(['AssetProcessor', 'AtomSampleViewerStandalone'], ignore_extensions=True)
  35. request.addfinalizer(teardown)
  36. # Execute test.
  37. process_utils.safe_check_call(cmd, stderr=subprocess.STDOUT, encoding='UTF-8', shell=True)
  38. try:
  39. unexpected_lines = ["Script: Screenshot check failed. Diff score", # "Diff score" ensures legit failure.
  40. "Trace::Error",
  41. "Trace::Assert",
  42. "Traceback (most recent call last):"]
  43. atomsampleviewer_log_monitor.monitor_log_for_lines(
  44. unexpected_lines=unexpected_lines, halt_on_unexpected=True, timeout=400)
  45. except ly_test_tools.log.log_monitor.LogMonitorException as e:
  46. expected_screenshots_path = os.path.join(
  47. workspace.paths.project(), "scripts", "ExpectedScreenshots")
  48. test_screenshots_path = os.path.join(
  49. workspace.paths.project(), "user", "scripts", "Screenshots")
  50. raise AtomSampleViewerException(
  51. f"Got error: {e}\n"
  52. f"Screenshot comparison check failed using Render Hardware Interface (RHI): '{rhi}'\n"
  53. "Please review logs and screenshots at:\n"
  54. f"Log file: {atomsampleviewer_log_monitor.file_to_monitor}\n"
  55. f"Expected screenshots: {expected_screenshots_path}\n"
  56. f"Test screenshots: {test_screenshots_path}\n")