1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tradefed.device.metric; 18 19 import com.android.tradefed.config.OptionSetter; 20 import com.android.tradefed.device.ITestDevice; 21 import com.android.tradefed.invoker.IInvocationContext; 22 import com.android.tradefed.metrics.proto.MetricMeasurement.Metric; 23 import com.android.tradefed.result.ITestInvocationListener; 24 import com.android.tradefed.util.IRunUtil; 25 import com.android.tradefed.util.CommandResult; 26 import com.android.tradefed.util.CommandStatus; 27 import com.android.tradefed.result.LogDataType; 28 29 import org.easymock.EasyMock; 30 import org.junit.After; 31 import org.junit.Before; 32 import org.junit.Test; 33 import org.junit.runner.RunWith; 34 import org.junit.runners.JUnit4; 35 36 import java.io.File; 37 import java.lang.Error; 38 import java.util.ArrayList; 39 import java.util.Arrays; 40 import java.util.HashMap; 41 import java.util.List; 42 import java.util.Map; 43 44 45 /** 46 * Unit tests for {@link AtraceCollector}, 47 */ 48 @RunWith(JUnit4.class) 49 public final class AtraceCollectorTest { 50 private ITestDevice mMockDevice; 51 private AtraceCollector mAtrace; 52 private OptionSetter mOptionSetter; 53 private ITestInvocationListener mMockTestLogger; 54 private IInvocationContext mMockInvocationContext; 55 private IRunUtil mMockRunUtil; 56 private File mDummyBinary; 57 private static final String M_DEFAULT_LOG_PATH = "/data/local/tmp/atrace.atr"; 58 private static final String M_SERIAL_NO = "12349876"; 59 private static final String M_CATEGORIES = "tisket tasket brisket basket"; 60 private static final String M_TRACE_PATH_NAME = "/tmp/traces.txt"; 61 62 @Before 63 public void setUp() throws Exception { 64 mMockDevice = EasyMock.createNiceMock(ITestDevice.class); 65 mMockTestLogger = EasyMock.createMock(ITestInvocationListener.class); 66 mMockInvocationContext = EasyMock.createNiceMock(IInvocationContext.class); 67 mMockRunUtil = EasyMock.createMock(IRunUtil.class); 68 69 mAtrace = new AtraceCollector(); 70 mOptionSetter = new OptionSetter(mAtrace); 71 mOptionSetter.setOptionValue("categories", M_CATEGORIES); 72 73 EasyMock.expect(mMockDevice.pullFile((String) EasyMock.anyObject())) 74 .andStubReturn(new File(M_TRACE_PATH_NAME)); 75 EasyMock.expect(mMockDevice.getSerialNumber()).andStubReturn(M_SERIAL_NO); 76 77 EasyMock.expect(mMockInvocationContext.getDevices()) 78 .andStubReturn(Arrays.asList(mMockDevice)); 79 EasyMock.replay(mMockInvocationContext); 80 mAtrace.init(mMockInvocationContext, mMockTestLogger); 81 mDummyBinary = File.createTempFile("tmp", "bin"); 82 mDummyBinary.setExecutable(true); 83 } 84 85 @After 86 public void tearDown() throws Exception { 87 mDummyBinary.delete(); 88 } 89 90 /** 91 * Test {@link AtraceCollector#onTestStart(DeviceMetricData)} to see if atrace collection 92 * started correctly. 93 * 94 * <p> 95 * Expect that atrace was started in async mode with compression on. 96 * </p> 97 */ 98 @Test 99 public void testStartsAtraceOnSetupNoOptions() throws Exception { 100 mMockDevice.executeShellCommand( 101 EasyMock.eq("atrace --async_start -z " + M_CATEGORIES), 102 EasyMock.anyObject(), 103 EasyMock.eq(1L), 104 EasyMock.anyObject(), 105 EasyMock.eq(1)); 106 EasyMock.expectLastCall().times(1); 107 108 EasyMock.replay(mMockDevice); 109 110 mAtrace.onTestStart(new DeviceMetricData(mMockInvocationContext)); 111 EasyMock.verify(mMockDevice); 112 } 113 114 /** 115 * Test {@link AtraceCollector#onTestStart(DeviceMetricData)} to see if atrace collection 116 * started correctly when the compress-dump option is false. 117 * 118 * <p>Expect that atrace was started in async mode with compression off. 119 */ 120 @Test 121 public void testStartsAtraceOnSetupNoCompression() throws Exception { 122 mMockDevice.executeShellCommand( 123 EasyMock.eq("atrace --async_start " + M_CATEGORIES), 124 EasyMock.anyObject(), 125 EasyMock.eq(1L), 126 EasyMock.anyObject(), 127 EasyMock.eq(1)); 128 EasyMock.expectLastCall().times(1); 129 130 EasyMock.replay(mMockDevice); 131 132 mOptionSetter.setOptionValue("compress-dump", "false"); 133 mAtrace.onTestStart(new DeviceMetricData(mMockInvocationContext)); 134 EasyMock.verify(mMockDevice); 135 } 136 137 /** 138 * Test {@link AtraceCollector#onTestStart(DeviceMetricData)} to see if atrace collection 139 * started correctly with some tracing categories. 140 * 141 * <p> 142 * Expect that supplied categories options were included in the command 143 * when starting atrace. 144 * </p> 145 */ 146 @Test 147 public void testStartsAtraceOnSetupCategoriesOption() throws Exception { 148 mMockDevice.executeShellCommand( 149 EasyMock.eq("atrace --async_start -z " + M_CATEGORIES), 150 EasyMock.anyObject(), 151 EasyMock.eq(1L), 152 EasyMock.anyObject(), 153 EasyMock.eq(1)); 154 EasyMock.expectLastCall().times(1); 155 156 EasyMock.replay(mMockDevice); 157 158 mAtrace.onTestStart(new DeviceMetricData(mMockInvocationContext)); 159 EasyMock.verify(mMockDevice); 160 } 161 162 /** 163 * Test {@link AtraceCollector#onTestStart(DeviceMetricData)} to see if atrace collection 164 * started correctly with multiple tracing categories. 165 * 166 * <p> 167 * Expect that supplied categories options were included in the command 168 * when starting atrace. 169 * </p> 170 */ 171 @Test 172 public void testStartsAtraceOnSetupMultipleCategoriesOption() throws Exception { 173 String freqCategory = "freq"; 174 String schedCategory = "sched"; 175 String expectedCategories = M_CATEGORIES + " " + freqCategory + " " + schedCategory; 176 mMockDevice.executeShellCommand( 177 EasyMock.eq("atrace --async_start -z " + expectedCategories), 178 EasyMock.anyObject(), EasyMock.eq(1L), EasyMock.anyObject(), EasyMock.eq(1)); 179 EasyMock.expectLastCall().times(1); 180 181 EasyMock.replay(mMockDevice); 182 183 mOptionSetter.setOptionValue("categories", freqCategory); 184 mOptionSetter.setOptionValue("categories", schedCategory); 185 mAtrace.onTestStart(new DeviceMetricData(mMockInvocationContext)); 186 EasyMock.verify(mMockDevice); 187 } 188 189 /** 190 * Test {@link AtraceCollector#onTestStart(DeviceMetricData)} to see if atrace collection 191 * started with no tracing categories does not do anything. 192 * 193 * <p> 194 * Expect that no commands are issued to the device when no categories are set 195 * </p> 196 */ 197 @Test 198 public void testStartsAtraceWithNoCategoriesOption() throws Exception { 199 mMockDevice.executeShellCommand( 200 (String) EasyMock.anyObject(), 201 EasyMock.anyObject(), EasyMock.anyLong(), EasyMock.anyObject(), EasyMock.anyInt()); 202 EasyMock.expectLastCall() 203 .andThrow(new Error("should not be called")) 204 .anyTimes(); 205 EasyMock.replay(mMockDevice); 206 207 AtraceCollector atrace = new AtraceCollector(); 208 atrace.onTestStart(new DeviceMetricData(mMockInvocationContext)); 209 atrace.onTestEnd( 210 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 211 EasyMock.verify(mMockDevice); 212 } 213 214 /** 215 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see if atrace collection 216 * stopped correctly. 217 * 218 * <p>Expect that atrace command was stopped, the trace file was pulled from device to host and 219 * the trace file removed from device. 220 */ 221 @Test 222 public void testStopsAtraceDuringTearDown() throws Exception { 223 mMockDevice.executeShellCommand( 224 EasyMock.eq("atrace --async_stop -o " + M_DEFAULT_LOG_PATH), 225 EasyMock.anyObject(), 226 EasyMock.eq(60L), 227 EasyMock.anyObject(), 228 EasyMock.eq(1)); 229 EasyMock.expectLastCall().times(1); 230 EasyMock.expect(mMockDevice.pullFile(EasyMock.eq(M_DEFAULT_LOG_PATH))) 231 .andReturn(new File("/tmp/potato")) 232 .once(); 233 EasyMock.expect(mMockDevice.executeShellCommand(EasyMock.eq("rm -f " + M_DEFAULT_LOG_PATH))) 234 .andReturn("") 235 .times(1); 236 237 EasyMock.replay(mMockDevice); 238 mAtrace.onTestEnd( 239 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 240 EasyMock.verify(mMockDevice); 241 } 242 243 /** 244 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see if atrace collection 245 * stopped correctly when preserve-ondevice-log is set. 246 * 247 * <p>Expect that atrace command was stopped, the trace file was pulled from device to host and 248 * the trace file was not removed from the device. 249 */ 250 @Test 251 public void testPreserveFileOnDeviceOption() throws Exception { 252 mMockDevice.executeShellCommand( 253 EasyMock.eq("atrace --async_stop -o " + M_DEFAULT_LOG_PATH), 254 EasyMock.anyObject(), 255 EasyMock.eq(60L), 256 EasyMock.anyObject(), 257 EasyMock.eq(1)); 258 EasyMock.expectLastCall().times(1); 259 EasyMock.expect(mMockDevice.pullFile(EasyMock.eq(M_DEFAULT_LOG_PATH))) 260 .andReturn(new File("/tmp/potato")) 261 .once(); 262 263 EasyMock.replay(mMockDevice); 264 mOptionSetter.setOptionValue("preserve-ondevice-log", "true"); 265 mAtrace.onTestEnd( 266 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 267 EasyMock.verify(mMockDevice); 268 } 269 270 /** 271 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that it throws an 272 * exception if the atrace file could not be collected. 273 * 274 * <p>Expect that DeviceNotAvailableException is thrown when the file returned is null. 275 */ 276 @Test 277 public void testLogPullFail() throws Exception { 278 EasyMock.expect(mMockDevice.pullFile((String) EasyMock.anyObject())) 279 .andReturn(null).once(); 280 EasyMock.replay(mMockDevice); 281 282 mAtrace.onTestEnd( 283 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 284 } 285 286 /** 287 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that it uploads its file 288 * correctly with compression on. 289 * 290 * <p>Expect that testLog is called with the proper filename and LogDataType. 291 */ 292 @Test 293 public void testUploadsLogWithCompression() throws Exception { 294 EasyMock.expect(mMockDevice.pullFile((String) EasyMock.anyObject())) 295 .andStubReturn(new File("/tmp/potato")); 296 EasyMock.expect(mMockDevice.getSerialNumber()).andStubReturn(M_SERIAL_NO); 297 mMockTestLogger.testLog( 298 EasyMock.eq("atrace" + M_SERIAL_NO), 299 EasyMock.eq(LogDataType.ATRACE), 300 EasyMock.anyObject()); 301 EasyMock.expectLastCall().times(1); 302 EasyMock.replay(mMockDevice, mMockTestLogger); 303 304 mAtrace.onTestEnd( 305 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 306 307 EasyMock.verify(mMockTestLogger); 308 } 309 310 /** 311 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that it uploads its file 312 * correctly with compression off. 313 * 314 * <p>Expect that testLog is called with the proper filename and LogDataType. 315 */ 316 @Test 317 public void testUploadsLogWithoutCompression() throws Exception { 318 EasyMock.expect(mMockDevice.pullFile((String) EasyMock.anyObject())) 319 .andStubReturn(new File("/tmp/potato")); 320 EasyMock.expect(mMockDevice.getSerialNumber()).andStubReturn(M_SERIAL_NO); 321 mMockTestLogger.testLog( 322 EasyMock.eq("atrace" + M_SERIAL_NO), 323 EasyMock.eq(LogDataType.TEXT), 324 EasyMock.anyObject()); 325 EasyMock.expectLastCall().times(1); 326 EasyMock.replay(mMockDevice, mMockTestLogger); 327 328 mOptionSetter.setOptionValue("compress-dump", "false"); 329 mAtrace.onTestEnd( 330 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 331 332 EasyMock.verify(mMockTestLogger); 333 } 334 335 /** 336 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that each device uploads 337 * a log 338 * 339 * <p>Expect that testLog is called for each device. 340 */ 341 @Test 342 public void testMultipleDeviceBehavior() throws Exception { 343 int num_devices = 3; 344 List<ITestDevice> devices = new ArrayList<ITestDevice>(); 345 for (int i = 0; i < num_devices; i++) { 346 ITestDevice device = EasyMock.createNiceMock(ITestDevice.class); 347 EasyMock.expect(device.getSerialNumber()).andStubReturn(M_SERIAL_NO); 348 EasyMock.expect(device.pullFile((String) EasyMock.anyObject())) 349 .andStubReturn(new File("/tmp/potato")); 350 EasyMock.replay(device); 351 devices.add(device); 352 } 353 IInvocationContext mockInvocationContext = 354 EasyMock.createNiceMock(IInvocationContext.class); 355 EasyMock.expect(mockInvocationContext.getDevices()) 356 .andStubReturn(devices); 357 358 mMockTestLogger.testLog( 359 (String) EasyMock.anyObject(), 360 EasyMock.eq(LogDataType.ATRACE), 361 EasyMock.anyObject()); 362 EasyMock.expectLastCall().times(num_devices); 363 EasyMock.replay(mMockTestLogger, mockInvocationContext); 364 365 AtraceCollector atrace = new AtraceCollector(); 366 OptionSetter optionSetter = new OptionSetter(atrace); 367 optionSetter.setOptionValue("categories", M_CATEGORIES); 368 atrace.init(mockInvocationContext, mMockTestLogger); 369 atrace.onTestEnd( 370 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 371 372 EasyMock.verify(mMockTestLogger); 373 } 374 375 /** 376 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that it can run trace 377 * post-processing commands on the log file 378 * 379 * <p>Expect that the executable is invoked and testLog is called for the trace data process. 380 */ 381 @Test 382 public void testExecutesPostProcessPar() throws Exception { 383 CommandResult commandResult = new CommandResult(CommandStatus.SUCCESS); 384 commandResult.setStdout("stdout"); 385 commandResult.setStderr("stderr"); 386 EasyMock.expect( 387 mMockRunUtil.runTimedCmd( 388 EasyMock.eq(60L), 389 EasyMock.eq(mDummyBinary.getAbsolutePath()), 390 EasyMock.eq("-i"), 391 EasyMock.eq(M_TRACE_PATH_NAME), 392 EasyMock.eq("--switch1"))) 393 .andReturn(commandResult) 394 .times(1); 395 396 mMockTestLogger.testLog( 397 EasyMock.eq("atrace" + M_SERIAL_NO), 398 EasyMock.eq(LogDataType.ATRACE), 399 EasyMock.anyObject()); 400 EasyMock.expectLastCall().times(1); 401 EasyMock.replay(mMockTestLogger, mMockRunUtil, mMockDevice); 402 403 //test 404 mOptionSetter.setOptionValue("post-process-binary", mDummyBinary.getAbsolutePath()); 405 mOptionSetter.setOptionValue("post-process-input-file-key", "TRACEF"); 406 mOptionSetter.setOptionValue("post-process-args", "-i"); 407 mOptionSetter.setOptionValue("post-process-args", "TRACEF"); 408 mOptionSetter.setOptionValue("post-process-args", "--switch1"); 409 mOptionSetter.setOptionValue("post-process-timeout", "60"); 410 mAtrace.setRunUtil(mMockRunUtil); 411 mAtrace.onTestEnd( 412 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 413 414 EasyMock.verify(mMockTestLogger, mMockRunUtil); 415 } 416 417 /** 418 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that it can run trace 419 * post-processing commands on the log file for executables who don't have keyed input. 420 * 421 * <p>Expect that the executable is invoked and testLog is called for the trace data process. 422 */ 423 @Test 424 public void testExecutesPostProcessParDifferentFormat() throws Exception { 425 CommandResult commandResult = new CommandResult(CommandStatus.SUCCESS); 426 commandResult.setStdout("stdout"); 427 commandResult.setStderr("stderr"); 428 EasyMock.expect( 429 mMockRunUtil.runTimedCmd( 430 EasyMock.eq(60L), 431 EasyMock.eq(mDummyBinary.getAbsolutePath()), 432 EasyMock.eq(M_TRACE_PATH_NAME), 433 EasyMock.eq("--switch1"))) 434 .andReturn(commandResult) 435 .times(1); 436 437 mMockTestLogger.testLog( 438 EasyMock.eq("atrace" + M_SERIAL_NO), 439 EasyMock.eq(LogDataType.ATRACE), 440 EasyMock.anyObject()); 441 EasyMock.expectLastCall().times(1); 442 EasyMock.replay(mMockTestLogger, mMockRunUtil, mMockDevice); 443 444 mOptionSetter.setOptionValue("post-process-binary", mDummyBinary.getAbsolutePath()); 445 mOptionSetter.setOptionValue("post-process-input-file-key", "TRACEF"); 446 mOptionSetter.setOptionValue("post-process-args", "TRACEF"); 447 mOptionSetter.setOptionValue("post-process-args", "--switch1"); 448 mOptionSetter.setOptionValue("post-process-timeout", "60"); 449 mAtrace.setRunUtil(mMockRunUtil); 450 mAtrace.onTestEnd( 451 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 452 453 EasyMock.verify(mMockTestLogger, mMockRunUtil); 454 } 455 456 /** 457 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that it can run a 458 * post-processing command that makes no output on stderr. 459 * 460 * <p>Expect that the executable is invoked and testLog is called for the trace data process. 461 */ 462 @Test 463 public void testExecutesPostProcessParNoStderr() throws Exception { 464 CommandResult commandResult = new CommandResult(CommandStatus.SUCCESS); 465 commandResult.setStdout("stdout"); 466 EasyMock.expect( 467 mMockRunUtil.runTimedCmd( 468 EasyMock.eq(180000L), 469 EasyMock.eq(mDummyBinary.getAbsolutePath()), 470 EasyMock.eq("-i"), 471 EasyMock.eq(M_TRACE_PATH_NAME), 472 EasyMock.eq("--switch1"))) 473 .andReturn(commandResult) 474 .times(1); 475 476 mMockTestLogger.testLog( 477 EasyMock.eq("atrace" + M_SERIAL_NO), 478 EasyMock.eq(LogDataType.ATRACE), 479 EasyMock.anyObject()); 480 EasyMock.expectLastCall().times(1); 481 EasyMock.replay(mMockTestLogger, mMockRunUtil, mMockDevice); 482 483 mOptionSetter.setOptionValue("post-process-binary", mDummyBinary.getAbsolutePath()); 484 mOptionSetter.setOptionValue("post-process-input-file-key", "TRACEF"); 485 mOptionSetter.setOptionValue("post-process-args", "-i"); 486 mOptionSetter.setOptionValue("post-process-args", "TRACEF"); 487 mOptionSetter.setOptionValue("post-process-args", "--switch1"); 488 mOptionSetter.setOptionValue("post-process-timeout", "3m"); 489 mAtrace.setRunUtil(mMockRunUtil); 490 mAtrace.onTestEnd( 491 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 492 493 EasyMock.verify(mMockTestLogger, mMockRunUtil); 494 } 495 496 /** 497 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that a failing 498 * post-processing command is not fatal. 499 * 500 * <p>Expect that the executable is invoked and testLog is called for the trace data process. 501 */ 502 @Test 503 public void testExecutesPostProcessParFailed() throws Exception { 504 CommandResult commandResult = new CommandResult(CommandStatus.FAILED); 505 commandResult.setStderr("stderr"); 506 507 EasyMock.expect( 508 mMockRunUtil.runTimedCmd( 509 EasyMock.eq(60000L), 510 EasyMock.eq(mDummyBinary.getAbsolutePath()), 511 EasyMock.eq("-i"), 512 EasyMock.eq(M_TRACE_PATH_NAME), 513 EasyMock.eq("--switch1"))) 514 .andReturn(commandResult) 515 .times(1); 516 517 mMockTestLogger.testLog( 518 EasyMock.eq("atrace" + M_SERIAL_NO), 519 EasyMock.eq(LogDataType.ATRACE), 520 EasyMock.anyObject()); 521 EasyMock.expectLastCall().times(1); 522 EasyMock.replay(mMockTestLogger, mMockRunUtil, mMockDevice); 523 524 mOptionSetter.setOptionValue("post-process-binary", mDummyBinary.getAbsolutePath()); 525 mOptionSetter.setOptionValue("post-process-input-file-key", "TRACEF"); 526 mOptionSetter.setOptionValue("post-process-args", "-i"); 527 mOptionSetter.setOptionValue("post-process-args", "TRACEF"); 528 mOptionSetter.setOptionValue("post-process-args", "--switch1"); 529 mOptionSetter.setOptionValue("post-process-timeout", "1m"); 530 mAtrace.setRunUtil(mMockRunUtil); 531 mAtrace.onTestEnd( 532 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 533 534 EasyMock.verify(mMockTestLogger, mMockRunUtil); 535 } 536 537 /** 538 * Test {@link AtraceCollector#onTestEnd(DeviceMetricData, Map)} to see that a timeout of the 539 * post-processing command is not fatal. 540 * 541 * <p>Expect that timeout is not fatal. 542 */ 543 @Test 544 public void testExecutesPostProcessParTimeout() throws Exception { 545 CommandResult commandResult = new CommandResult(CommandStatus.TIMED_OUT); 546 547 EasyMock.expect( 548 mMockRunUtil.runTimedCmd( 549 EasyMock.eq(3661000L), 550 EasyMock.eq(mDummyBinary.getAbsolutePath()), 551 EasyMock.eq("-i"), 552 EasyMock.eq(M_TRACE_PATH_NAME), 553 EasyMock.eq("--switch1"))) 554 .andReturn(commandResult) 555 .times(1); 556 557 mMockTestLogger.testLog( 558 EasyMock.eq("atrace" + M_SERIAL_NO), 559 EasyMock.eq(LogDataType.ATRACE), 560 EasyMock.anyObject()); 561 EasyMock.expectLastCall().times(1); 562 EasyMock.replay(mMockTestLogger, mMockRunUtil, mMockDevice); 563 564 mOptionSetter.setOptionValue("post-process-binary", mDummyBinary.getAbsolutePath()); 565 mOptionSetter.setOptionValue("post-process-input-file-key", "TRACEF"); 566 mOptionSetter.setOptionValue("post-process-args", "-i"); 567 mOptionSetter.setOptionValue("post-process-args", "TRACEF"); 568 mOptionSetter.setOptionValue("post-process-args", "--switch1"); 569 mOptionSetter.setOptionValue("post-process-timeout", "1h1m1s"); 570 mAtrace.setRunUtil(mMockRunUtil); 571 mAtrace.onTestEnd( 572 new DeviceMetricData(mMockInvocationContext), new HashMap<String, Metric>()); 573 574 EasyMock.verify(mMockTestLogger, mMockRunUtil); 575 } 576 } 577