@@ -16,10 +16,11 @@ package main
1616
1717import (
1818 "archive/zip"
19- "io "
19+ "errors "
2020 "log"
2121 "os"
2222 "path/filepath"
23+ "regexp"
2324 "testing"
2425
2526 "github.com/google/android-cuttlefish/e2etests/orchestration/common"
@@ -48,18 +49,15 @@ func TestBugReport(t *testing.T) {
4849 if err != nil {
4950 t .Fatal (err )
5051 }
52+
5153 zipFilename , err := createBugReport (srv , cvd .Group )
54+
5255 if err != nil {
5356 t .Fatalf ("failed creating bugreport: %s" , err )
5457 }
55-
56- if err := assertZipIntegrity (zipFilename ); err != nil {
57- t .Errorf ("invalid zip file: %s" , err )
58+ if err := assertAdbBugReportIsIncluded (zipFilename ); err != nil {
59+ t .Errorf ("failed adb bugreport check: %s" , err )
5860 }
59- // TODO(b/508663354): include adb bug report is broken
60- // if err := assertAdbBugReportIsIncluded(zipFilename); err != nil {
61- // t.Errorf("failed adb bugreport check: %s", err)
62- // }
6361}
6462
6563func createBugReport (srv hoclient.HostOrchestratorClient , group string ) (string , error ) {
@@ -73,8 +71,7 @@ func createBugReport(srv hoclient.HostOrchestratorClient, group string) (string,
7371 return "" , err
7472 }
7573 opts := hoclient.CreateBugReportOpts {
76- // TODO(b/508663354): include adb bug report is broken
77- // IncludeADBBugReport: true,
74+ IncludeADBBugReport : true ,
7875 }
7976 if err := srv .CreateBugReport (group , opts , f ); err != nil {
8077 return "" , err
@@ -85,43 +82,20 @@ func createBugReport(srv hoclient.HostOrchestratorClient, group string) (string,
8582 return filename , nil
8683}
8784
88- // The zip file is verified checking for errors extracting
89- // each file in the archive.
90- func assertZipIntegrity (filename string ) error {
85+ func assertAdbBugReportIsIncluded (filename string ) error {
9186 r , err := zip .OpenReader (filename )
9287 if err != nil {
9388 return err
9489 }
9590 defer r .Close ()
91+ re , err := regexp .Compile (`^bugreport-aosp_cf_x86_64_only_phone.*\.zip$` )
92+ if err != nil {
93+ return err
94+ }
9695 for _ , f := range r .File {
97- rc , err := f .Open ()
98- if err != nil {
99- return err
100- }
101- _ , readErr := io .Copy (io .Discard , rc )
102- rc .Close ()
103- if readErr != nil {
104- return readErr
96+ if re .MatchString (f .FileHeader .Name ) {
97+ return nil
10598 }
10699 }
107- return nil
100+ return errors . New ( "not found" )
108101}
109-
110- // TODO(b/508663354): include adb bug report is broken
111- // func assertAdbBugReportIsIncluded(filename string) error {
112- // r, err := zip.OpenReader(filename)
113- // if err != nil {
114- // return err
115- // }
116- // defer r.Close()
117- // re, err := regexp.Compile(`^bugreport-aosp_cf_x86_64_only_phone.*\.zip$`)
118- // if err != nil {
119- // return err
120- // }
121- // for _, f := range r.File {
122- // if re.MatchString(f.FileHeader.Name) {
123- // return nil
124- // }
125- // }
126- // return errors.New("not found")
127- // }
0 commit comments