Thursday, October 3, 2024
HomeGolangProtection for deamon - Getting Assist

Protection for deamon – Getting Assist


Hello,
I’m making an attempt to make protection for a daemon. when constructing I’m utilizing -cover .
is there any solution to dump ( like gcov_flush in GCC) or terminate gracefully with a purpose to get protection?

Protection profiling assist for integration exams – The Go Programming Language

Sorry, the hyperlink I supplied appears not serving to, perhaps GoLang not assist this characteristic at present. We are able to open a proposal to debate this situation with GoLang group if you need.

Yeah, that may be good choice to debate with the group.
additionally I discovered GitHub – qiniu/goc: A Complete Protection Testing System for The Go Programming Language
didn’t mange to get it to work but, however do you assume it’d?



1 Like

In response to the doc [1], I feel that perhaps the software that you simply want.

[1] Goc can gather code coverages at runtime in your long-run golang purposes.

I simply tried the goc software, it appears works tremendous. In the event you obtained caught, be at liberty to speak to me.

Hey,
I additionally managed to get it to work. Thanks.

Nevertheless it’s inflicting me new situation, as a result of It forces me to construct with goc. and I cant put the goc on my compilation machine. is there a solution to modify the output binaries the use the goc? or another concepts?

To the perfect of my information, it’s advisable to have goc put in on the compilation machine.

The mechanism behind goc operates as follows: the compiler (goc) inserts coverage-related statements into your code earlier than feeding them into the compiler.

  1. It copies the challenge into /tmp/goc-build-${hash}/. This folder can be deleted after compilation, however you should use goc construct --debug to retain it for additional investigation.
  2. It parses the supply code into an AST (summary syntax tree).
  3. Protection counting statements are added initially of each Fundamental Block.
  4. The supply code of the devoted internet server (http_cover_apis_auto_generated.go) is copied and imported into your challenge, answerable for gathering protection information.
  5. Lastly, it compiles the modified challenge.

This course of is much like how protection information is collected when utilizing go check -cover. You may learn extra about it on this weblog submit.

You may observe the modified supply code beneath /tmp/goc-build-${hash}. The modified supply code will resemble the next (discover the counter variable, e.g., GoCover_0_373131613736336566316238.Depend):

func predominant() { GoCover_0_373131613736336566316238.Depend[2]++;
    whole := 256
    scheduler := gojob.New().Begin()
    for i := 0; i < whole; i++ { GoCover_0_373131613736336566316238.Depend[4]++;
        scheduler.Submit(New(i, rand.Intn(10)))
    }
    GoCover_0_373131613736336566316238.Depend[3]++; scheduler.Wait()
}

Concerning your query, is there a solution to modify the output binaries to make use of goc?

The reply is sure, however it will be tough and ungraceful, particularly if it is advisable to ship the modified challenge to the compilation machine.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments