<snip snip>
Hi,
I wrote a quick and dirty POC ...
comments welcome
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#! /bin/sh
SRC_D=src
BUILD_D=src
CONFIG_SH=config.sh
INIT_C=init.c
SHUTDOWN_C=shutdown.c
C_FILE=/tmp/__efl_test.c
O_FILE=/tmp/__efl_test.o
DEBUG=0
SCRIPT_DIR=${0%/*}
SCRIPT_FILE=${0##*/}
CC=${CC:-"clang"}
LD=""
INCLUDE=""
function fatal {
echo "FATAL $1"
exit 1
}
while [ $# -ge 1 ]; do
case "$1" in
-s*|--src*)
shift
[ $# -lt 1 ] && fatal "option -s is missing directory argument"
SRC_D=$1
shift
;;
-b*|--build*)
shift
[ $# -lt 1 ] && fatal "option -b is missing directory argument"
BUILD_D=$1
shift
;;
-h|--help)
echo "Usage: $SCRIPT_FILE [options]"
echo
echo "Options:"
echo " -s, --src directory Directory to search tests into"
echo " -b, --build directory Directory to search built files
into"
echo " -h, --help This message."
exit 0
;;
*)
break
esac
done
SRC_D=$(readlink -f $SRC_D)
BUILD_D=$(readlink -f $BUILD_D)
[ -d "$SRC_D" -a -r "$SRC_D" ] || fatal "$SRC_D is not a valid directory"
[ -d "$BUILD_D" -a -r "$BUILD_D" ] || fatal "$BUILD_D is not a valid directory"
function load_cfg {
unset LDS
unset INCLUDES
LDF=""
LDP=""
INCLUDE="-I .."
if [ -f $CONFIG_SH -a -r $CONFIG_SH ]
then
echo " load $CONFIG_SH"
source ./$CONFIG_SH
for include in $INCLUDES
do
F=$(find $SRC_D -name $include)
if [ -z "$F" ]
then
F=$(find $BUILD_D -name $include)
[ ! -z "$F" ] || fatal "can't find $include in $SRC_D or $BUILD_D"
fi
INCLUDE="$INCLUDE -I ${F%/*}"
done
for ld in $LDS
do
F=$(find $BUILD_D -name $ld)
[ ! -z "$F" ] || fatal "can't find $ld in $BUILD_D"
F=$(readlink -f $F)
LDP="$LDP -L ${F%/*}"
lib=${F##*/lib}
lib=${lib%.so*}
LDF="$LDF -l$lib"
done
fi
}
echo "search for tests into $SRC_D"
for dir in $(find $SRC_D -type d -name tests)
do
echo " enter $dir"
pushd $dir > /dev/null || fatal "cannot enter $dir"
[ -f $INIT_C -a -r $INIT_C ] || fatal "missing mandatory file $INIT_C"
[ -f $SHUTDOWN_C -a -r $SHUTDOWN_C ] || fatal "missing mandatory file
$SHUTDOWN_C"
load_cfg
for test_c in $(ls -1 test_*.c)
do
echo -n " compile and run $test_c"
cat $INIT_C $test_c $SHUTDOWN_C > $C_FILE
CMD="$CC $INCLUDE $LDP $LDF -o $C_FILE.o $O_FILE"
[ $DEBUG -eq 1 ] && echo "$CMD"
$CMD || fatal "compilation failed"
$O_FILE.o && echo " PASS" || fatal "test run failed"
done
echo " leave"
popd > /dev/null
done
echo "done"
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
this is what I've got in src/lib/eina/tests
jeyzu@bigdaddy: tests (master) $ cat config.sh
INCLUDES="eina_config.h Eina.h Efl_Config.h"
LDS="libeina.so"
jeyzu@bigdaddy: tests (master) $ cat init.c
#include <Eina.h>
#define FAIL_IF(_x) if ((_x)) { fprintf(stderr, "fail\n"); exit(1); }
int main(int argc, char *argv[])
{
eina_init();
jeyzu@bigdaddy: tests (master) $ cat shutdown.c
eina_shutdown();
return 0;
}
jeyzu@bigdaddy: tests (master) $ cat test_list_append.c
Eina_List *list = NULL;
list = eina_list_append(list, (void *)123L);
FAIL_IF(eina_list_data_find_list(list, (void *)123L) != list);
run from topdir
jeyzu@bigdaddy: efl (master) $ ./tests.sh -s src/lib/eina -b build
search for tests into /home/jeyzu/usr/git/efl/core/efl/src/lib/eina
enter /home/jeyzu/usr/git/efl/core/efl/src/lib/eina/tests
load config.sh
compile and run test_list_append.c PASS
leave
done
--- Hell'O from Yverdoom
Jérémy (jeyzu)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel