From: Michael Jeanson Date: Thu, 13 Jun 2019 18:10:51 +0000 (-0400) Subject: tests: Move libtestcommon to utils X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=550b7a4e67a46d1de6b3e83b010b6d38b1c5e7d4 tests: Move libtestcommon to utils Signed-off-by: Michael Jeanson Change-Id: I4efe6edae5d70921cbfb106f5184c58f7e2e5abb Reviewed-on: https://review.lttng.org/c/babeltrace/+/1426 Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am index 679fda2b..16616ccf 100644 --- a/tests/lib/Makefile.am +++ b/tests/lib/Makefile.am @@ -2,14 +2,11 @@ SUBDIRS = AM_CPPFLAGS += -I$(top_srcdir)/tests/utils -LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la +COMMON_TEST_LDADD = \ + $(top_builddir)/tests/utils/tap/libtap.la \ + $(top_builddir)/tests/utils/libtestcommon.la -libtestcommon_la_SOURCES = common.c common.h -noinst_LTLIBRARIES = libtestcommon.la - -COMMON_TEST_LDADD = $(LIBTAP) $(builddir)/libtestcommon.la - -test_bitfield_LDADD = $(LIBTAP) $(builddir)/libtestcommon.la +test_bitfield_LDADD = $(COMMON_TEST_LDADD) test_ctf_writer_LDADD = \ $(COMMON_TEST_LDADD) \ diff --git a/tests/lib/common.c b/tests/lib/common.c deleted file mode 100644 index 1878d777..00000000 --- a/tests/lib/common.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * common.c - * - * Lib BabelTrace - Common function to all tests - * - * Copyright 2012 - Yannick Brosseau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; under version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - -#define RMDIR_NFDOPEN 8 - -static -int nftw_recursive_rmdir(const char *file, const struct stat *sb, int flag, - struct FTW *s) -{ - switch (flag) { - case FTW_F: - unlink(file); - break; - case FTW_DP: - rmdir(file); - break; - } - - return 0; -} - -void recursive_rmdir(const char *path) -{ - int nftw_flags = FTW_PHYS | FTW_DEPTH; - - nftw(path, nftw_recursive_rmdir, RMDIR_NFDOPEN, nftw_flags); -} diff --git a/tests/lib/common.h b/tests/lib/common.h deleted file mode 100644 index daa224f2..00000000 --- a/tests/lib/common.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * common.h - * - * Lib BabelTrace - Common function to all tests - * - * Copyright 2012 - Yannick Brosseau - * Copyright 2016 - Jérémie Galarneau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; under version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef _TESTS_COMMON_H -#define _TESTS_COMMON_H - -struct bt_context; - -void recursive_rmdir(const char *path); - -#endif /* _TESTS_COMMON_H */ diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am index c23292e2..d010e2b0 100644 --- a/tests/utils/Makefile.am +++ b/tests/utils/Makefile.am @@ -1,3 +1,7 @@ SUBDIRS = tap + +noinst_LTLIBRARIES = libtestcommon.la +libtestcommon_la_SOURCES = common.c common.h + # Directories added to EXTRA_DIST will be recursively copied to the distribution. EXTRA_DIST = python diff --git a/tests/utils/common.c b/tests/utils/common.c new file mode 100644 index 00000000..1878d777 --- /dev/null +++ b/tests/utils/common.c @@ -0,0 +1,50 @@ +/* + * common.c + * + * Lib BabelTrace - Common function to all tests + * + * Copyright 2012 - Yannick Brosseau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include + +#define RMDIR_NFDOPEN 8 + +static +int nftw_recursive_rmdir(const char *file, const struct stat *sb, int flag, + struct FTW *s) +{ + switch (flag) { + case FTW_F: + unlink(file); + break; + case FTW_DP: + rmdir(file); + break; + } + + return 0; +} + +void recursive_rmdir(const char *path) +{ + int nftw_flags = FTW_PHYS | FTW_DEPTH; + + nftw(path, nftw_recursive_rmdir, RMDIR_NFDOPEN, nftw_flags); +} diff --git a/tests/utils/common.h b/tests/utils/common.h new file mode 100644 index 00000000..daa224f2 --- /dev/null +++ b/tests/utils/common.h @@ -0,0 +1,29 @@ +/* + * common.h + * + * Lib BabelTrace - Common function to all tests + * + * Copyright 2012 - Yannick Brosseau + * Copyright 2016 - Jérémie Galarneau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef _TESTS_COMMON_H +#define _TESTS_COMMON_H + +struct bt_context; + +void recursive_rmdir(const char *path); + +#endif /* _TESTS_COMMON_H */