autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Splitting tests and sources


From: Ivan \"Rambius\" Ivanov
Subject: Splitting tests and sources
Date: Fri, 30 Jul 2010 21:10:54 +0300

Hello,

I am developing a project with some unit tests. The tests and the
sources were living in one and the same directory, src/, at the top
level directory of the project. The unit tests use the sources and
link against them and I was able to successfully execute them.

I decided to split the tests and the sources, because it became a
clutter. I moved the unit tests to tests/ and left the sources in src/
and I have some problems building the unit tests. My build files are
as follow:

configure.ac:

AC_INIT([cryptoexamples], [0.1], address@hidden)
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR([src])
AC_CONFIG_SRCDIR([tests])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE

AC_PROG_CC
AC_PROG_RANLIB
AC_PATH_PROG([ATFRUN], [atf-run])
AC_PATH_PROG([ATFREPORT], [atf-report])

PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.7])
PKG_CHECK_MODULES([ATF_C], [atf-c >= 0.10])

AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])
AC_OUTPUT


Makefile.am:

SUBDIRS = src tests


src/Makefile.am:

AM_CFLAGS=-Wall
AM_CPPFLAGS=$(OPENSSL_CFLAGS)
AM_LDFLAGS=$(OPENSSL_LIBS)

CLEANFILES =

bin_PROGRAMS = countnb encbf

countnb_SOURCES = countnb.c

encbf_SOURCES = seed_prng.c init_bf.c encdec.c encbf.c


tests/Makefile.am:

AM_CFLAGS=-Wall
AM_CPPFLAGS=$(OPENSSL_CFLAGS) $(ATF_C_CFLAGS)
AM_LDFLAGS=$(OPENSSL_LIBS) $(ATF_C_LIBS)

CLEANFILES =

testsdir = $(exec_prefix)/tests/cryptoexamples
tests_DATA = Atffile

tests_PROGRAMS = test_seed_prng test_init_bf test_encdec test_base64
test_base64_key_iv

test_seed_prng_SOURCES = seed_prng.c test_seed_prng.c
test_init_bf_SOURCES = seed_prng.c init_bf.c test_init_bf.c
test_encdec_SOURCES = seed_prng.c init_bf.c encdec.c test_encdec.c
test_base64_SOURCES = base64.c test_base64.c
test_base64_key_iv_SOURCES = seed_prng.c init_bf.c base64.c test_base64_key_iv.c

atf_run_and_report = rm -f $${fifofile}; \
        mkfifo $${fifofile}; \
        cd $${dir}; \
        cat $${fifofile} | tee $${logfile} | atf-report & \
        atf-run >>$${fifofile}; \
        res=$${?}; \
        wait; \
        echo "The verbatim output of atf-run has been saved to" \
             "$${logfile}; exit code was $${res}"; \
        test $${res} -eq 0

check-local: check-atf
.PHONY: check-atf
check-atf:
        logfile=$$(pwd)/check.log; fifofile=$$(pwd)/check.fifo;
dir=${builddir}; $(atf_run_and_report)
CLEANFILES += check.fifo check.log

installcheck-local: installcheck-atf
.PHONY: installcheck-atf
installcheck-atf:
        logfile=$$(pwd)/installcheck.log; fifofile=$$(pwd)/installcheck.fifo;
dir=$(testsdir); ${atf_run_and_report}
CLEANFILES += installcheck.log installcheck.fifo


Some of the test programs for example test_seed_prng depend on the
sources in src:

test_seed_prng_SOURCES = seed_prng.c test_seed_prng.c


How can I specify this dependency? I tried several ways
unsuccessfully: adding src/ to AM_CPPFLAGS and AM_LDFLAGS in
tests/Makefile.am; changing test_seed_prng_SOURCES line to
test_seed_prng_SOURCES = ../src/seed_prng.c test_seed_prng.c, but I
had no luck.

Thank you very much for your help in advance.

Regards
Rambius

-- 
Tangra Mega Rock: http://www.radiotangra.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]