Skip to content

Commit

Permalink
use python to build an test the c-sources
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Jan 24, 2024
1 parent 1578301 commit b3b09fc
Show file tree
Hide file tree
Showing 20 changed files with 183 additions and 218 deletions.
1 change: 1 addition & 0 deletions libs/mli_core/src/mliAccelerator.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CASE("mliAccelerator, init")

CHECK(mliScenery_malloc_from_path_tar(
&scenery,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down
1 change: 1 addition & 0 deletions libs/mli_core/src/mliArchive.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CASE("mliArchive, read tar")

CHECK(mliArchive_malloc_from_path(
&arc,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down
2 changes: 1 addition & 1 deletion libs/mli_core/src/mliImage.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ CASE("scaling")

CASE("mliImage_write_to_ppm, mliImage_malloc_from_ppm")
{
const char path[] = "mli_core/tests/resources/mliImage/img.ppm.tmp";
const char path[] = "libs/mli_core/tests/resources/mliImage/img.ppm.tmp";
struct mliImage img = mliImage_init();
struct mliImage back = mliImage_init();
uint32_t col;
Expand Down
2 changes: 1 addition & 1 deletion libs/mli_core/src/mliIo.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ CASE("mli_line_viewer_write")

mliIo_rewind(&f);
CHECK(mliIo_read_to_path(
&f, "mli_core/tests/resources/lines_info.tmp"));
&f, "libs/mli_core/tests/resources/lines_info.tmp"));

mliIo_free(&f);
mliStr_free(&text);
Expand Down
21 changes: 15 additions & 6 deletions libs/mli_core/src/mliObject_wavefront.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ CASE("mliObject, read wavefront file")
struct mliObject obj = mliObject_init();
CHECK(mliIo_malloc_from_path(
&str,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down Expand Up @@ -390,6 +391,7 @@ CASE("mliObject, write and read binary-string")
FILE *f;
CHECK(mliIo_malloc_from_path(
&str,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand All @@ -402,7 +404,8 @@ CASE("mliObject, write and read binary-string")
mliIo_free(&str);

f =
fopen("mli_core/"
fopen("libs/"
"mli_core/"
"tests/"
"resources/"
"hexagonal_mirror_facet.bin.tmp",
Expand All @@ -412,7 +415,8 @@ CASE("mliObject, write and read binary-string")
fclose(f);

f =
fopen("mli_core/"
fopen("libs/"
"mli_core/"
"tests/"
"resources/"
"hexagonal_mirror_facet.bin.tmp",
Expand Down Expand Up @@ -455,6 +459,7 @@ CASE("mliObject, write and read ascii-text-string")
struct mliObject obj_back = mliObject_init();
CHECK(mliIo_malloc_from_path(
&str,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand All @@ -469,12 +474,12 @@ CASE("mliObject, write and read ascii-text-string")
mliObject_fprint_to_wavefront(&f, &obj);
mliIo_rewind(&f);
mliIo_read_to_path(
&f, "mli_core/tests/resources/hexagonal_mirror_facet.obj.tmp");
&f, "libs/mli_core/tests/resources/hexagonal_mirror_facet.obj.tmp");
mliIo_free(&f);

CHECK(mliIo_malloc_from_path(
&str,
"mli_core/tests/resources/hexagonal_mirror_facet.obj.tmp"));
"libs/mli_core/tests/resources/hexagonal_mirror_facet.obj.tmp"));
CHECK(mliObject_malloc_from_wavefront(&obj_back, (char *)str.cstr));
mliIo_free(&str);

Expand Down Expand Up @@ -514,6 +519,7 @@ CASE("mliObject, read and write multiple materials")
struct mliObject obj_back = mliObject_init();
CHECK(mliIo_malloc_from_path(
&str,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand All @@ -532,11 +538,12 @@ CASE("mliObject, read and write multiple materials")
mliObject_fprint_to_wavefront(&f, &obj_orig);
mliIo_rewind(&f);
mliIo_read_to_path(
&f, "mli_core/tests/resources/cube_with_materials.obj.tmp");
&f, "libs/mli_core/tests/resources/cube_with_materials.obj.tmp");
mliIo_free(&f);

CHECK(mliIo_malloc_from_path(
&str,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down Expand Up @@ -579,6 +586,7 @@ CASE("mliObject, read and write repeating materials")
struct mliObject obj_back = mliObject_init();
CHECK(mliIo_malloc_from_path(
&str,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand All @@ -593,11 +601,12 @@ CASE("mliObject, read and write repeating materials")
mliObject_fprint_to_wavefront(&f, &obj_orig);
mliIo_rewind(&f);
mliIo_read_to_path(
&f, "mli_core/tests/resources/repeating_material.obj.tmp");
&f, "libs/mli_core/tests/resources/repeating_material.obj.tmp");
mliIo_free(&f);

CHECK(mliIo_malloc_from_path(
&str,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down
1 change: 1 addition & 0 deletions libs/mli_core/src/mliOcTree.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ CASE("ray parallel to axis")

CHECK(mliScenery_malloc_from_path_tar(
&scenery,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down
4 changes: 2 additions & 2 deletions libs/mli_core/src/mliTar.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CASE("Write and read tape-archive")

sprintf(payload, "%s", "Hello world!");

f = fopen("mli_core/tests/resources/mliTar/123.tar.tmp", "wb");
f = fopen("libs/mli_core/tests/resources/mliTar/123.tar.tmp", "wb");
CHECK(mliTar_write_begin(&tar, f));
CHECK(mliTarHeader_set_directory(&tarh, "resources"));
CHECK(mliTar_write_header(&tar, &tarh));
Expand All @@ -25,7 +25,7 @@ CASE("Write and read tape-archive")

memset(payload, '\0', sizeof(payload));

f = fopen("mli_core/tests/resources/mliTar/123.tar.tmp", "rb");
f = fopen("libs/mli_core/tests/resources/mliTar/123.tar.tmp", "rb");
tar = mliTar_init();
CHECK(mliTar_read_begin(&tar, f));
CHECK(mliTar_read_header(&tar, &tarh));
Expand Down
22 changes: 12 additions & 10 deletions libs/mli_core/src/mliUserScenery.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CASE("mliScenery, malloc from archive")
fprintf(stderr, "%s, %d\n", __FILE__, __LINE__);
CHECK(mliScenery_malloc_from_path_tar(
&scenery,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down Expand Up @@ -105,6 +106,7 @@ CASE("mliScenery, read, write")

CHECK(mliScenery_malloc_from_path_tar(
&orig,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand All @@ -113,47 +115,47 @@ CASE("mliScenery, read, write")

/* geometry */
/* -------- */
f = fopen("mli_core/tests/resources/geometry.bin.tmp", "w");
f = fopen("libs/mli_core/tests/resources/geometry.bin.tmp", "w");
CHECK(f != NULL);
CHECK(mliGeometry_fwrite(&orig.geometry, f));
fclose(f);
f = fopen("mli_core/tests/resources/geometry.bin.tmp", "r");
f = fopen("libs/mli_core/tests/resources/geometry.bin.tmp", "r");
CHECK(f != NULL);
CHECK(mliGeometry_malloc_fread(&back.geometry, f));
fclose(f);
CHECK(mliGeometry_equal(&back.geometry, &orig.geometry));

/* materials */
/* --------- */
f = fopen("mli_core/tests/resources/materials.bin.tmp", "w");
f = fopen("libs/mli_core/tests/resources/materials.bin.tmp", "w");
CHECK(f != NULL);
CHECK(mliMaterials_fwrite(&orig.materials, f));
fclose(f);
f = fopen("mli_core/tests/resources/materials.bin.tmp", "r");
f = fopen("libs/mli_core/tests/resources/materials.bin.tmp", "r");
CHECK(f != NULL);
CHECK(mliMaterials_malloc_fread(&back.materials, f));
fclose(f);
CHECK(mliMaterials_equal(&back.materials, &orig.materials));

/* accelerator */
/* ----------- */
f = fopen("mli_core/tests/resources/accelerator.bin.tmp", "w");
f = fopen("libs/mli_core/tests/resources/accelerator.bin.tmp", "w");
CHECK(f != NULL);
CHECK(mliAccelerator_fwrite(&orig.accelerator, f));
fclose(f);
f = fopen("mli_core/tests/resources/accelerator.bin.tmp", "r");
f = fopen("libs/mli_core/tests/resources/accelerator.bin.tmp", "r");
CHECK(f != NULL);
CHECK(mliAccelerator_malloc_fread(&back.accelerator, f));
fclose(f);
CHECK(mliAccelerator_equal(&back.accelerator, &orig.accelerator));

/* geomap */
/* ------ */
f = fopen("mli_core/tests/resources/geomap.bin.tmp", "w");
f = fopen("libs/mli_core/tests/resources/geomap.bin.tmp", "w");
CHECK(f != NULL);
CHECK(mliGeometryToMaterialMap_fwrite(&orig.geomap, f));
fclose(f);
f = fopen("mli_core/tests/resources/geomap.bin.tmp", "r");
f = fopen("libs/mli_core/tests/resources/geomap.bin.tmp", "r");
CHECK(f != NULL);
CHECK(mliGeometryToMaterialMap_malloc_fread(&back.geomap, f));
fclose(f);
Expand All @@ -162,9 +164,9 @@ CASE("mliScenery, read, write")
/* full scenery */
/* ------------ */
CHECK(mliScenery_write_to_path(
&orig, "mli_core/tests/resources/scenery.bin.tmp"));
&orig, "libs/mli_core/tests/resources/scenery.bin.tmp"));
CHECK(mliScenery_malloc_from_path(
&back, "mli_core/tests/resources/scenery.bin.tmp"));
&back, "libs/mli_core/tests/resources/scenery.bin.tmp"));
CHECK(mliScenery_equal(&back, &orig));

mliScenery_free(&back);
Expand Down
3 changes: 2 additions & 1 deletion libs/mli_core/src/mli_cstr.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ CASE("line info fprint")
FILE *f;
CHECK(mliIo_malloc_from_path(
&s,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand All @@ -298,7 +299,7 @@ CASE("line info fprint")
"geometry/"
"objects/"
"cube_with_materials.obj"));
f = fopen("mli_core/tests/resources/lines_info.tmp", "w");
f = fopen("libs/mli_core/tests/resources/lines_info.tmp", "w");
CHECK(f);
CHECK(mli_cstr_lines_fprint(f, (char *)s.cstr, 1, 3));
CHECK(mli_cstr_lines_fprint(f, (char *)s.cstr, 10, 3));
Expand Down
8 changes: 4 additions & 4 deletions libs/mli_core/src/mli_json.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ CASE("mliJson_malloc_from_path")
double myfloat;

CHECK(mliJson_malloc_from_path(
&json, "mli_core/tests/resources/mliJson/example.json"));
&json, "libs/mli_core/tests/resources/mliJson/example.json"));
CHECK(mliJson_debug_to_path(
&json, "mli_core/tests/resources/mliJson/example.debug.tmp"));
&json, "libs/mli_core/tests/resources/mliJson/example.debug.tmp"));

CHECK(mliJson_token_by_key(&json, 0, "name", &return_idx));
CHECK(return_idx == 1);
Expand Down Expand Up @@ -145,9 +145,9 @@ CASE("parse mliVec and mliColor")
struct mliVec vec2 = mliVec_init(0., 0., 0.);
struct mliColor col = mliColor_set(0., 0., 0.);
CHECK(mliJson_malloc_from_path(
&json, "mli_core/tests/resources/mliJson/vec.json"));
&json, "libs/mli_core/tests/resources/mliJson/vec.json"));
CHECK(mliJson_debug_to_path(
&json, "mli_core/tests/resources/mliJson/vec.debug.tmp"));
&json, "libs/mli_core/tests/resources/mliJson/vec.debug.tmp"));

CHECK(mliJson_token_by_key(&json, 0, "vec1", &token));
CHECK(mliVec_from_json_token(&vec1, &json, token + 1));
Expand Down
1 change: 1 addition & 0 deletions libs/mli_core/src/mli_photon_propagation.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CASE("simple propagation")

CHECK(mliScenery_malloc_from_path_tar(
&scenery,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CASE("focussing_a_parallel_beam")

CHECK(mliScenery_malloc_from_path_tar(
&scenery,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down Expand Up @@ -93,6 +94,7 @@ CASE("focussing_a_parallel_beam")
mliColor_set(1.0, 255.0 / max_color.g, 255.0 / max_color.b));
CHECK(mliImage_write_to_path(
&screen_img,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down
1 change: 1 addition & 0 deletions libs/mli_core/tests/mli_photon_propagation_prism.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ CASE("refraction_in_prism")

CHECK(mliScenery_malloc_from_path_tar(
&scenery,
"libs/"
"mli_core/"
"tests/"
"resources/"
Expand Down
Loading

0 comments on commit b3b09fc

Please sign in to comment.