Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robot: Add API option to subject upload. #1130

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion cmd/robot/subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func init() {
Name: "subject",
ShortHelp: "Upload a traceable application to the server",
ShortUsage: "<filenames>",
Action: &subjectUploadVerb{RobotOptions: defaultRobotOptions},
Action: &subjectUploadVerb{RobotOptions: defaultRobotOptions, API: GLESAPI},
})
searchVerb.Add(&app.Verb{
Name: "subject",
Expand All @@ -46,8 +46,28 @@ func init() {
})
}

const (
GLESAPI APIType = iota
VulkanAPI
)

type APIType uint8

var apiTypeToName = map[APIType]string{
GLESAPI: "gles",
VulkanAPI: "vulkan",
}

func (a *APIType) Choose(c interface{}) {
*a = c.(APIType)
}
func (a APIType) String() string {
return apiTypeToName[a]
}

type subjectUploadVerb struct {
RobotOptions
API APIType `help:"the api to capture, can be either gles or vulkan (default:gles)"`
TraceTime time.Duration `help:"trace time override (if non-zero)"`
subjects subject.Subjects
}
Expand All @@ -64,6 +84,7 @@ func (v *subjectUploadVerb) process(ctx context.Context, id string) error {
if v.TraceTime != 0 {
hints = &subject.Hints{TraceTime: ptypes.DurationProto(v.TraceTime)}
}
hints.API = v.API.String()
subject, created, err := v.subjects.Add(ctx, id, hints)
if err != nil {
return log.Err(ctx, err, "Failed processing subject")
Expand Down
2 changes: 2 additions & 0 deletions test/robot/subject/subject.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ message Subject {
message Hints {
// traceTime is the preferred duration for tracing this subject.
google.protobuf.Duration traceTime = 1;
// API is the name of the api to capture on this subject, values can be gles and vulkan
string API = 4;
}

// Service is the api to the robot app storage.
Expand Down
1 change: 1 addition & 0 deletions test/robot/trace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func doTrace(ctx context.Context, action string, in *Input, store *stash.Client,
"-observe-frames", "5",
"-record-errors",
"-gapii-device", d.Instance().Serial,
"-api", in.GetHints().GetAPI(),
}
cmd := shell.Command(gapit.System(), params...)
output, callErr := cmd.Call(ctx)
Expand Down