Skip to content

Commit 43e6d12

Browse files
SentimentronV8 LUCI CQ
authored andcommitted
cleanup: address review comments from #6617022
* Static files dispersed to other repos * URLs to static files corrected * Formatting changes * Untested local web-server changes reverted Bug: 416356440 Change-Id: Id7944645d6f253b28b5d22320b431527fb717996 Reviewed-on: https://chromium-review.googlesource.com/c/crossbench/+/6634469 Commit-Queue: Richard Townsend <[email protected]> Reviewed-by: Camillo Bruni <[email protected]>
1 parent c7a48f4 commit 43e6d12

File tree

6 files changed

+16
-49
lines changed

6 files changed

+16
-49
lines changed
Binary file not shown.

config/benchmark/powerline/index.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

config/benchmark/powerline/network_config.hjson

Lines changed: 0 additions & 5 deletions
This file was deleted.

crossbench/benchmarks/powerline/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
from crossbench.benchmarks.powerline.powerline_benchmark import PowerlineBenchmark
5+
from crossbench.benchmarks.powerline.powerline_benchmark import \
6+
PowerlineBenchmark

crossbench/benchmarks/powerline/powerline_benchmark.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
import abc
65
import argparse
76
import datetime as dt
87
import logging
9-
from typing import Any, Optional
8+
from typing import Any, Optional, Final
109

1110
from typing_extensions import override
1211

@@ -21,19 +20,16 @@
2120
from crossbench.parse import DurationParser
2221
from crossbench.runner.run import Run
2322
from crossbench.stories.story import Story
23+
from crossbench.action_runner.action.enums import ReadyState
2424

25-
PLAY_AUDIO_SCRIPT = """
26-
27-
setTimeout(()=>{
25+
PLAY_AUDIO_SCRIPT: Final[str] = """
2826
document.getElementById('unmuteButton').click();
29-
}, 1000);
30-
3127
"""
3228

33-
class PowerlineStory(Story, metaclass=abc.ABCMeta):
29+
class PowerlineStory(Story):
3430

3531
STORY_NAME="podcast"
36-
URL="http://localhost:8000"
32+
URL="https://chromium-workloads.web.app/web-tests/main/synthetic/powerline/podcast.html"
3733

3834
def __init__(self, run_for: Optional[dt.timedelta] = dt.timedelta()):
3935
duration = (run_for or dt.timedelta(seconds=600))
@@ -45,11 +41,16 @@ def run(self, run: Run) -> None:
4541
with run.actions("Show URL") as actions:
4642
actions.show_url(self.URL)
4743
with run.actions("Autoplay") as actions:
48-
actions.wait(dt.timedelta(seconds=5))
44+
actions.wait_for_ready_state(
45+
ReadyState.COMPLETE, timeout=dt.timedelta(seconds=5)
46+
)
4947
actions.js(PLAY_AUDIO_SCRIPT)
5048
with run.actions("Screen") as actions:
5149
actions.wait(dt.timedelta(seconds=5))
52-
actions.platform.sh("input", "keyevent", "26")
50+
if actions.platform.is_android:
51+
# On Android, put the screen to sleep to simulate playing a
52+
# podcast in the background.
53+
actions.platform.sh("input", "keyevent", "26")
5354
self._wait_for_input()
5455
logging.info("Stopping benchmark...")
5556

@@ -69,7 +70,7 @@ def all_story_names(cls) -> tuple[str, ...]:
6970

7071

7172

72-
class PowerlineBenchmark(Benchmark, metaclass=abc.ABCMeta):
73+
class PowerlineBenchmark(Benchmark):
7374
"""
7475
Benchmark runner for the Powerline background power-consumption test.
7576
@@ -94,11 +95,6 @@ def __init__(self,
9495
def _base_dir(cls) -> pth.LocalPath:
9596
return config.config_dir() / "benchmark" / "powerline"
9697

97-
@classmethod
98-
@override
99-
def default_network_config_path(cls) -> pth.LocalPath:
100-
return cls._base_dir() / "network_config.hjson"
101-
10298
@classmethod
10399
@override
104100
def default_probe_config_path(cls) -> pth.LocalPath:

crossbench/parse.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import json
1111
import logging
1212
import math
13-
import os
1413
import re
1514
import shlex
1615
from typing import (TYPE_CHECKING, Any, Callable, Final, Iterable, Optional,
@@ -37,7 +36,7 @@ class PathParser:
3736
PATH_PREFIX = re.compile(r"^(?:"
3837
r"(?:\.\.?|~)?|"
3938
r"[a-zA-Z]:"
40-
r")(\\|/)[^\\/]",)
39+
r")(\\|/)[^\\/]")
4140

4241
@classmethod
4342
def value_has_path_prefix(cls, value: str) -> bool:
@@ -52,13 +51,6 @@ def path(cls,
5251
if not path_value:
5352
raise argparse.ArgumentTypeError("Invalid empty path.")
5453
try:
55-
# Some tests (e.g. powerline) use locally-hosted web servers
56-
if str(path_value).startswith("${crossbench_root}"):
57-
dirname = os.path.abspath(
58-
os.path.join(
59-
os.path.dirname(__file__), os.path.pardir
60-
))
61-
path_value = str(path_value).replace("${crossbench_root}", dirname, 1)
6254
path = pth.LocalPath(path_value).expanduser()
6355
except RuntimeError as e:
6456
raise argparse.ArgumentTypeError(

0 commit comments

Comments
 (0)