mirror of
https://github.com/LTTLabsOSS/markbench-tests.git
synced 2026-01-08 21:48:00 -05:00
Artifact manager implementation for cs2, added menu navigation using pyautogui
This commit is contained in:
@@ -19,7 +19,8 @@ from harness_utils.output import (
|
||||
DEFAULT_DATE_FORMAT)
|
||||
from harness_utils.process import terminate_processes
|
||||
from harness_utils.keras_service import KerasService
|
||||
from harness_utils.steam import exec_steam_game
|
||||
from harness_utils.steam import exec_steam_game, get_registry_active_user, get_steam_folder_path
|
||||
from harness_utils.artifacts import ArtifactManager, ArtifactType
|
||||
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
@@ -27,6 +28,9 @@ LOG_DIR = SCRIPT_DIR.joinpath("run")
|
||||
PROCESS_NAME = "cs2.exe"
|
||||
STEAM_GAME_ID = 730
|
||||
|
||||
STEAM_USER_ID = get_registry_active_user()
|
||||
cfg = Path(get_steam_folder_path(), "userdata", str(STEAM_USER_ID), str(STEAM_GAME_ID), "local", "cfg", "cs2_video.txt")
|
||||
|
||||
def setup_logging():
|
||||
"""default logging config"""
|
||||
LOG_DIR.mkdir(exist_ok=True)
|
||||
@@ -56,6 +60,8 @@ def run_benchmark(keras_service):
|
||||
copy_config()
|
||||
setup_start_time = time.time()
|
||||
start_game()
|
||||
|
||||
am = ArtifactManager(LOG_DIR)
|
||||
time.sleep(20) # wait for game to load into main menu
|
||||
|
||||
result = keras_service.wait_for_word("play", timeout=30, interval=0.1)
|
||||
@@ -63,6 +69,57 @@ def run_benchmark(keras_service):
|
||||
logging.info("Did not find the play menu. Did the game load?")
|
||||
sys.exit(1)
|
||||
|
||||
height, width = get_resolution()
|
||||
location = None
|
||||
|
||||
# We check the resolution so we know which screenshot to use for the locate on screen function
|
||||
match width:
|
||||
case "1920":
|
||||
location = gui.locateOnScreen("C:\markbench-2.1.2-2f39666\harness\LTTLabsOSS-markbench-tests\counterstrike2_2\screenshots\settings_1080.png")
|
||||
case "2560":
|
||||
location = gui.locateOnScreen("C:\markbench-2.1.2-2f39666\harness\LTTLabsOSS-markbench-tests\counterstrike2_2\screenshots\settings_1440.png")
|
||||
case "3840":
|
||||
location = gui.locateOnScreen("C:\markbench-2.1.2-2f39666\harness\LTTLabsOSS-markbench-tests\counterstrike2_2\screenshots\settings_2160.png")
|
||||
case _:
|
||||
logging.error("Could not find the settings cog. The game resolution is currently " + height + "," + width + ". Are you using a standard resolution?")
|
||||
sys.exit(1)
|
||||
|
||||
click_me = gui.center(location)
|
||||
gui.click(click_me.x, click_me.y)
|
||||
time.sleep(0.2)
|
||||
|
||||
if keras_service.wait_for_word(word="brightness", timeout=30, interval=1) is None:
|
||||
logging.info("Did not find the video settings menu. Did the menu get stuck?")
|
||||
sys.exit(1)
|
||||
|
||||
am.take_screenshot("video.png", ArtifactType.CONFIG_IMAGE, "picture of video settings")
|
||||
|
||||
result = keras_service.look_for_word(word="advanced", attempts=10, interval=1)
|
||||
if not result:
|
||||
logging.info("Did not find the advanced video menu. Did Keras click correctly?")
|
||||
sys.exit(1)
|
||||
|
||||
gui.click(result["x"], result["y"])
|
||||
time.sleep(0.2)
|
||||
|
||||
am.take_screenshot("advanced_video_1.png", ArtifactType.CONFIG_IMAGE, "first picture of advanced video settings")
|
||||
|
||||
result = keras_service.look_for_word(word="boost", attempts=10, interval=1)
|
||||
if not result:
|
||||
logging.info("Did not find the keyword 'Boost' in the advanced video menu. Did Keras click correctly?")
|
||||
sys.exit(1)
|
||||
|
||||
gui.moveTo(result["x"], result["y"])
|
||||
time.sleep(1)
|
||||
gui.scroll(-6000000)
|
||||
time.sleep(1)
|
||||
|
||||
if keras_service.wait_for_word(word="particle", timeout=30, interval=1) is None:
|
||||
logging.info("Did not find the keyword 'Particle' in advanced video menu. Did Keras scroll correctly?")
|
||||
sys.exit(1)
|
||||
|
||||
am.take_screenshot("advanced_video_2.png", ArtifactType.CONFIG_IMAGE, "second picture of advanced video settings")
|
||||
|
||||
logging.info('Starting benchmark')
|
||||
user.press("`")
|
||||
time.sleep(0.5)
|
||||
@@ -107,9 +164,14 @@ def run_benchmark(keras_service):
|
||||
test_end_time = time.time()
|
||||
logging.info("The console opened. Marking end time.")
|
||||
|
||||
time.sleep(10)
|
||||
time.sleep(8)
|
||||
|
||||
am.take_screenshot("result.png", ArtifactType.RESULTS_IMAGE, "benchmark results")
|
||||
am.copy_file(Path(cfg), ArtifactType.CONFIG_TEXT, "cs2 video config")
|
||||
logging.info("Run completed. Closing game.")
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
elapsed_test_time = round((test_end_time - test_start_time), 2)
|
||||
logging.info("Benchmark took %f seconds", elapsed_test_time)
|
||||
terminate_processes(PROCESS_NAME)
|
||||
|
||||
BIN
counterstrike2/screenshots/settings_1080.png
Normal file
BIN
counterstrike2/screenshots/settings_1080.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
counterstrike2/screenshots/settings_1440.png
Normal file
BIN
counterstrike2/screenshots/settings_1440.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
counterstrike2/screenshots/settings_2160.png
Normal file
BIN
counterstrike2/screenshots/settings_2160.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
Reference in New Issue
Block a user