Add CUJ tests
Add a cuj_tests binary that runs through a sequence of critical user journey builds and collects metrics. Bug: 145688720 Test: cuj_tests Change-Id: I6bb1a3fc4a458fd8cea7b7c924f565d0cf3e6df3
This commit is contained in:
@@ -19,9 +19,9 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"android/soong/ui/metrics/metrics_proto"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
soong_metrics_proto "android/soong/ui/metrics/metrics_proto"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -137,13 +137,32 @@ func (m *Metrics) SetBuildDateTime(date_time string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Metrics) Serialize() (data []byte, err error) {
|
||||
return proto.Marshal(&m.metrics)
|
||||
}
|
||||
|
||||
// exports the output to the file at outputPath
|
||||
func (m *Metrics) Dump(outputPath string) (err error) {
|
||||
data, err := m.Serialize()
|
||||
return writeMessageToFile(&m.metrics, outputPath)
|
||||
}
|
||||
|
||||
type CriticalUserJourneysMetrics struct {
|
||||
cujs soong_metrics_proto.CriticalUserJourneysMetrics
|
||||
}
|
||||
|
||||
func NewCriticalUserJourneysMetrics() *CriticalUserJourneysMetrics {
|
||||
return &CriticalUserJourneysMetrics{}
|
||||
}
|
||||
|
||||
func (c *CriticalUserJourneysMetrics) Add(name string, metrics *Metrics) {
|
||||
c.cujs.Cujs = append(c.cujs.Cujs, &soong_metrics_proto.CriticalUserJourneyMetrics{
|
||||
Name: proto.String(name),
|
||||
Metrics: &metrics.metrics,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *CriticalUserJourneysMetrics) Dump(outputPath string) (err error) {
|
||||
return writeMessageToFile(&c.cujs, outputPath)
|
||||
}
|
||||
|
||||
func writeMessageToFile(pb proto.Message, outputPath string) (err error) {
|
||||
data, err := proto.Marshal(pb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user