1 /* 2 * Copyright (C) 2017 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.compatibility.common.tradefed.build; 17 18 import com.android.tradefed.build.IBuildInfo; 19 import com.android.tradefed.log.LogUtil.CLog; 20 import com.android.tradefed.testtype.suite.TestSuiteInfo; 21 22 import java.io.File; 23 import java.io.FileNotFoundException; 24 25 /** 26 * A simple helper that stores and retrieves information from a {@link IBuildInfo}. 27 */ 28 public class VtsCompatibilityInvocationHelper { 29 private File mTestCasesDir = null; 30 31 /** 32 * Get test case binaries directory 33 */ getTestsDir()34 public File getTestsDir() throws FileNotFoundException { 35 if (mTestCasesDir == null) { 36 String testCasesRootDirPath; 37 testCasesRootDirPath = System.getenv( 38 String.format("%s_TESTCASES", TestSuiteInfo.getInstance().getName())); 39 File testCaseDir; 40 if (testCasesRootDirPath != null && !testCasesRootDirPath.trim().equals("")) { 41 testCaseDir = new File(testCasesRootDirPath); 42 } else { 43 String rootDirPath; 44 rootDirPath = System.getProperty( 45 String.format("%s_ROOT", TestSuiteInfo.getInstance().getName())); 46 if (rootDirPath == null || rootDirPath.trim().equals("")) { 47 throw new IllegalArgumentException( 48 String.format("Missing install path property %s_ROOT", 49 TestSuiteInfo.getInstance().getName())); 50 } 51 testCaseDir = new File(rootDirPath, "android-vts/testcases"); 52 } 53 if (!testCaseDir.exists()) { 54 throw new FileNotFoundException(String.format( 55 "Root directory doesn't exist %s", testCaseDir.getAbsolutePath())); 56 } 57 mTestCasesDir = testCaseDir.getAbsoluteFile(); 58 CLog.d(String.format( 59 "%s TEST CASES DIR: %s", TestSuiteInfo.getInstance().getName(), mTestCasesDir)); 60 } 61 62 return mTestCasesDir; 63 } 64 }