hs-test: added a test counter and time elapsed 06/41906/2
authorAdrian Villin <[email protected]>
Wed, 11 Dec 2024 08:56:29 +0000 (09:56 +0100)
committerFlorin Coras <[email protected]>
Thu, 12 Dec 2024 19:54:53 +0000 (19:54 +0000)
- only works when not running in parallel

Type: test

Change-Id: Iab9881f8a2a93c6ef5129742e3c0ad950f9e5328
Signed-off-by: Adrian Villin <[email protected]>
extras/hs-test/infra/hst_suite.go

index 1e189b6..78cabb3 100644 (file)
@@ -104,6 +104,19 @@ type StringerStruct struct {
        Label string
 }
 
+var testCounter uint16
+var startTime time.Time = time.Now()
+
+func testCounterFunc() {
+       if ParallelTotal.Value.String() != "1" {
+               return
+       }
+       testCounter++
+       fmt.Printf("Test counter: %d\n"+
+               "Time elapsed: %.2fs\n",
+               testCounter, time.Since(startTime).Seconds())
+}
+
 // ColorableString for ReportEntry to use
 func (s StringerStruct) ColorableString() string {
        return fmt.Sprintf("{{red}}%s{{/}}", s.Label)
@@ -233,6 +246,7 @@ func (s *HstSuite) SkipIfUnconfiguring() {
 }
 
 func (s *HstSuite) SetupTest() {
+       testCounterFunc()
        s.Log("[* TEST SETUP]")
        s.StartedContainers = s.StartedContainers[:0]
        s.SkipIfUnconfiguring()