Unit tests within guacamole-server are implemented using the following:
Makefile.am
and uses make check
to run those tests.util/generate-test-runner.pl
, a Perl script which generates a test runner
written in C which leverages CUnit, running the unit tests declared in each
of the given .c
files. The generated test runner produces output in TAP
format which is consumed by the TAP test driver
provided by automake.All unit tests should be within reasonably-isolated C source files, with each logical test having its own function of the form:
void test_SUITENAME__TESTNAME() {
...
}
where TESTNAME
is the arbitrary name of the test and SUITENAME
is the
arbitrary name of the test suite that this test belongs to.
This naming convention is required by generate-test-runner.pl
. Absolutely
all tests MUST follow the above convention if they are to be picked up and
organized by the test runner generation script. Functions which are not tests
MUST NOT follow the above convention so that they are not picked up mistakenly
by the test runner generator as if they were tests.
The Makefile.am
for a subproject which contains such tests is typically
modified to contain a sections like the following:
#
# Unit tests for myproj
#
check_PROGRAMS = test_myproj
TESTS = $(check_PROGRAMS)
test_myproj_SOURCES = \
...all source files...
test_myproj_CFLAGS = \
-Werror -Wall -pedantic \
...other flags...
test_myproj_LDADD = \
...libraries...
#
# Autogenerate test runner
#
GEN_RUNNER = $(top_srcdir)/util/generate-test-runner.pl
CLEANFILES = _generated_runner.c
_generated_runner.c: $(test_myproj_SOURCES)
$(AM_V_GEN) $(GEN_RUNNER) $(test_myproj_SOURCES) > $@
nodist_test_libguac_SOURCES = \
_generated_runner.c
# Use automake's TAP test driver for running any tests
LOG_DRIVER = \
env AM_TAP_AWK='$(AWK)' \
$(SHELL) $(top_srcdir)/build-aux/tap-driver.sh
The above declares ...
test_myproj
should be built from the given sources.
Note that test_myproj_SOURCES
contains only the source which was actually
written by hand while nodist_test_myproj_SOURCES
contains only the source
which was generated by generate-test-runner.pl
.test_myproj
binary should be run to test this project when
make check
is run, and that automake's TAP driver should be used to
consume its output._generated_runner.c
source file is generated dynamically
(through running generate-test-runner.pl
on all non-generated test source)
and should not be distributed as part of the source archive.With tests following the above naming convention in place, and with the
necessary changes made to the applicable Makefile.am
, all tests will be
run automatically when make check
is run.
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )