1 /* 2 * Copyright (C) 2010 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.build; 17 18 import com.android.tradefed.device.ITestDevice; 19 20 import java.io.File; 21 import java.io.Serializable; 22 import java.util.Collection; 23 import java.util.Map; 24 25 /** Holds information about the build under test. */ 26 public interface IBuildInfo extends Serializable { 27 28 /** 29 * Default value when build ID is unknown. 30 */ 31 public final static String UNKNOWN_BUILD_ID = "-1"; 32 33 /** 34 * Returns the unique identifier of build under test. Should never be null. Defaults to 35 * {@link #UNKNOWN_BUILD_ID}. 36 */ 37 public String getBuildId(); 38 39 /** 40 * Sets the unique identifier of build under test. Should never be null. 41 */ 42 public void setBuildId(String buildId); 43 44 /** 45 * Return a unique name for the tests being run. 46 */ 47 public String getTestTag(); 48 49 /** 50 * Sets the unique name for the tests being run. 51 */ 52 public void setTestTag(String testTag); 53 54 /** 55 * Return complete name for the build being tested. 56 * <p/> 57 * A common implementation is to construct the build target name from a combination of 58 * the build flavor and branch name. [ie (branch name)-(build flavor)] 59 */ 60 public String getBuildTargetName(); 61 62 /** 63 * Optional method to return the type of build being tested. 64 * <p/> 65 * A common implementation for Android platform builds is to return 66 * (build product)-(build os)-(build variant). 67 * ie generic-linux-userdebug 68 * 69 * @return the build flavor or <code>null</code> if unset/not applicable 70 */ 71 public String getBuildFlavor(); 72 73 /** 74 * @return the {@link ITestDevice} serial that this build was executed on. Returns <code>null 75 * </code> if no device is associated with this build. 76 */ 77 public String getDeviceSerial(); 78 79 /** 80 * Set the build flavor. 81 * 82 * @param buildFlavor 83 */ 84 public void setBuildFlavor(String buildFlavor); 85 86 /** 87 * Optional method to return the source control branch that the build being tested was 88 * produced from. 89 * 90 * @return the build branch or <code>null</code> if unset/not applicable 91 */ 92 public String getBuildBranch(); 93 94 /** 95 * Set the build branch 96 * 97 * @param branch the branch name 98 */ 99 public void setBuildBranch(String branch); 100 101 /** 102 * Set the {@link ITestDevice} serial associated with this build. 103 * 104 * @param serial the serial number of the {@link ITestDevice} that this build was executed with. 105 */ 106 public void setDeviceSerial(String serial); 107 108 /** 109 * Get a set of name-value pairs of additional attributes describing the build. 110 * 111 * @return a {@link Map} of build attributes. Will not be <code>null</code>, but may be empty. 112 */ 113 public Map<String, String> getBuildAttributes(); 114 115 /** 116 * Add a build attribute 117 * 118 * @param attributeName the unique attribute name 119 * @param attributeValue the attribute value 120 */ 121 public void addBuildAttribute(String attributeName, String attributeValue); 122 123 124 /** 125 * Helper method to retrieve a file with given name. 126 * @param name 127 * @return the image file or <code>null</code> if not found 128 */ 129 public File getFile(String name); 130 131 /** 132 * Returns all {@link VersionedFile}s stored in this {@link BuildInfo}. 133 */ 134 public Collection<VersionedFile> getFiles(); 135 136 /** 137 * Helper method to retrieve a file version with given name. 138 * @param name 139 * @return the image version or <code>null</code> if not found 140 */ 141 public String getVersion(String name); 142 143 /** 144 * Stores an file with given name in this build info. 145 * 146 * @param name the unique name of the file 147 * @param file the local {@link File} 148 * @param version the file version 149 */ 150 public void setFile(String name, File file, String version); 151 152 /** 153 * Clean up any temporary build files 154 */ 155 public void cleanUp(); 156 157 /** 158 * Clones the {@link IBuildInfo} object. 159 */ 160 public IBuildInfo clone(); 161 } 162