These are chat archives for Snaipe/Criterion

1st
Feb 2017
Yuriy Yarosh
@yuriy-yarosh
Feb 01 2017 18:28

o/
cr_malloc returns NULL on MacOS, for unknown reason.

Test(uri_tests, emptySchemaShouldBeParsed) {

    URI* testURI = cr_malloc(sizeof(URI));
    cr_log_warn("%u", (uint) sizeof(URI));
    cr_log_error("%u", (uint) testURI);
    cr_assert_not_null(testURI, "URI should be allocated");
...

leads to

[WARN] 88
[ERR ] 0
[----] ~/src/.../Tests/uri_test.c:12: Assertion failed: URI should be allocated
[FAIL] uri_tests::emptySchemaShouldBeParsed: (0.00s)
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0
Franklin Mathieu
@Snaipe
Feb 01 2017 18:31
cr_malloc is only relevant when allocating memory from outside a test that should be inherited, just use malloc from within the test
Yuriy Yarosh
@yuriy-yarosh
Feb 01 2017 18:32
I don't get what "allocating memory from outside" means...
Franklin Mathieu
@Snaipe
Feb 01 2017 18:32
From a report hook, basically
Tests run in their own process, cr_malloc is here to ensure that memory allocated in the parent process gets inherited in the child process
Yuriy Yarosh
@yuriy-yarosh
Feb 01 2017 18:33
ah... so basically it's better to go for cr_malloc in setup teardown hooks, right ?
I'm like 1.5 hours into Criterion, so I don't really get how things actually work in here.
Franklin Mathieu
@Snaipe
Feb 01 2017 18:34
setup and teardown are run in the same process as the child, so no; I'm talking about things like ReportHook(PRE_ALL) {} for instance
so, in this case, don't worry about it; just use normal malloc and free
Yuriy Yarosh
@yuriy-yarosh
Feb 01 2017 18:34

Ok, I'll get into it later.

Anyway, Thank You Franklin for so fast response.

Franklin Mathieu
@Snaipe
Feb 01 2017 18:35
You're welcome!
Yuriy Yarosh
@yuriy-yarosh
Feb 01 2017 18:38

I'm pretty hyped about Criterion, it's dope. You've did great job.
Writing C+Swift+DPDK backend web-framework, because I can :3
Something like seastar but with a simple API like Vapor

Tried Scala-native previously - it performed not that great...

Franklin Mathieu
@Snaipe
Feb 01 2017 18:40
That's awesome! There's still room for a lot of improvements, and I'm rewriting a lot of the core parts for more consistency and simplicity (like #182) for 3.0. Hopefully Criterion will improve even more in the future.
Yuriy Yarosh
@yuriy-yarosh
Feb 01 2017 18:41
Yeah, I'll look into it later ;)