mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-04-27 11:22:24 +00:00
The logging package contains two functions, SetLogOptions and SetLogFile, that could experience race conditions when multiple goroutines access and modify the logger struct concurrently. To address these issues, a copy of the logger struct is now created in each function to eliminate data races. In addition, the test-go.sh script is updated to include the '-race' flag, enabling race detection during testing. This change helps prevent future race conditions by activating the Go race detector. Signed-off-by: Alina Sudakov <asudakov@redhat.com>
24 lines
777 B
Bash
Executable File
24 lines
777 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# this if... will be removed when gomodules goes default
|
|
if [ "$GO111MODULE" == "off" ]; then
|
|
echo "Warning: this will be deprecated in near future so please use go modules!"
|
|
|
|
ORG_PATH="gopkg.in/k8snetworkplumbingwg"
|
|
REPO_PATH="${ORG_PATH}/multus-cni"
|
|
|
|
if [ ! -h gopath/src/${REPO_PATH} ]; then
|
|
mkdir -p gopath/src/${ORG_PATH}
|
|
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
|
|
fi
|
|
|
|
export GO15VENDOREXPERIMENT=1
|
|
export GOBIN=${PWD}/bin
|
|
export GOPATH=${PWD}/gopath
|
|
bash -c "umask 0; cd ${GOPATH}/src/${REPO_PATH}; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} go test -v -covermode=count -coverprofile=coverage.out ./..."
|
|
else
|
|
# test with go modules
|
|
bash -c "umask 0; go test -v -race -covermode=atomic -coverprofile=coverage.out ./..."
|
|
fi
|