blob: 9d2eb91953c715aa6302576469b04edd18d3ad80 [file] [log] [blame]
Julien Desprezece3f402016-11-21 15:56:56 +00001/*
2 * Copyright (C) 2016 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 */
16package com.android.tradefed.suite.checker;
17
18import com.android.tradefed.device.DeviceNotAvailableException;
19import com.android.tradefed.device.ITestDevice;
Julien Desprez3e4d47d2018-05-23 15:53:40 -070020import com.android.tradefed.suite.checker.StatusCheckerResult.CheckStatus;
Julien Desprezece3f402016-11-21 15:56:56 +000021
22/**
Julien Desprez3e4d47d2018-05-23 15:53:40 -070023 * An checker that performs checks on system status and returns a boolean to indicate if the system
24 * is in an expected state. Such check maybe performed either prior to or after a module execution.
25 *
26 * <p>Note: the checker must be reentrant: meaning that the same instance will be called multiple
Julien Desprezece3f402016-11-21 15:56:56 +000027 * times for each module executed, so it should not leave a state so as to interfere with the checks
28 * to be performed for the following modules.
Julien Desprez3e4d47d2018-05-23 15:53:40 -070029 *
30 * <p>The return {@link StatusCheckerResult} describing the results. May have an error message set
31 * in case of failure.
Julien Desprezece3f402016-11-21 15:56:56 +000032 */
33public interface ISystemStatusChecker {
34
35 /**
36 * Check system condition before test module execution. Subclass should override this method if
37 * a check is desirable here. Implementation must return a <code>boolean</code> value to
38 * indicate if the status check has passed or failed.
Julien Desprez3e4d47d2018-05-23 15:53:40 -070039 *
40 * <p>It's strongly recommended that system status be checked <strong>after</strong> module
41 * execution, and this method may be used for the purpose of caching certain system state prior
42 * to module execution.
Julien Desprezece3f402016-11-21 15:56:56 +000043 *
44 * @param device The {@link ITestDevice} on which to run the checks.
45 * @return result of system status check
46 * @throws DeviceNotAvailableException
47 */
Julien Desprez3e4d47d2018-05-23 15:53:40 -070048 public default StatusCheckerResult preExecutionCheck(ITestDevice device)
Julien Desprezece3f402016-11-21 15:56:56 +000049 throws DeviceNotAvailableException {
Julien Desprez3e4d47d2018-05-23 15:53:40 -070050 return new StatusCheckerResult(CheckStatus.SUCCESS);
Julien Desprezece3f402016-11-21 15:56:56 +000051 }
52
53 /**
Julien Desprez3e4d47d2018-05-23 15:53:40 -070054 * Check system condition after test module execution. Subclass should override this method if a
55 * check is desirable here. Implementation must return a <code>boolean</code> value to indicate
56 * if the status check has passed or failed.
Julien Desprezece3f402016-11-21 15:56:56 +000057 *
58 * @param device The {@link ITestDevice} on which to run the checks.
59 * @return result of system status check
60 * @throws DeviceNotAvailableException
61 */
Julien Desprez3e4d47d2018-05-23 15:53:40 -070062 public default StatusCheckerResult postExecutionCheck(ITestDevice device)
Julien Desprezece3f402016-11-21 15:56:56 +000063 throws DeviceNotAvailableException {
Julien Desprez3e4d47d2018-05-23 15:53:40 -070064 return new StatusCheckerResult(CheckStatus.SUCCESS);
Julien Desprezece3f402016-11-21 15:56:56 +000065 }
66}