[kutil] Fix failing heap allocator tests

The tests clearly haven't even been built in a while. I've added a
helper script to the project root. Also added a kassert() handler that
will allow tests to catch or fail on asserts.
This commit is contained in:
2020-09-07 16:56:07 -07:00
parent 8534d8d3c5
commit 8490472581
6 changed files with 72 additions and 10 deletions

View File

@@ -1,2 +1,29 @@
#define CATCH_CONFIG_MAIN
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
#include "kutil/assert.h"
bool ASSERT_EXPECTED = false;
bool ASSERT_HAPPENED = false;
void test_assert(const char *file, unsigned line, const char *message)
{
CAPTURE( file );
CAPTURE( line );
INFO( message );
REQUIRE( ASSERT_EXPECTED );
ASSERT_EXPECTED = false;
ASSERT_HAPPENED = true;
}
int main( int argc, char* argv[] ) {
kutil::assert_set_callback(test_assert);
int result = Catch::Session().run( argc, argv );
return result;
}
namespace kutil {
void * kalloc(size_t size) { return malloc(size); }
void kfree(void *p) { return free(p); }
}