From 85a544d671be739732d43114a4d2f05dc6a628ef Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 20 Oct 2017 23:30:36 +0200 Subject: [PATCH] avoid unnecessary data race error in test cases --- testing/scenarios/dokodemo_test.go | 22 ++-- testing/scenarios/shadowsocks_test.go | 60 ++++----- testing/scenarios/vmess_test.go | 182 +++++++++++++------------- 3 files changed, 132 insertions(+), 132 deletions(-) diff --git a/testing/scenarios/dokodemo_test.go b/testing/scenarios/dokodemo_test.go index a1b07f61b..0c88d0eb4 100644 --- a/testing/scenarios/dokodemo_test.go +++ b/testing/scenarios/dokodemo_test.go @@ -33,6 +33,12 @@ func TestDokodemoTCP(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -55,17 +61,17 @@ func TestDokodemoTCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := uint32(pickPort()) + clientPortRange := uint32(5) + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := uint32(pickPort()) - clientPortRange := uint32(5) - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -100,12 +106,6 @@ func TestDokodemoTCP(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) diff --git a/testing/scenarios/shadowsocks_test.go b/testing/scenarios/shadowsocks_test.go index 73a9a31eb..3bfd948c5 100644 --- a/testing/scenarios/shadowsocks_test.go +++ b/testing/scenarios/shadowsocks_test.go @@ -38,6 +38,12 @@ func TestShadowsocksAES256TCP(t *testing.T) { serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -57,16 +63,16 @@ func TestShadowsocksAES256TCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -99,12 +105,6 @@ func TestShadowsocksAES256TCP(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -156,6 +156,12 @@ func TestShadowsocksAES128UDP(t *testing.T) { serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -176,16 +182,16 @@ func TestShadowsocksAES128UDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -218,12 +224,6 @@ func TestShadowsocksAES128UDP(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -275,6 +275,12 @@ func TestShadowsocksChacha20TCP(t *testing.T) { serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -294,16 +300,16 @@ func TestShadowsocksChacha20TCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -336,12 +342,6 @@ func TestShadowsocksChacha20TCP(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index 1334ce2bb..80a53fbf6 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -37,6 +37,12 @@ func TestVMessDynamicPort(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -82,16 +88,16 @@ func TestVMessDynamicPort(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -126,12 +132,6 @@ func TestVMessDynamicPort(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -172,6 +172,12 @@ func TestVMessGCM(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -195,16 +201,16 @@ func TestVMessGCM(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -243,12 +249,6 @@ func TestVMessGCM(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -295,6 +295,12 @@ func TestVMessGCMUDP(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -318,16 +324,16 @@ func TestVMessGCMUDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -366,12 +372,6 @@ func TestVMessGCMUDP(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -428,6 +428,12 @@ func TestVMessChacha20(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -451,16 +457,16 @@ func TestVMessChacha20(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -499,12 +505,6 @@ func TestVMessChacha20(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -551,6 +551,12 @@ func TestVMessNone(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -574,16 +580,16 @@ func TestVMessNone(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -622,12 +628,6 @@ func TestVMessNone(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -674,6 +674,12 @@ func TestVMessKCP(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickUDPPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -700,16 +706,16 @@ func TestVMessKCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -753,12 +759,6 @@ func TestVMessKCP(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -807,6 +807,12 @@ func TestVMessIPv6(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -830,16 +836,16 @@ func TestVMessIPv6(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -878,12 +884,6 @@ func TestVMessIPv6(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -922,6 +922,12 @@ func TestVMessGCMMux(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -945,16 +951,16 @@ func TestVMessGCMMux(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -999,12 +1005,6 @@ func TestVMessGCMMux(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig) @@ -1064,6 +1064,12 @@ func TestVMessGCMMuxUDP(t *testing.T) { userID := protocol.NewID(uuid.New()) serverPort := pickPort() serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: log.LogLevel_Debug, + ErrorLogType: log.LogType_Console, + }), + }, Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -1087,17 +1093,17 @@ func TestVMessGCMMuxUDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), }, }, + } + + clientPort := pickPort() + clientUDPPort := pickUDPPort() + clientConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&log.Config{ ErrorLogLevel: log.LogLevel_Debug, ErrorLogType: log.LogType_Console, }), }, - } - - clientPort := pickPort() - clientUDPPort := pickUDPPort() - clientConfig := &core.Config{ Inbound: []*proxyman.InboundHandlerConfig{ { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ @@ -1155,12 +1161,6 @@ func TestVMessGCMMuxUDP(t *testing.T) { }), }, }, - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: log.LogLevel_Debug, - ErrorLogType: log.LogType_Console, - }), - }, } servers, err := InitializeServerConfigs(serverConfig, clientConfig)