1 /* 2 * Copyright (C) 2018 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 package com.android.tradefed.result; 17 18 import com.android.ddmlib.testrunner.TestIdentifier; 19 import com.android.tradefed.build.IBuildInfo; 20 import com.android.tradefed.invoker.IInvocationContext; 21 import com.android.tradefed.log.LogUtil.CLog; 22 import com.android.tradefed.util.SubprocessEventHelper.BaseTestEventInfo; 23 import com.android.tradefed.util.SubprocessEventHelper.FailedTestEventInfo; 24 import com.android.tradefed.util.SubprocessEventHelper.InvocationStartedEventInfo; 25 import com.android.tradefed.util.SubprocessEventHelper.TestEndedEventInfo; 26 import com.android.tradefed.util.SubprocessEventHelper.TestStartedEventInfo; 27 import com.android.tradefed.util.SubprocessTestResultsParser; 28 29 import java.util.Map; 30 31 /** 32 * A class for freezed subprocess results reporter which is compatible with M & N version of CTS. 33 * Methods in this class were part of ITestInvocationListener in pre-O version of TF/CTS. Changes 34 * are not supposed to be made on this class. 35 */ 36 public final class LegacySubprocessResultsReporter extends SubprocessResultsReporter { 37 38 /** Legacy method, only used for pre-O cts test */ 39 public void testAssumptionFailure(TestIdentifier testId, String trace) { 40 FailedTestEventInfo info = 41 new FailedTestEventInfo(testId.getClassName(), testId.getTestName(), trace); 42 printEvent(SubprocessTestResultsParser.StatusKeys.TEST_ASSUMPTION_FAILURE, info); 43 } 44 45 /** Legacy method, only used for pre-O cts test */ 46 public void testEnded(TestIdentifier testId, Map<String, String> metrics) { 47 testEnded(testId, System.currentTimeMillis(), metrics); 48 } 49 50 /** Legacy method, only used for pre-O cts test */ 51 public void testEnded(TestIdentifier testId, long endTime, Map<String, String> metrics) { 52 TestEndedEventInfo info = 53 new TestEndedEventInfo( 54 testId.getClassName(), testId.getTestName(), endTime, metrics); 55 printEvent(SubprocessTestResultsParser.StatusKeys.TEST_ENDED, info); 56 } 57 58 /** Legacy method, only used for pre-O cts test */ 59 public void testFailed(TestIdentifier testId, String reason) { 60 FailedTestEventInfo info = 61 new FailedTestEventInfo(testId.getClassName(), testId.getTestName(), reason); 62 printEvent(SubprocessTestResultsParser.StatusKeys.TEST_FAILED, info); 63 } 64 65 /** Legacy method, only used for pre-O cts test */ 66 public void testIgnored(TestIdentifier testId) { 67 BaseTestEventInfo info = new BaseTestEventInfo(testId.getClassName(), testId.getTestName()); 68 printEvent(SubprocessTestResultsParser.StatusKeys.TEST_IGNORED, info); 69 } 70 71 /** Legacy method, only used for pre-O cts test */ 72 public void testStarted(TestIdentifier testId) { 73 testStarted(testId, System.currentTimeMillis()); 74 } 75 76 /** Legacy method, only used for pre-O cts test */ 77 public void testStarted(TestIdentifier testId, long startTime) { 78 TestStartedEventInfo info = 79 new TestStartedEventInfo(testId.getClassName(), testId.getTestName(), startTime); 80 printEvent(SubprocessTestResultsParser.StatusKeys.TEST_STARTED, info); 81 } 82 83 /** Legacy method, only used for pre-O cts test */ 84 public void invocationStarted(IBuildInfo buildInfo) { 85 InvocationStartedEventInfo info = 86 new InvocationStartedEventInfo(buildInfo.getTestTag(), System.currentTimeMillis()); 87 printEvent(SubprocessTestResultsParser.StatusKeys.INVOCATION_STARTED, info); 88 } 89 90 /** A intentionally inop function to handle incompatibility problem in CTS 8.1 */ 91 @Override 92 public void testModuleStarted(IInvocationContext moduleContext) { 93 CLog.d("testModuleStarted is called but ignored intentionally"); 94 } 95 96 /** A intentionally inop function to handle incompatibility problem in CTS 8.1 */ 97 @Override 98 public void testModuleEnded() { 99 CLog.d("testModuleEnded is called but ignored intentionally"); 100 } 101 102 } 103