tests: Fix out of tree build for lua scripting

test_frrscript is run from the `tests` directory and expects the sample
lua script `script1.lua` to be present in the `lib` directory. When the
package is built out of tree (which always happens when a debian
package is built), and scripting is enabled, test fails because the lua
file is not present in the `tests/lib/` subdir of the _build_ directory.

Fix this by adding `script1.lua` as an extra dependency for
`test_frrscript`, and a recipe that copies the file from the source tree
to the build tree (note: it needs to be marked ".PHONY" because
otherwise `make` thinks that it already exists, in the source tree).

After this commit, the following command starts to work:

    dpkg-buildpackage --build-profiles=pkg.frr.lua -b -uc

Signed-off-by: Eugene Crosser <crosser@average.org>
This commit is contained in:
Eugene Crosser 2023-05-08 18:38:40 +02:00
parent cf0d1e8c25
commit 5b2ee104c2

View File

@ -15,8 +15,14 @@ tests_lib_test_frrscript_CFLAGS = $(TESTS_CFLAGS)
tests_lib_test_frrscript_CPPFLAGS = $(TESTS_CPPFLAGS)
tests_lib_test_frrscript_LDADD = $(ALL_TESTS_LDADD)
tests_lib_test_frrscript_SOURCES = tests/lib/test_frrscript.c
EXTRA_tests_lib_test_frrscript_DEPENDENCIES = copy_script
EXTRA_DIST += tests/lib/test_frrscript.py tests/lib/script1.lua
# For out-of-tree build, lua script needs to be in the build dir, rather than
# just available somewhere in the VPATH
copy_script: tests/lib/script1.lua
test -e tests/lib/script1.lua || \
$(INSTALL_SCRIPT) $< tests/lib/script1.lua
##############################################################################
GRPC_TESTS_LDADD = staticd/libstatic.a grpc/libfrrgrpc_pb.la -lgrpc++ -lprotobuf $(ALL_TESTS_LDADD) $(LIBYANG_LIBS) -lm