1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16package tester 17 18import "context" 19 20type ResultStatus string 21 22const ( 23 ResultPass = `pass` 24 ResultOccasionalFail = `occasional_fail` 25 ResultFail = `fail` 26) 27 28type Result struct { 29 TestCaseName string 30 Status ResultStatus 31} 32 33type Tester interface { 34 // TaskName returns the name of task which DoTestTask execute. 35 TaskName() string 36 // Prepare do some test preparations for one certain package 37 Prepare(pkgDir string, device string, ctx context.Context) error 38 // DoTestTask do a full test on given device. 39 DoTestTask(device string, ctx context.Context) ([]Result, error) 40 // DoTestCase do a single testcase on given device. 41 DoTestCase(device string, testCase string, ctx context.Context) (Result, error) 42 // DoTestCases do testcases on given device. 43 DoTestCases(device string, testcases []string, ctx context.Context) ([]Result, error) 44} 45 46type NewFunc func() Tester 47