star-stl

Load STereo Lithography (StL) file format
git clone git://git.meso-star.fr/star-stl.git
Log | Files | Refs | README | LICENSE

commit a907a559315166cb6612e3154344c340d4494fb9
parent 34b005acdcab56194c9b98cded2edfce277727ca
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon,  7 Apr 2025 17:13:42 +0200

Refactor tests to make them easier to read

Diffstat:
Msrc/test_sstl.c | 12+++++++++++-
Msrc/test_sstl_load.c | 404++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Dsrc/test_sstl_utils.h | 33---------------------------------
3 files changed, 245 insertions(+), 204 deletions(-)

diff --git a/src/test_sstl.c b/src/test_sstl.c @@ -14,11 +14,21 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "sstl.h" -#include "test_sstl_utils.h" #include <rsys/logger.h> static void +check_memory_allocator(struct mem_allocator* allocator) +{ + if(MEM_ALLOCATED_SIZE(allocator)) { + char dump[512]; + MEM_DUMP(allocator, dump, sizeof(dump)/sizeof(char)); + fprintf(stderr, "%s\n", dump); + FATAL("Memory leaks\n"); + } +} + +static void log_stream(const char* msg, void* ctx) { ASSERT(msg); diff --git a/src/test_sstl_load.c b/src/test_sstl_load.c @@ -14,17 +14,82 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "sstl.h" -#include "test_sstl_utils.h" -#include <rsys/clock_time.h> #include <rsys/float3.h> -#include <rsys/logger.h> -#include <rsys/rsys.h> +#include <rsys/mem_allocator.h> + +#include <string.h> + +/******************************************************************************* + * Helper functions + ******************************************************************************/ +static void +check_api(struct sstl* sstl) +{ + const char* filename = "test.stl"; + FILE* fp = NULL; + struct sstl_desc desc = SSTL_DESC_NULL; + + CHK((fp = fopen(filename, "w+")) != NULL); + rewind(fp); + + CHK(sstl_load(sstl, NULL) == RES_BAD_ARG); + CHK(sstl_load(NULL, filename) == RES_BAD_ARG); + CHK(sstl_load(sstl, "none.stl") == RES_IO_ERR); + CHK(sstl_load(sstl, filename) == RES_OK); /* Empty file should be OK */ + + CHK(sstl_get_desc(sstl, NULL) == RES_BAD_ARG); + CHK(sstl_get_desc(NULL, &desc) == RES_BAD_ARG); + CHK(sstl_get_desc(sstl, &desc) == RES_OK); + + CHK(desc.solid_name == NULL); + CHK(desc.vertices_count == 0); + CHK(desc.triangles_count == 0); + + + CHK(sstl_load_stream(NULL, fp, "stream") == RES_BAD_ARG); + CHK(sstl_load_stream(sstl, NULL, "stream") == RES_BAD_ARG); + CHK(sstl_load_stream(sstl, fp, NULL) == RES_BAD_ARG); + CHK(sstl_load_stream(sstl, fp, "stream") == RES_OK); + + CHK(sstl_get_desc(sstl, &desc) == RES_OK); + + CHK(desc.solid_name == NULL); + CHK(desc.vertices_count == 0); + CHK(desc.triangles_count == 0); + + CHK(fclose(fp) == 0); +} + +static void +check_no_triangle(struct sstl* sstl) +{ + static const char* stl = + "solid my_solid\n" + "endsolid my_solid\n"; + const char* filename = "empty.stl"; + FILE* fp = NULL; + struct sstl_desc desc = SSTL_DESC_NULL; + + CHK(sstl); + + CHK((fp = fopen(filename, "w+")) != NULL); + CHK(fwrite(stl, sizeof(char), strlen(stl), fp) == strlen(stl)); + rewind(fp); + + CHK(sstl_load_stream(sstl, fp, filename) == RES_OK); + CHK(sstl_get_desc(sstl, &desc) == RES_OK); + CHK(!strcmp(desc.solid_name, "my_solid")); + CHK(desc.vertices_count == 0); + CHK(desc.triangles_count == 0); + + CHK(fclose(fp) == 0); +} static void -test_basic(struct sstl* sstl) +check_1_triangle(struct sstl* sstl) { - static const char* test0 = + static const char* stl = "solid\n" " facet normal 0.0 -1.0 0.0\n" " outer loop\n" @@ -34,8 +99,37 @@ test_basic(struct sstl* sstl) " endloop\n" " endfacet\n" "endsolid"; - static const char* test1 = - "solid my_solid\n" + const char* filename = "1_triangle.stl"; + FILE* fp = NULL; + float v[3] = {0,0,0}; + struct sstl_desc desc = SSTL_DESC_NULL; + + CHK(sstl); + + CHK((fp = fopen(filename, "w")) != NULL); + CHK(fwrite(stl, sizeof(char), strlen(stl), fp) == strlen(stl)); + CHK(fclose(fp) == 0); + + CHK(sstl_load(sstl, filename) == RES_OK); + CHK(sstl_get_desc(sstl, &desc) == RES_OK); + + CHK(desc.solid_name == NULL); + CHK(desc.vertices_count == 3); + CHK(desc.triangles_count == 1); + CHK(desc.indices[0] == 0); + CHK(desc.indices[1] == 1); + CHK(desc.indices[2] == 2); + CHK(f3_eq(desc.vertices + 0*3, f3(v, 0.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + 1*3, f3(v, 1.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + 2*3, f3(v, 0.f, 0.f, 1.f)) == 1); + CHK(f3_eq(desc.normals, f3(v, 0.f, -1.f, 0.f)) == 1); +} + +static void +check_1_triangle_with_noise(struct sstl* sstl) +{ + static const char* stl = + "solid My Solid\n" "\n" " facet normal 0.0 -1.0 0.0\n" " outer loop hophophophophop\n" @@ -45,10 +139,37 @@ test_basic(struct sstl* sstl) " endloop \n" " endfacet \t\t\t noise\n" "endsolid pouet\n"; - static const char* test2 = - "solid my_solid\n" - "endsolid my_solid\n"; - static const char* test3 = + const char* filename = "1_triangle_with_noise.stl"; + FILE* fp = NULL; + float v[3] = {0,0,0}; + struct sstl_desc desc = SSTL_DESC_NULL; + + CHK(sstl); + + CHK((fp = fopen(filename, "w")) != NULL); + CHK(fwrite(stl, sizeof(char), strlen(stl), fp) == strlen(stl)); + CHK(fclose(fp) == 0); + + CHK(sstl_load(sstl, filename) == RES_OK); + CHK(sstl_get_desc(sstl, &desc) == RES_OK); + + CHK(sstl_get_desc(sstl, &desc) == RES_OK); + CHK(strcmp(desc.solid_name, "My Solid") == 0); + CHK(desc.vertices_count == 3); + CHK(desc.triangles_count == 1); + CHK(desc.indices[0] == 0); + CHK(desc.indices[1] == 1); + CHK(desc.indices[2] == 2); + CHK(f3_eq(desc.vertices + 0*3, f3(v, 0.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + 1*3, f3(v, 1.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + 2*3, f3(v, 0.f, 0.f, 1.f)) == 1); + CHK(f3_eq(desc.normals, f3(v, 0.f, -1.f, 0.f)) == 1); +} + +static void +check_1_triangle_no_normal(struct sstl* sstl) +{ + static const char* stl = "solid\n" " facet normal 0.0 0.0 0.0\n" " outer loop\n" @@ -58,7 +179,39 @@ test_basic(struct sstl* sstl) " endloop\n" " endfacet\n" "endsolid"; + const char* filename = "1_triangle_no_normal.stl"; + FILE* fp = NULL; + float v[3] = {0,0,0}; + struct sstl_desc desc = SSTL_DESC_NULL; + + CHK((fp = fopen(filename, "w+")) != NULL); + CHK(fwrite(stl, sizeof(char), strlen(stl), fp) == strlen(stl)); + rewind(fp); + + CHK(sstl_load_stream(sstl, fp, filename) == RES_OK); + + CHK(sstl_get_desc(sstl, &desc) == RES_OK); + CHK(desc.solid_name == NULL); + CHK(desc.vertices_count == 3); + CHK(desc.triangles_count == 1); + CHK(desc.indices[0] == 0); + CHK(desc.indices[1] == 1); + CHK(desc.indices[2] == 2); + CHK(f3_eq(desc.vertices + 0*3, f3(v, 0.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + 1*3, f3(v, 1.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + 2*3, f3(v, 0.f, 0.f, 1.f)) == 1); + + /* Normal is automatically calculated */ + CHK(f3_eq(desc.normals, f3(v, 0.f, -1.f, 0.f)) == 1); + + CHK(fclose(fp) == 0); +} + +static void +check_invalid_file(struct sstl* sstl) +{ static const char* bad[] = { + /* "endsolid" is missing */ "solid\n" " facet normal 0.0 -1.0 0.0\n" " outer loop\n" @@ -66,8 +219,9 @@ test_basic(struct sstl* sstl) " vertex 1.0 0.0 0.0\n" " vertex 0.0 0.0 1.0\n" " endloop\n" - " endfacet\n" - , + " endfacet\n", + + /* "solid" is missing */ " facet normal 0.0 -1.0 0.0\n" " outer loop\n" " vertex 0.0 0.0 0.0\n" @@ -75,8 +229,9 @@ test_basic(struct sstl* sstl) " vertex 0.0 0.0 1.0\n" " endloop\n" " endfacet\n" - "endsolid\n" - , + "endsolid\n", + + /* "normal" is missing */ "solid\n" " facet 0.0 -1.0 0.0\n" " outer loop\n" @@ -85,8 +240,9 @@ test_basic(struct sstl* sstl) " vertex 0.0 0.0 1.0\n" " endloop\n" " endfacet\n" - "endsolid\n" - , + "endsolid\n", + + /* "facet" is missing */ "solid\n" " normal 0.0 -1.0 0.0\n" " outer loop\n" @@ -95,8 +251,9 @@ test_basic(struct sstl* sstl) " vertex 0.0 0.0 1.0\n" " endloop\n" " endfacet\n" - "endsolid\n" - , + "endsolid\n", + + /* invalid vertex coordinate */ "solid\n" " facet normal 0.0 -1.0 0.0\n" " outer loop\n" @@ -105,8 +262,9 @@ test_basic(struct sstl* sstl) " vertex 0.0 0.0 1.0\n" " endloop\n" " endfacet\n" - "endsolid\n" - , + "endsolid\n", + + /* Not enough vertices */ "solid\n" " facet normal 0.0 -1.0 0.0\n" " outer loop\n" @@ -114,8 +272,9 @@ test_basic(struct sstl* sstl) " vertex 0.0 0.0 1.0\n" " endloop\n" " endfacet\n" - "endsolid\n" - , + "endsolid\n", + + /* "outer loop" is missing */ "solid\n" " facet normal 0.0 -1.0 0.0\n" " vertex 0.0 0.0 0.0\n" @@ -125,99 +284,25 @@ test_basic(struct sstl* sstl) "endsolid\n" }; const size_t nbads = sizeof(bad)/sizeof(const char*); - float tmp[3]; - struct sstl_desc desc; - FILE* file; + FILE* fp = NULL; size_t i; CHK(sstl != NULL); - file = fopen("test_basic.stl", "w"); - CHK(file != NULL); - fwrite(test0, sizeof(char), strlen(test0), file); - fclose(file); - - CHK(sstl_load(NULL, NULL) == RES_BAD_ARG); - CHK(sstl_load(sstl, NULL) == RES_BAD_ARG); - CHK(sstl_load(NULL, "test_basic.stl") == RES_BAD_ARG); - CHK(sstl_load(sstl, "none.stl") == RES_IO_ERR); - CHK(sstl_load(sstl, "test_basic.stl") == RES_OK); - - CHK(sstl_get_desc(NULL, NULL) == RES_BAD_ARG); - CHK(sstl_get_desc(sstl, NULL) == RES_BAD_ARG); - CHK(sstl_get_desc(NULL, &desc) == RES_BAD_ARG); - CHK(sstl_get_desc(sstl, &desc) == RES_OK); - - CHK(desc.solid_name == NULL); - CHK(desc.vertices_count == 3); - CHK(desc.triangles_count == 1); - CHK(desc.indices[0] == 0); - CHK(desc.indices[1] == 1); - CHK(desc.indices[2] == 2); - CHK(f3_eq(desc.vertices + 0*3, f3(tmp, 0.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + 1*3, f3(tmp, 1.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + 2*3, f3(tmp, 0.f, 0.f, 1.f)) == 1); - CHK(f3_eq(desc.normals, f3(tmp, 0.f, -1.f, 0.f)) == 1); - - file = tmpfile(); - CHK(file != NULL); - fwrite(test1, sizeof(char), strlen(test1), file); - rewind(file); - CHK(sstl_load_stream(NULL, NULL, "stream") == RES_BAD_ARG); - CHK(sstl_load_stream(sstl, NULL, "stream") == RES_BAD_ARG); - CHK(sstl_load_stream(NULL, file, "stream") == RES_BAD_ARG); - CHK(sstl_load_stream(sstl, file, NULL) == RES_BAD_ARG); - CHK(sstl_load_stream(sstl, file, "stream") == RES_OK); - fclose(file); - - CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(strcmp(desc.solid_name, "my_solid") == 0); - CHK(desc.vertices_count == 3); - CHK(desc.triangles_count == 1); - CHK(desc.indices[0] == 0); - CHK(desc.indices[1] == 1); - CHK(desc.indices[2] == 2); - CHK(f3_eq(desc.vertices + 0*3, f3(tmp, 0.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + 1*3, f3(tmp, 1.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + 2*3, f3(tmp, 0.f, 0.f, 1.f)) == 1); - CHK(f3_eq(desc.normals, f3(tmp, 0.f, -1.f, 0.f)) == 1); - - file = tmpfile(); - fwrite(test2, sizeof(char), strlen(test2), file); - rewind(file); - CHK(sstl_load_stream(sstl, file, "stream") == RES_OK); - fclose(file); - - CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(strcmp(desc.solid_name, "my_solid") == 0); - CHK(desc.vertices_count == 0); - CHK(desc.triangles_count == 0); - - file = tmpfile(); - fwrite(test3, sizeof(char), strlen(test3), file); - rewind(file); - CHK(sstl_load_stream(sstl, file, "stream") == RES_OK); - fclose(file); - - CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.vertices_count == 3); - CHK(desc.triangles_count == 1); - CHK(f3_eq(desc.normals, f3(tmp, 0.f, -1.f, 0.f)) == 1); - - FOR_EACH(i, 0, nbads) { - file = tmpfile(); - fwrite(bad[i], sizeof(char), strlen(bad[i]), file); - rewind(file); - CHK(sstl_load_stream(sstl, file, "stream") == RES_BAD_ARG); - fclose(file); + FOR_EACH(i, 0, nbads) { + CHK((fp = tmpfile()) != NULL); + CHK(fwrite(bad[i], sizeof(char), strlen(bad[i]), fp) == strlen(bad[i])); + rewind(fp); + CHK(sstl_load_stream(sstl, fp, "invalid StL") == RES_BAD_ARG); + CHK(fclose(fp) == 0); } } static void -test_tetrahedron(struct sstl* sstl) +check_tetrahedron(struct sstl* sstl) { static const char* tetrahedron[] = { - "solid cube_corner\n", + "solid cube corner\n", " facet normal 0.0 -1.0 0.0\n", " outer loop\n", " vertex 0.0 0.0 0.0\n", @@ -248,90 +333,69 @@ test_tetrahedron(struct sstl* sstl) " endfacet\n", "endsolid\n" }; - FILE* file; + FILE* fp = NULL; const size_t nlines = sizeof(tetrahedron)/sizeof(const char*); - struct sstl_desc desc; - float tmp[3]; + struct sstl_desc desc = SSTL_DESC_NULL; + float v[3]; size_t i; CHK(sstl != NULL); - file = tmpfile(); - CHK(file != NULL); - FOR_EACH(i, 0, nlines) - fwrite(tetrahedron[i], sizeof(char), strlen(tetrahedron[i]), file); - rewind(file); + CHK((fp = tmpfile()) != NULL); + FOR_EACH(i, 0, nlines) { + const size_t n = strlen(tetrahedron[i]); + CHK(fwrite(tetrahedron[i], sizeof(char), n, fp) == n); + } + rewind(fp); - CHK(sstl_load_stream(sstl, file, "stream") == RES_OK); - CHK(fclose(file) == 0); + CHK(sstl_load_stream(sstl, fp, "Tetrahedron") == RES_OK); + CHK(fclose(fp) == 0); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(strcmp(desc.solid_name, "cube_corner") == 0); + CHK(strcmp(desc.solid_name, "cube corner") == 0); CHK(desc.vertices_count == 4); CHK(desc.triangles_count == 4); - CHK(f3_eq(desc.vertices + desc.indices[0]*3, f3(tmp, 0.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[1]*3, f3(tmp, 1.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[2]*3, f3(tmp, 0.f, 0.f, 1.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[3]*3, f3(tmp, 0.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[4]*3, f3(tmp, 0.f, 1.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[5]*3, f3(tmp, 1.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[6]*3, f3(tmp, 0.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[7]*3, f3(tmp, 0.f, 0.f, 1.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[8]*3, f3(tmp, 0.f, 1.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[9]*3, f3(tmp, 1.f, 0.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[10]*3, f3(tmp, 0.f, 1.f, 0.f)) == 1); - CHK(f3_eq(desc.vertices + desc.indices[11]*3, f3(tmp, 0.f, 0.f, 1.f)) == 1); - - CHK(f3_eq(desc.normals + 0*3, f3(tmp, 0.f,-1.f, 0.f)) == 1); - CHK(f3_eq(desc.normals + 1*3, f3(tmp, 0.f, 0.f,-1.f)) == 1); - CHK(f3_eq(desc.normals + 2*3, f3(tmp,-1.f, 0.f, 0.f)) == 1); - f3_normalize(tmp, f3(tmp, 1.f, 1.f, 1.f)); - CHK(f3_eq_eps(desc.normals + 3*3, tmp, 1.e-6f) == 1); + CHK(f3_eq(desc.vertices + desc.indices[0]*3, f3(v, 0.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[1]*3, f3(v, 1.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[2]*3, f3(v, 0.f, 0.f, 1.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[3]*3, f3(v, 0.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[4]*3, f3(v, 0.f, 1.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[5]*3, f3(v, 1.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[6]*3, f3(v, 0.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[7]*3, f3(v, 0.f, 0.f, 1.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[8]*3, f3(v, 0.f, 1.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[9]*3, f3(v, 1.f, 0.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[10]*3, f3(v, 0.f, 1.f, 0.f)) == 1); + CHK(f3_eq(desc.vertices + desc.indices[11]*3, f3(v, 0.f, 0.f, 1.f)) == 1); + + CHK(f3_eq(desc.normals + 0*3, f3(v, 0.f,-1.f, 0.f)) == 1); + CHK(f3_eq(desc.normals + 1*3, f3(v, 0.f, 0.f,-1.f)) == 1); + CHK(f3_eq(desc.normals + 2*3, f3(v,-1.f, 0.f, 0.f)) == 1); + f3_normalize(v, f3(v, 1.f, 1.f, 1.f)); + CHK(f3_eq_eps(desc.normals + 3*3, v, 1.e-6f) == 1); } +/******************************************************************************* + * The test + ******************************************************************************/ int main(int argc, char** argv) { - struct mem_allocator allocator; - struct sstl* sstl; - int i; + struct sstl* sstl = NULL; (void)argc, (void)argv; - mem_init_proxy_allocator(&allocator, &mem_default_allocator); + CHK(sstl_create(NULL, NULL, 3, &sstl) == RES_OK); - CHK(sstl_create(NULL, &allocator, 3, &sstl) == RES_OK); - - test_basic(sstl); - test_tetrahedron(sstl); - - FOR_EACH(i, 1, argc) { - struct sstl_desc desc; - char buf[512]; - struct time t0, t1; - - printf("loading %s", argv[i]); - fflush(stdout); - - time_current(&t0); - CHK(sstl_load(sstl, argv[i]) == RES_OK); - time_current(&t1); - time_sub(&t0, &t1, &t0); - time_dump(&t0, TIME_MIN|TIME_SEC|TIME_MSEC, NULL, buf, sizeof(buf)); - - CHK(sstl_get_desc(sstl, &desc) == RES_OK); - - printf(" - #vertices = %lu; #triangles = %lu - %s\n", - (unsigned long)desc.vertices_count, - (unsigned long)desc.triangles_count, - buf); - } + check_api(sstl); + check_no_triangle(sstl); + check_1_triangle(sstl); + check_1_triangle_with_noise(sstl); + check_1_triangle_no_normal(sstl); + check_invalid_file(sstl); + check_tetrahedron(sstl); CHK(sstl_ref_put(sstl) == RES_OK); - - check_memory_allocator(&allocator); - mem_shutdown_proxy_allocator(&allocator); CHK(mem_allocated_size() == 0); return 0; } - diff --git a/src/test_sstl_utils.h b/src/test_sstl_utils.h @@ -1,33 +0,0 @@ -/* Copyright (C) 2015, 2016, 2019, 2021, 2023, 2025 |Méso|Star> (contact@meso-star.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifndef TEST_SSTL_UTILS_H -#define TEST_SSTL_UTILS_H - -#include <rsys/mem_allocator.h> - -static INLINE void -check_memory_allocator(struct mem_allocator* allocator) -{ - if(MEM_ALLOCATED_SIZE(allocator)) { - char dump[512]; - MEM_DUMP(allocator, dump, sizeof(dump)/sizeof(char)); - fprintf(stderr, "%s\n", dump); - FATAL("Memory leaks\n"); - } -} - -#endif /* TEST_SSTL_UTILS_H */ -