本文整理汇总了Golang中github.com/kedebug/golang-programming/15-440/P1-F11/lsplog.SetVerbose函数的典型用法代码示例。如果您正苦于以下问题:Golang SetVerbose函数的具体用法?Golang SetVerbose怎么用?Golang SetVerbose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetVerbose函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: runtest
func (ts *TestSystem) runtest(timeoutms int) {
lspnet.SetWriteDropPercent(ts.DropPercent)
if ts.Description != "" {
fmt.Printf("Testing: %s\n", ts.Description)
}
go ts.runserver()
for i := 0; i < ts.NClients; i++ {
go ts.runclient(i)
}
go ts.runtimeout(timeoutms)
for i := 0; i < ts.NClients; i++ {
v := <-ts.CChan
if v < 0 {
ts.RunFlag = false
ts.Tester.Logf("Test timed out after %f secs\n",
float64(timeoutms)/1000.0)
ts.Tester.FailNow()
}
}
ts.RunFlag = false
lsplog.Vlogf(0, "Passed: %d clients, %d messages/client, %.2f maxsleep, %.2f drop rate\n",
ts.NClients, ts.NMessages,
float64(ts.MaxSleepMilliseconds)/1000.0,
float64(ts.DropPercent)/100.0)
lsplog.SetVerbose(DefaultVerbosity)
lspnet.SetWriteDropPercent(0)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:27,代码来源:lsp_test.go
示例2: main
func main() {
var ihelp *bool = flag.Bool("h", false, "Print help information")
var iport *int = flag.Int("p", 6666, "Port number")
var iverb *int = flag.Int("v", 4, "Verbosity (0-6)")
var idrop *int = flag.Int("r", 0, "Network packet drop percentage")
var elim *int = flag.Int("k", 5, "Epoch limit")
var ems *int = flag.Int("d", 2000, "Epoch duration (millisecconds)")
flag.Parse()
if *ihelp {
flag.Usage()
os.Exit(0)
}
var port int = *iport
if flag.NArg() > 0 {
nread, _ := fmt.Sscanf(flag.Arg(0), "%d", &port)
if nread != 1 {
flag.Usage()
os.Exit(0)
}
}
params := &lsp.LspParams{*elim, *ems}
lsplog.SetVerbose(*iverb)
lspnet.SetWriteDropPercent(*idrop)
fmt.Printf("Establishing server on port %d\n", port)
srv, err := lsp.NewLspServer(port, params)
if err != nil {
fmt.Printf("... failed. Error message %s\n", err.Error())
} else {
runserver(srv)
}
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:32,代码来源:echoserver.go
示例3: TestBasic2
func TestBasic2(t *testing.T) {
lsplog.SetVerbose(2)
ts := NewTestSystem(t, 1, params(5, 2000))
if ts == nil {
t.FailNow()
}
ts.SetDescription("Long client/server interaction")
ts.SetNMessages(50)
ts.runtest(1000)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:10,代码来源:lsp_test.go
示例4: TestBasic3
func TestBasic3(t *testing.T) {
lsplog.SetVerbose(DefaultVerbosity)
ts := NewTestSystem(t, 2, params(5, 2000))
if ts == nil {
t.FailNow()
}
ts.SetDescription("Two client/one server interaction")
ts.SetNMessages(50)
ts.runtest(1000)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:10,代码来源:lsp_test.go
示例5: TestBasic4
func TestBasic4(t *testing.T) {
lsplog.SetVerbose(DefaultVerbosity)
ts := NewTestSystem(t, 10, params(5, 2000))
if ts == nil {
t.FailNow()
}
ts.SetDescription("10 clients, long interaction")
ts.SetNMessages(50)
ts.runtest(2000)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:10,代码来源:lsp_test.go
示例6: TestBasic6
func TestBasic6(t *testing.T) {
lsplog.SetVerbose(DefaultVerbosity)
ts := NewTestSystem(t, 2, params(5, 2000))
if ts == nil {
t.FailNow()
}
ts.SetDescription("2 clients, test wraparound of sequence numnbers")
ts.SetNMessages(550)
ts.runtest(2000)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:10,代码来源:lsp_test.go
示例7: TestSendReceive2
func TestSendReceive2(t *testing.T) {
lsplog.SetVerbose(DefaultVerbosity)
ts := NewTestSystem(t, 4, params(5, 5000))
if ts == nil {
t.FailNow()
}
ts.SetDescription("No epochs. Multiple clients")
ts.SetNMessages(6)
ts.runtest(5000)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:10,代码来源:lsp_test.go
示例8: TestRobust3
func TestRobust3(t *testing.T) {
lsplog.SetVerbose(DefaultVerbosity)
ts := NewTestSystem(t, 4, params(20, 50))
if ts == nil {
t.FailNow()
}
ts.SetDescription("Four clients. Some packet dropping")
ts.SetDropPercent(20)
ts.SetNMessages(8)
ts.runtest(15000)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:11,代码来源:lsp_test.go
示例9: TestSendReceive3
func TestSendReceive3(t *testing.T) {
lsplog.SetVerbose(DefaultVerbosity)
ts := NewTestSystem(t, 4, params(5, 10000))
if ts == nil {
t.FailNow()
}
ts.SetDescription("No epochs. Random delays inserted")
ts.SetNMessages(6)
ts.SetMaxSleepMilliseconds(100)
ts.runtest(10000)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:11,代码来源:lsp_test.go
示例10: TestBasic5
func TestBasic5(t *testing.T) {
lsplog.SetVerbose(DefaultVerbosity)
ts := NewTestSystem(t, 4, params(5, 2000))
if ts == nil {
t.FailNow()
}
ts.SetDescription("Random delays by clients & server")
ts.SetNMessages(10)
ts.SetMaxSleepMilliseconds(100)
ts.runtest(15000)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:11,代码来源:lsp_test.go
示例11: main
func main() {
var ihelp *bool = flag.Bool("h", false, "Show help information")
var iport *int = flag.Int("p", 6666, "Port number")
var ihost *string = flag.String("H", "localhost", "Host address")
var iverb *int = flag.Int("v", 4, "Verbosity (0-6)")
var irdrop *int = flag.Int("r", 0, "Network read packet drop percentage")
var iwdrop *int = flag.Int("w", 0, "Network write packet drop percentage")
var elim *int = flag.Int("k", 5, "Epoch limit")
var ems *int = flag.Int("d", 2000, "Epoch duration (millisecconds)")
flag.Parse()
if *ihelp {
flag.Usage()
os.Exit(0)
}
if flag.NArg() > 0 {
// Look for host:port on command line
ok := true
fields := strings.Split(flag.Arg(0), ":")
ok = ok && len(fields) == 2
if ok {
*ihost = fields[0]
n, err := fmt.Sscanf(fields[1], "%d", iport)
ok = ok && n == 1 && err == nil
}
if !ok {
flag.Usage()
os.Exit(0)
}
}
params := &lsp.LspParams{*elim, *ems}
lsplog.SetVerbose(*iverb)
lspnet.SetReadDropPercent(*irdrop)
lspnet.SetWriteDropPercent(*iwdrop)
hostport := fmt.Sprintf("%s:%v", *ihost, *iport)
fmt.Printf("Connecting to server at %s\n", hostport)
cli, err := lsp.NewLspClient(hostport, params)
if err != nil {
fmt.Printf("... failed. Error message %s\n", err.Error())
}
if lsplog.CheckReport(1, err) {
return
}
runclient(cli)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:45,代码来源:echoclient.go
示例12: NewSynchTestSystem
// Test components
func NewSynchTestSystem(t *testing.T, nclients int, nmessages int, mode int, maxepochs int, params *LspParams) {
fmt.Printf("Testing: Mode %s, %d clients\n", SynchModeName[mode], nclients)
ts := new(SynchTestSystem)
ts.Mode = mode
ts.Params = params
ts.C2MChan = make(chan bool)
ts.S2MChan = make(chan bool)
ts.N2MChan = make(chan bool)
ts.TChan = make(chan int)
ts.M2CChan = make(chan bool)
ts.M2SChan = make(chan bool)
ts.M2NChan = make(chan bool)
ts.Nclients = nclients
ts.Nmessages = nmessages
ts.Clients = make([]*LspClient, nclients)
ts.ClientMap = make(map[uint16]int, nclients)
ts.Data = make([][]int, nclients)
ts.Rgen = *rand.New(rand.NewSource(time.Now().Unix()))
for i := 0; i < nclients; i++ {
ts.Data[i] = genData(nmessages, ts.Rgen)
}
ts.Nclients = nclients
ts.Port = synchrandport(ts.Rgen)
ts.RunFlag = true
ts.Tester = t
go ts.RunNetwork()
go ts.RunServer()
// Set up clients
for i := 0; i < nclients; i++ {
go ts.RunClient(i)
}
go ts.RunTimeout(float64(maxepochs))
ts.Master()
ts.RunFlag = false
lsplog.SetVerbose(SynchDefaultVerbosity)
lspnet.SetWriteDropPercent(0)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:38,代码来源:lsp_s_test.go
示例13: TestServerToClient2
func TestServerToClient2(t *testing.T) {
lsplog.SetVerbose(3)
NewSynchTestSystem(t, 3, 10, doservertoclient, 12, synchparams(5, 500))
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:4,代码来源:lsp_s_test.go
示例14: TestStopServerConns2
func TestStopServerConns2(t *testing.T) {
lsplog.SetVerbose(1)
NewAuxTestSystem(t, 3, doserverstopconns, 5, auxparams(2, 500))
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:4,代码来源:lsp_x_test.go
示例15: TestStopClient2
func TestStopClient2(t *testing.T) {
lsplog.SetVerbose(1)
NewAuxTestSystem(t, 3, doclientstop, 15, auxparams(5, 500))
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:4,代码来源:lsp_x_test.go
示例16: NewAuxTestSystem
func NewAuxTestSystem(t *testing.T, nclients int, mode int, maxepochs int,
params *LspParams) {
fmt.Printf("Testing: Mode %s, %d clients\n", ModeName[mode], nclients)
ts := new(AuxTestSystem)
ts.Mode = mode
ts.Params = params
ts.ClientChan = make(chan bool)
ts.ServerChan = make(chan bool)
ts.TimeChan = make(chan bool)
ts.Clients = make([]*LspClient, nclients)
ts.Nclients = nclients
ts.Nmessages = 10
ts.Rgen = *rand.New(rand.NewSource(time.Now().Unix()))
ts.Port = randport(ts.Rgen)
ts.RunFlag = true
ts.Tester = t
go ts.BuildServer()
for i := 0; i < nclients; i++ {
go ts.BuildClient(i)
}
go ts.runtimeout(float64(maxepochs))
switch ts.Mode {
case doclientstop:
// Wait for server or timer to complete
select {
case sok := <-ts.ServerChan:
if !sok {
ts.Tester.Logf("Server error\n")
ts.Tester.FailNow()
}
case <-ts.TimeChan:
ts.Tester.Logf("Test timed out waiting for server\n")
ts.Tester.FailNow()
}
lsplog.Vlogf(0, "Server completed\n")
// Wait for the clients
for i := 0; i < nclients; i++ {
select {
case cok := <-ts.ClientChan:
if !cok {
ts.Tester.Logf("Client error\n")
ts.Tester.FailNow()
}
case <-ts.TimeChan:
ts.Tester.Logf("Test timed out waiting for client\n")
ts.Tester.FailNow()
}
}
lsplog.Vlogf(0, "Clients completed\n")
default: // Includes stopserver
// Wait for the clients
for i := 0; i < nclients; i++ {
select {
case cok := <-ts.ClientChan:
if !cok {
ts.Tester.Logf("Client error\n")
ts.Tester.FailNow()
}
case <-ts.TimeChan:
ts.Tester.Logf("Test timed out waiting for client\n")
ts.Tester.FailNow()
}
}
// Wait for server or timer to complete
select {
case sok := <-ts.ServerChan:
if !sok {
ts.Tester.Logf("Server error\n")
ts.Tester.FailNow()
}
case <-ts.TimeChan:
ts.Tester.Logf("Test timed out waiting for server\n")
ts.Tester.FailNow()
}
}
lsplog.SetVerbose(AuxDefaultVerbosity)
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:78,代码来源:lsp_x_test.go
示例17: TestRoundTrip2
func TestRoundTrip2(t *testing.T) {
lsplog.SetVerbose(3)
NewSynchTestSystem(t, 3, 10, doroundtrip, 12, synchparams(5, 500))
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:4,代码来源:lsp_s_test.go
示例18: TestClientToServer3
func TestClientToServer3(t *testing.T) {
lsplog.SetVerbose(3)
NewSynchTestSystem(t, 5, 500, doclienttoserver, 20, synchparams(5, 2000))
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:4,代码来源:lsp_s_test.go
示例19: TestClientToServer2
func TestClientToServer2(t *testing.T) {
lsplog.SetVerbose(3)
NewSynchTestSystem(t, 3, 10, doclienttoserver, 12, synchparams(5, 500))
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:4,代码来源:lsp_s_test.go
示例20: TestStopServerConns1
func TestStopServerConns1(t *testing.T) {
lsplog.SetVerbose(1)
NewAuxTestSystem(t, 1, doserverstopconns, 10, auxparams(5, 500))
}
开发者ID:kedebug,项目名称:golang-programming,代码行数:4,代码来源:lsp_x_test.go
注:本文中的github.com/kedebug/golang-programming/15-440/P1-F11/lsplog.SetVerbose函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论