1 /* 2 * Copyright (C) 2018 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.sandbox; 17 18 import com.android.tradefed.config.Option; 19 import com.android.tradefed.config.OptionClass; 20 21 import java.io.File; 22 23 /** Class that can receive and provide options to a {@link ISandbox}. */ 24 @OptionClass(alias = "sandbox", global_namespace = true) 25 public final class SandboxOptions { 26 27 public static final String TF_LOCATION = "tf-location"; 28 public static final String SANDBOX_BUILD_ID = "sandbox-build-id"; 29 public static final String USE_PROTO_REPORTER = "use-proto-reporter"; 30 public static final String CHILD_GLOBAL_CONFIG = "sub-global-config"; 31 public static final String PARENT_PREPARER_CONFIG = "parent-preparer-config"; 32 public static final String WAIT_FOR_EVENTS_TIMEOUT = "wait-for-events"; 33 34 @Option( 35 name = TF_LOCATION, 36 description = "The path to the Tradefed binary of the version to use for the sandbox." 37 ) 38 private File mTfVersion = null; 39 40 @Option( 41 name = SANDBOX_BUILD_ID, 42 description = 43 "Provide the build-id to force the sandbox version of Tradefed to be." 44 + "Mutually exclusive with the tf-location option." 45 ) 46 private String mBuildId = null; 47 48 @Option( 49 name = USE_PROTO_REPORTER, 50 description = "Whether or not to use protobuf format reporting between processes." 51 ) 52 private boolean mUseProtoReporter = true; 53 54 @Option( 55 name = CHILD_GLOBAL_CONFIG, 56 description = 57 "Force a particular configuration to be used as global configuration for the" 58 + " sandbox.") 59 private String mChildGlobalConfig = null; 60 61 @Option( 62 name = PARENT_PREPARER_CONFIG, 63 description = 64 "A configuration which target_preparers will be run in the parent of the sandbox." 65 ) 66 private String mParentPreparerConfig = null; 67 68 @Option( 69 name = WAIT_FOR_EVENTS_TIMEOUT, 70 isTimeVal = true, 71 description = 72 "The time we should wait for all events to complete after the " 73 + "sandbox is done running." 74 ) 75 private long mWaitForEventsTimeoutMs = 30000L; 76 77 /** 78 * Returns the provided directories containing the Trade Federation version to use for 79 * sandboxing the run. 80 */ getSandboxTfDirectory()81 public File getSandboxTfDirectory() { 82 return mTfVersion; 83 } 84 85 /** Returns the build-id forced for the sandbox to be used during the run. */ getSandboxBuildId()86 public String getSandboxBuildId() { 87 return mBuildId; 88 } 89 90 /** Returns whether or not protobuf reporting should be used. */ shouldUseProtoReporter()91 public boolean shouldUseProtoReporter() { 92 return mUseProtoReporter; 93 } 94 95 /** 96 * Returns the configuration to be used for the child sandbox. Or null if the parent one should 97 * be used. 98 */ getChildGlobalConfig()99 public String getChildGlobalConfig() { 100 return mChildGlobalConfig; 101 } 102 103 /** Returns the configuration which preparer should run in the parent process of the sandbox. */ getParentPreparerConfig()104 public String getParentPreparerConfig() { 105 return mParentPreparerConfig; 106 } 107 108 /** 109 * Returns the time we should wait for events to be processed after the sandbox is done running. 110 */ getWaitForEventsTimeout()111 public long getWaitForEventsTimeout() { 112 return mWaitForEventsTimeoutMs; 113 } 114 } 115