Skip to content

Commit a71d4ed

Browse files
committed
vibratorservice: Fix broken benchmarks
Fixes an issue with the benchmarks, where they would skip unsupported situations by early returning without reaching the measure loop and without notifying the framework. The framework would then retry the exact same scenario indefinitely. To fix, makes sure every early return also calls SkipWithMessage. Fixes: 279134938 Test: adb shell /tmp/VibratorHalControllerBenchmarks --v=2 Change-Id: If7f92816133bf3d03a5915b6f077eb961d55cf75
1 parent 427e333 commit a71d4ed

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

services/vibratorservice/benchmarks/VibratorHalControllerBenchmarks.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ BENCHMARK_WRAPPER(VibratorBench, off, {
152152

153153
BENCHMARK_WRAPPER(VibratorBench, setAmplitude, {
154154
if (!hasCapabilities(vibrator::Capabilities::AMPLITUDE_CONTROL, state)) {
155+
state.SkipWithMessage("missing capability");
155156
return;
156157
}
157158

@@ -180,6 +181,7 @@ BENCHMARK_WRAPPER(VibratorBench, setAmplitude, {
180181

181182
BENCHMARK_WRAPPER(VibratorBench, setAmplitudeCached, {
182183
if (!hasCapabilities(vibrator::Capabilities::AMPLITUDE_CONTROL, state)) {
184+
state.SkipWithMessage("missing capability");
183185
return;
184186
}
185187

@@ -200,6 +202,7 @@ BENCHMARK_WRAPPER(VibratorBench, setAmplitudeCached, {
200202

201203
BENCHMARK_WRAPPER(VibratorBench, setExternalControl, {
202204
if (!hasCapabilities(vibrator::Capabilities::EXTERNAL_CONTROL, state)) {
205+
state.SkipWithMessage("missing capability");
203206
return;
204207
}
205208

@@ -221,6 +224,7 @@ BENCHMARK_WRAPPER(VibratorBench, setExternalControl, {
221224

222225
BENCHMARK_WRAPPER(VibratorBench, setExternalControlCached, {
223226
if (!hasCapabilities(vibrator::Capabilities::EXTERNAL_CONTROL, state)) {
227+
state.SkipWithMessage("missing capability");
224228
return;
225229
}
226230

@@ -239,6 +243,7 @@ BENCHMARK_WRAPPER(VibratorBench, setExternalControlCached, {
239243

240244
BENCHMARK_WRAPPER(VibratorBench, setExternalAmplitudeCached, {
241245
if (!hasCapabilities(vibrator::Capabilities::EXTERNAL_AMPLITUDE_CONTROL, state)) {
246+
state.SkipWithMessage("missing capability");
242247
return;
243248
}
244249

@@ -331,9 +336,11 @@ class VibratorEffectsBench : public VibratorBench {
331336

332337
BENCHMARK_WRAPPER(VibratorEffectsBench, alwaysOnEnable, {
333338
if (!hasCapabilities(vibrator::Capabilities::ALWAYS_ON_CONTROL, state)) {
339+
state.SkipWithMessage("missing capability");
334340
return;
335341
}
336342
if (!hasArgs(state)) {
343+
state.SkipWithMessage("missing args");
337344
return;
338345
}
339346

@@ -357,9 +364,11 @@ BENCHMARK_WRAPPER(VibratorEffectsBench, alwaysOnEnable, {
357364

358365
BENCHMARK_WRAPPER(VibratorEffectsBench, alwaysOnDisable, {
359366
if (!hasCapabilities(vibrator::Capabilities::ALWAYS_ON_CONTROL, state)) {
367+
state.SkipWithMessage("missing capability");
360368
return;
361369
}
362370
if (!hasArgs(state)) {
371+
state.SkipWithMessage("missing args");
363372
return;
364373
}
365374

@@ -384,6 +393,7 @@ BENCHMARK_WRAPPER(VibratorEffectsBench, alwaysOnDisable, {
384393

385394
BENCHMARK_WRAPPER(VibratorEffectsBench, performEffect, {
386395
if (!hasArgs(state)) {
396+
state.SkipWithMessage("missing args");
387397
return;
388398
}
389399

@@ -441,9 +451,11 @@ class VibratorPrimitivesBench : public VibratorBench {
441451

442452
BENCHMARK_WRAPPER(VibratorPrimitivesBench, performComposedEffect, {
443453
if (!hasCapabilities(vibrator::Capabilities::COMPOSE_EFFECTS, state)) {
454+
state.SkipWithMessage("missing capability");
444455
return;
445456
}
446457
if (!hasArgs(state)) {
458+
state.SkipWithMessage("missing args");
447459
return;
448460
}
449461

@@ -468,4 +480,4 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench, performComposedEffect, {
468480
}
469481
});
470482

471-
BENCHMARK_MAIN();
483+
BENCHMARK_MAIN();

0 commit comments

Comments
 (0)