go.ligato.io/vpp-agent/v3@v3.5.0/tests/e2e/main_test.go (about)

     1  //  Copyright (c) 2020 Cisco and/or its affiliates.
     2  //
     3  //  Licensed under the Apache License, Version 2.0 (the "License");
     4  //  you may not use this file except in compliance with the License.
     5  //  You may obtain a copy of the License at:
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  //  Unless required by applicable law or agreed to in writing, software
    10  //  distributed under the License is distributed on an "AS IS" BASIS,
    11  //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  //  See the License for the specific language governing permissions and
    13  //  limitations under the License.
    14  
    15  package e2e
    16  
    17  import (
    18  	"flag"
    19  	"log"
    20  	"os"
    21  	"testing"
    22  
    23  	"github.com/sirupsen/logrus"
    24  	govppcore "go.fd.io/govpp/core"
    25  
    26  	"go.ligato.io/vpp-agent/v3/tests/e2e/e2etest"
    27  	"go.ligato.io/vpp-agent/v3/tests/testutils"
    28  )
    29  
    30  func TestMain(m *testing.M) {
    31  	debugFlag := flag.Bool("debug", false, "Turn on debug mode.")
    32  	// Detect if GitHub Workflow debug flag is set.
    33  	debugEnv := os.Getenv("RUNNER_DEBUG") != "" && os.Getenv("GITHUB_WORKFLOW") != ""
    34  	log.SetFlags(log.Lmicroseconds | log.Lshortfile)
    35  	flag.Parse()
    36  	e2etest.Debug = *debugFlag || debugEnv
    37  	if e2etest.Debug {
    38  		logrus.SetLevel(logrus.DebugLevel)
    39  		govppcore.SetLogLevel(logrus.DebugLevel)
    40  	}
    41  	if testutils.RunTestSuite("e2e") {
    42  		result := m.Run()
    43  		os.Exit(result)
    44  	}
    45  }