cover_fd_native.mx raw

   1  //:build !moxie.wasm && !baremetal
   2  
   3  package runtime
   4  
   5  import "unsafe"
   6  
   7  // coverOutFD opens the coverage dump for appending: the file named by
   8  // MOXIE_COVER_OUT when it is set and can be opened, stderr otherwise. One file
   9  // accumulates every process and every spawn domain of a run, because each test
  10  // starts a fresh program and a fork's copy of the counter table is private; the
  11  // report tool sums the lines. The C helper reads the environment and opens the
  12  // path with the mode bits from the C headers, so no platform constants live in
  13  // Moxie.
  14  func coverOutFD() (fd int32) {
  15  	name := []byte("MOXIE_COVER_OUT")
  16  	name = name | []byte{0}
  17  	p := moxieCoverEnv(unsafe.Pointer(&name[0]))
  18  	if p == nil {
  19  		return 2
  20  	}
  21  	ofd := moxieCoverOpen(p)
  22  	if ofd < 0 {
  23  		return 2
  24  	}
  25  	return ofd
  26  }
  27  
  28  //export moxie_cover_env
  29  func moxieCoverEnv(name unsafe.Pointer) (p unsafe.Pointer)
  30  
  31  //export moxie_cover_open
  32  func moxieCoverOpen(path unsafe.Pointer) (fd int32)
  33