From 43033b8ae0070a6717e54431f7f0c50476ad4fc0 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Tue, 4 Jan 2022 02:16:19 +0300 Subject: [PATCH] sequential test --- .github/workflows/pr.yml | 2 +- .github/workflows/push.yml | 4 ++-- Makefile | 2 +- internal/raw/raw_test.go | 10 ++++------ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 075b8e7..c3a1b9e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -86,7 +86,7 @@ jobs: with: go-version: 1.16.x - name: Coverage Test - run: sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic + run: sudo go test ./... -race -p 1 -coverprofile=coverage.txt -covermode=atomic - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index bc3468c..60ef689 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -92,7 +92,7 @@ jobs: with: go-version: 1.16.x - name: Coverage Test - run: sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic + run: sudo go test ./... -race -p 1 -coverprofile=coverage.txt -covermode=atomic - name: Coverage Upload run: bash <(curl -s https://codecov.io/bash) @@ -113,7 +113,7 @@ jobs: with: go-version: 1.16.x - name: Coverage Test - run: sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic + run: sudo go test ./... -race -p 1 -coverprofile=coverage.txt -covermode=atomic - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/Makefile b/Makefile index 462a361..75481a1 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ ineffassign: ineffassign ./... test: - sudo go test ./... -v + sudo go test ./... -p 1 -v build: go build -o bin/main main.go diff --git a/internal/raw/raw_test.go b/internal/raw/raw_test.go index 7f8c8fa..2600151 100644 --- a/internal/raw/raw_test.go +++ b/internal/raw/raw_test.go @@ -2,15 +2,12 @@ package raw import ( "context" - "github.com/stretchr/testify/assert" "math/rand" - "sync" "testing" "time" ) func TestStartFlooding(t *testing.T) { - var m sync.Mutex srcIps := getIps() srcPorts := getPorts() macAddrs := getMacAddrs() @@ -42,10 +39,11 @@ func TestStartFlooding(t *testing.T) { defer cancel() t.Logf("starting flood, caseName=%s, floodType=%s, floodMilliSeconds=%d\n", tc.name, tc.floodType, tc.floodMilliSeconds) go func() { - m.Lock() - defer m.Unlock() err := StartFlooding(tc.dstIp, tc.dstPort, tc.payloadLength, tc.floodType) - assert.Nil(t, err) + if err != nil { + t.Errorf("an error occured on flooding process: %s\n", err.Error()) + return + } }() select {