• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.testtype.binary;
17 
18 import com.android.tradefed.config.Option;
19 import com.android.tradefed.config.OptionClass;
20 import com.android.tradefed.device.DeviceNotAvailableException;
21 import com.android.tradefed.device.ITestDevice;
22 import com.android.tradefed.result.ITestInvocationListener;
23 import com.android.tradefed.result.TestDescription;
24 import com.android.tradefed.testtype.IDeviceTest;
25 import com.android.tradefed.util.CommandResult;
26 import com.android.tradefed.util.CommandStatus;
27 import java.io.IOException;
28 import java.util.concurrent.TimeUnit;
29 
30 /**
31  * Test runner for executable running on the target and parsing tesult of kernel test.
32  */
33 @OptionClass(alias = "kernel-target-test")
34 public class KernelTargetTest extends ExecutableTargetTest {
35     @Option(name = "ignore-binary-check", description = "Ignore the binary check in findBinary().")
36     private boolean mIgnoreBinaryCheck = false;
37     @Option(name = "exit-code-skip", description = "Exit code for skipped tests.")
38     private int mExitCodeSkip = 32;
39 
40     @Override
findBinary(String binary)41     public String findBinary(String binary) throws DeviceNotAvailableException {
42         if (mIgnoreBinaryCheck)
43             return binary;
44         return super.findBinary(binary);
45     }
46 
47     /**
48      * Check the result of the test command.
49      *
50      * @param result test result of the command {@link CommandResult}
51      * @param listener the {@link ITestInvocationListener}
52      * @param description The test in progress.
53      */
checkCommandResult( CommandResult result, ITestInvocationListener listener, TestDescription description)54     protected void checkCommandResult(
55             CommandResult result, ITestInvocationListener listener, TestDescription description) {
56         if (result.getExitCode() == mExitCodeSkip) {
57             listener.testIgnored(description);
58         } else {
59             super.checkCommandResult(result, listener, description);
60         }
61     }
62 }
63