#!/bin/bash
#
# $Id$
#
# test script for library functions
#

lib="../lib/mr_conf.c ../lib/mr_msg.c ../lib/mr_err.c ../lib/mr_mem.c"
OPT="-Wall -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -Wstrict-prototypes -Wshadow -funsigned-char -Wunused -Winit-self -Wcast-align -O2 -g -I../common -I../include"

echo "Generating test-msg"
gcc $OPT test-msg.c $lib -o test-msg
echo "Generating test-string"
gcc $OPT test-string.c ../lib/mr_str.c $lib -o test-string
echo "Generating test-conf"
gcc $OPT test-conf.c $lib -o test-conf

for f in test-conf test-string test-msg; do
	chmod 755 $f
	./$f > /tmp/$f.res
	diff -q $f.res /tmp/$f.res
	if [ $? -ne 0 ]; then
		echo "$f test KO !!"
	fi
done
