github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/p2p/discv5/sim_testmain_test.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 12:09:44</date>
    10  //</624342657463750656>
    11  
    12  
    13  //+构建Go1.4、Nacl、Faketime_模拟
    14  
    15  package discv5
    16  
    17  import (
    18  	"os"
    19  	"runtime"
    20  	"testing"
    21  	"unsafe"
    22  )
    23  
    24  //在运行时启用假时间模式,如在游乐场上。
    25  //这有一点可能不起作用,因为有些go代码
    26  //可能在设置变量之前执行。
    27  
    28  //转到:linkname faketime runtime.faketime
    29  var faketime = 1
    30  
    31  func TestMain(m *testing.M) {
    32  //为了获得go:linkname的访问权限,我们需要以某种方式使用unsafe。
    33  	_ = unsafe.Sizeof(0)
    34  
    35  //运行实际测试。runwithplaygroundtime确保
    36  //这就是所谓的跑步。
    37  	runtime.GOMAXPROCS(8)
    38  	os.Exit(m.Run())
    39  }
    40