Added a basic testing infrastructure and found a bug through it.
This commit is contained in:
parent
c0c17f6641
commit
6538b038e7
|
@ -31,7 +31,8 @@ function build_dependencies {
|
|||
|
||||
cd .build/depends/libRR/Core/
|
||||
bash build.bash release
|
||||
cp .build/libRR-Core.a "$REPOSITORY_FOLDER/.build/"
|
||||
cp .build/librr-core.a "$REPOSITORY_FOLDER/.build/"
|
||||
cp .build/librr-platform.a "$REPOSITORY_FOLDER/.build/"
|
||||
|
||||
cd "$REPOSITORY_FOLDER"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd $(dirname "$(pwd)/$0")
|
||||
REPOSITORY_FOLDER=$(pwd)
|
||||
|
||||
MAIN_OBJECTS_FOLDER="$REPOSITORY_FOLDER/.build/objects/"
|
||||
DEFAULT_LINKAGE_PATHS="
|
||||
$REPOSITORY_FOLDER/.build/maintree-core.a
|
||||
$REPOSITORY_FOLDER/.build/librr-core.a
|
||||
$REPOSITORY_FOLDER/.build/librr-platform.a
|
||||
"
|
||||
|
||||
function get_include_path_configuration() {
|
||||
TEST_PATH=$1
|
||||
|
||||
INCLUDE_CONFIG_PATH="$TEST_PATH/include_paths.txt"
|
||||
INCLUDE_STATEMENTS="-I $TEST_PATH/inc-c/"
|
||||
if [[ ! -f $INCLUDE_CONFIG_PATH ]]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
for LINE in $(cat $INCLUDE_CONFIG_PATH)
|
||||
do
|
||||
INCLUDE_STATEMENTS="$INCLUDE_STATEMENTS -I $REPOSITORY_FOLDER/$LINE"
|
||||
done
|
||||
}
|
||||
|
||||
function get_linkage_path_configuration() {
|
||||
TEST_PATH=$1
|
||||
|
||||
LINKAGE_PATHS=$DEFAULT_LINKAGE_PATHS
|
||||
if [[ -f "$TEST_PATH/linkage_paths.txt" ]]
|
||||
then
|
||||
for LINKAGE_ITEM in $(cat "$TEST_PATH/linkage_paths.txt")
|
||||
do
|
||||
LINKAGE_PATHS="$LINKAGE_PATHS $REPOSITORY_FOLDER/$LINKAGE_ITEM"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function compile_single_test() {
|
||||
TEST_PATH=$1
|
||||
TEST_NAME=$(basename $TEST_PATH)
|
||||
|
||||
echo "Compiling Test: $TEST_NAME"
|
||||
|
||||
# TODO: As a small improvement, the tests could be able to have multiple sub-folders for sources.
|
||||
|
||||
get_include_path_configuration $TEST_PATH
|
||||
get_linkage_path_configuration $TEST_PATH
|
||||
gcc -o $TEST_PATH/$TEST_NAME.elf $TEST_PATH/*.c $LINKAGE_PATHS $INCLUDE_STATEMENTS
|
||||
}
|
||||
|
||||
function compile_all_tests_of_module() {
|
||||
MODULE_NAME=$1
|
||||
|
||||
echo "================================================================"
|
||||
echo "COMPILING ALL TESTS OF MODULE: '$MODULE_NAME'."
|
||||
echo " "
|
||||
|
||||
TEST_PATH_LIST_PATH="$REPOSITORY_FOLDER/$MODULE_NAME/build-config/tests.txt"
|
||||
if [[ ! -f $TEST_PATH_LIST_PATH ]]
|
||||
then
|
||||
echo "Couldn't find list of tests for module '$MODULE_NAME'. Skipping."
|
||||
return
|
||||
fi
|
||||
|
||||
for RELATIVE_TEST_PATH in $(cat $TEST_PATH_LIST_PATH)
|
||||
do
|
||||
TEST_PATH=$REPOSITORY_FOLDER/$MODULE_NAME/$RELATIVE_TEST_PATH
|
||||
compile_single_test $TEST_PATH
|
||||
done
|
||||
}
|
||||
|
||||
compile_all_tests_of_module core
|
|
@ -0,0 +1,3 @@
|
|||
.build/depends/libRR/Core/core/exports/
|
||||
.build/depends/libRR/Core/platform/exports/
|
||||
core/inc-c/
|
|
@ -0,0 +1,15 @@
|
|||
#include <tag_registry.h>
|
||||
#include <librr/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MtTagRegistry tag_registry = mt_create_tag_registry(NULL);
|
||||
u32_t some_tag = mt_get_tag_id(&tag_registry, "some_tag");
|
||||
if(some_tag != mt_get_tag_id(&tag_registry, "some_tag"))
|
||||
{
|
||||
puts("Inconsistent returned tag identifiers.");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue