Cts框架解析(8)-IBuildProvider(五)

2015-01-27 22:35:41 · 作者: · 浏览: 137
nedFileMap.put(name, new VersionedFile(file, version)); } /** * {@inheritDoc} */ @Override public void cleanUp() { for (VersionedFile fileRecord : mVersionedFileMap.values()) { FileUtil.recursiveDelete(fileRecord.getFile()); } mVersionedFileMap.clear(); } /** * {@inheritDoc} */ @Override public IBuildInfo clone() { BuildInfo copy = new BuildInfo(mBuildId, mTestTag, mBuildTargetName); copy.addAllBuildAttributes(this); try { copy.addAllFiles(this); } catch (IOException e) { throw new RuntimeException(e); } copy.setBuildBranch(mBuildBranch); copy.setBuildFlavor(mBuildFlavor); return copy; } /** * {@inheritDoc} */ @Override public String getBuildFlavor() { return mBuildFlavor; } /** * {@inheritDoc} */ @Override public void setBuildFlavor(String buildFlavor) { mBuildFlavor = buildFlavor; } /** * {@inheritDoc} */ @Override public String getBuildBranch() { return mBuildBranch; } /** * {@inheritDoc} */ @Override public void setBuildBranch(String branch) { mBuildBranch = branch; } /** * {@inheritDoc} */ @Override public void setDeviceSerial(String serial) { mDeviceSerial = serial; } /** * {@inheritDoc} */ @Override public int hashCode() { return Objects.hashCode(mBuildAttributes, mBuildBranch, mBuildFlavor, mBuildId, mBuildTargetName, mTestTag, mDeviceSerial); } /** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } BuildInfo other = (BuildInfo) obj; return Objects.equal(mBuildAttributes, other.mBuildAttributes) && Objects.equal(mBuildBranch, other.mBuildBranch) && Objects.equal(mBuildFlavor, other.mBuildFlavor) && Objects.equal(mBuildId, other.mBuildId) && Objects.equal(mBuildTargetName, other.mBuildTargetName) && Objects.equal(mTestTag, other.mTestTag) && Objects.equal(mDeviceSerial, other.mDeviceSerial); } }
提供的属性有build的id号,build的目标名称,测试标签,根目录,build的分支,测试类型。关机要理解build是什么意思,我还不是太了解build这个意义,暂时先用build来代替吧,等我了解了,再做解释。在原生的cts中,使用的是CtsBuildProvider,很简单的就是把cts的根目录属性设置上,然后是buildId,测试目标,build命令设置好就返回了。但是你如果要添加你自己的实现类,肯定不是简单的这么一点代码。比如你要做的测试时测试你的 系统,那么这里面提供的东西就多了。首先你的系统存放的地址,分支号,要build的版本号等等都要在这里面获取并存到buildinfo对象中返回给TestInvocation中。


/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.cts.tradefed.build;

import com.android.tradefed.build.FolderBuildInfo;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.build.IBuildProvider;
import com.android.tradefed.build.IFolderBuildInfo;
import com.android.tradefed.config.Option;

import java.io.File;

/**
 * A simple {@link IBuildProvider} that uses a pre-existing CTS install.
 */
public class CtsBuildProvider implements IBuildProvider {

    @Option(name="cts-install-path", description="the path to the cts insta