1 /* 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 */ 16 17 package com.android.compatibility.testtype; 18 19 import com.android.tradefed.config.Option; 20 import com.android.tradefed.device.DeviceNotAvailableException; 21 import com.android.tradefed.result.ITestInvocationListener; 22 import com.android.tradefed.testtype.AndroidJUnitTest; 23 import com.android.tradefed.util.ArrayUtil; 24 25 import java.util.ArrayList; 26 import java.util.List; 27 28 /** 29 * A specialized test type for Libcore tests that provides the ability to specify a set of 30 * expectation files. Expectation files are used to indicate tests that are expected to fail, 31 * often because they come from upstream projects, and should not be run under CTS. 32 */ 33 public class LibcoreTest extends AndroidJUnitTest { 34 35 private static final String INSTRUMENTATION_ARG_NAME = "core-expectations"; 36 37 @Option(name = "core-expectation", description = "Provides failure expectations for libcore " 38 + "tests via the specified file; the path must be absolute and will be resolved to " 39 + "matching bundled resource files; this parameter should be repeated for each " 40 + "expectation file") 41 private List<String> mCoreExpectations = new ArrayList<>(); 42 43 /** 44 * {@inheritDoc} 45 */ 46 @Override 47 public void run(ITestInvocationListener listener) throws DeviceNotAvailableException { 48 if (!mCoreExpectations.isEmpty()) { 49 addInstrumentationArg(INSTRUMENTATION_ARG_NAME, ArrayUtil.join(",", mCoreExpectations)); 50 } 51 super.run(listener); 52 } 53 } 54