Add automatic tests
The first automatic tests are for the ECS and the utilities. None of them are testing much.
This commit is contained in:
parent
25399640a4
commit
a6595f584c
|
@ -0,0 +1,3 @@
|
|||
# ECS Auto-Tests
|
||||
|
||||
This folder contains the fully automated tests of the Voxula ECS.
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
#ifndef VOXULA_ECS_AUTOMATIC_TEST_H
|
||||
#define VOXULA_ECS_AUTOMATIC_TEST_H
|
||||
|
||||
#include <voxula/internals/ecs.h>
|
||||
|
||||
int main(int argc, char **argv);
|
||||
|
||||
bool test_many_entities();
|
||||
|
||||
#endif // VOXULA_ECS_AUTOMATIC_TEST_H
|
|
@ -0,0 +1,19 @@
|
|||
#include <voxula/tests/ecs.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
bool test_many_entities()
|
||||
{
|
||||
vecs_s *ecs = vecs_new(NULL);
|
||||
uint32_t max_entities = 1024 * 1024;
|
||||
vecs_entity_s *entities = malloc(max_entities * sizeof(vecs_entity_s));
|
||||
uint32_t num_entities = 0;
|
||||
while(num_entities < max_entities)
|
||||
{
|
||||
entities[num_entities] = vecs_summon(ecs);
|
||||
++num_entities;
|
||||
}
|
||||
free(entities);
|
||||
vecs_free(ecs);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
#include <voxula/tests/ecs.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_many_entities(NULL);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
# Utility Auto-Tests
|
||||
|
||||
This folder contains the fully-automatic testing suite of the Voxula
|
||||
Engine's utilites.
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
#ifndef VOXULA_UTILITY_AUTOMATIC_TETS_H
|
||||
#define VOXULA_UTILITY_AUTOMATIC_TETS_H
|
||||
|
||||
#include <voxula/internals/utility.h>
|
||||
|
||||
int main(int argc, char **argv);
|
||||
|
||||
bool vx_test_case_force_continuation_creation();
|
||||
|
||||
#endif // VOXULA_UTILITY_AUTOMATIC_TETS_H
|
|
@ -0,0 +1,27 @@
|
|||
#include <voxula/internals/utility.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
bool vx_test_case_jumping_pointer_web()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool vx_test_case_force_continuation_creation()
|
||||
{
|
||||
uint32_t pool_capacity = 64;
|
||||
vx_pool_s *pool = vx_new_pool(8, pool_capacity);
|
||||
void **items = malloc(4 * pool_capacity * sizeof(void *));
|
||||
uint32_t item_index = 0;
|
||||
while(item_index < (pool_capacity * 4))
|
||||
{
|
||||
items[item_index] = vx_pool(pool);
|
||||
++item_index;
|
||||
}
|
||||
free(items);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_pool_interaction()
|
||||
{
|
||||
vx_new_pool(8, 64);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <voxula/tests/utility.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(vx_test_case_force_continuation_creation())
|
||||
{
|
||||
puts("OK(utility/force-continuation-creation)");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd $(dirname $0)
|
||||
SCRIPT_PATH=$(pwd)
|
||||
cd ..
|
||||
PROJECT_PATH=$(pwd)
|
||||
|
||||
function list_modules() {
|
||||
MODULE_FOLDER=$1
|
||||
|
||||
MODULES=$(ls $MODULE_FOLDER)
|
||||
for MODULE in $MODULES
|
||||
do
|
||||
if [[ -d "$MODULE_FOLDER/$MODULE/auto-test" ]];
|
||||
then
|
||||
echo $MODULE
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function list_sources() {
|
||||
SOURCE_PATH=$1
|
||||
ENTRY_PATH=$(pwd)
|
||||
|
||||
cd $SOURCE_PATH
|
||||
SOURCES=$(find . -type f | grep ".c$")
|
||||
for SOURCE in $SOURCES
|
||||
do
|
||||
echo $SOURCE_PATH/$(echo $SOURCE | cut -c 3-)
|
||||
done
|
||||
cd $ENTRY_PATH
|
||||
}
|
||||
|
||||
function make_include_statements() {
|
||||
MODULE_NAME=$1
|
||||
|
||||
for INCLUDE_PATH in $(cat modules/$MODULE_NAME/includes.txt)
|
||||
do
|
||||
MODIFIED_PATH="${INCLUDE_PATH//"{module}"/"$PROJECT_PATH/modules/$MODULE_NAME"}"
|
||||
MODIFIED_PATH="${MODIFIED_PATH//"{module-folder}"/"$PROJECT_PATH/modules"}"
|
||||
echo "-I ${MODIFIED_PATH//"{dependencies}"/"$PROJECT_PATH/dependencies"}"
|
||||
done
|
||||
}
|
||||
|
||||
MODULES=$(list_modules "modules/")
|
||||
for MODULE in $MODULES
|
||||
do
|
||||
SOURCES=$(list_sources "modules/$MODULE/auto-test/src-c")
|
||||
INCLUDE_STATEMENTS=$(make_include_statements $MODULE)
|
||||
gcc -o $PROJECT_PATH/.build/test-$MODULE.elf \
|
||||
$SOURCES \
|
||||
.build/archives/*.a \
|
||||
-I "modules/$MODULE/auto-test/inc-c" \
|
||||
$INCLUDE_STATEMENTS
|
||||
|
||||
./.build/test-$MODULE.elf
|
||||
done
|
Loading…
Reference in New Issue