libtracefs install and test fixes
cover libtracefs install and test fixes
From: "Tzvetomir (VMware) Stoyanov" <[email protected]>
Added support for pkg-config, used by library users. Added library unit tests.
Made the installation consistent with libtraceevent.
Tzvetomir (VMware) Stoyanov (3):
libtracefs: Add support for pkg-config
libtracefs: Add unit tests
libtracefs: Do not install library in a subfolder
Makefile | 58 +++- libtracefs.pc.template | 10 + utest/Makefile | 42 +++ utest/README | 15 ++ utest/trace-utest.c | 83 ++++++ utest/trace-utest.h | 11 + utest/tracefs-utest.c | 588 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 797 insertions(+), 10 deletions(-) create mode 100644 libtracefs.pc.template create mode 100644 utest/Makefile create mode 100644 utest/README create mode 100644 utest/trace-utest.c create mode 100644 utest/trace-utest.h create mode 100644 utest/tracefs-utest.c
Signature · 1 line
2.28.0
PATCH 1/3 libtracefs: Add support for pkg-config
From: Tzvetomir (VMware) Stoyanov <[email protected]>
The pkg-config file is used by the library users to check if the library is installed on the system and get required CFLAGS and LDFLAGS in order to use it.
--- Makefile | 35 ++++++++++++++++++++++++++++++++--- libtracefs.pc.template | 10 ++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 libtracefs.pc.template
Makefile +32 -3
@@ -1,4 +1,3 @@ -# SPDX-License-Identifier: LGPL-2.1 # libtracefs version TFS_VERSION = 0 TFS_PATCHLEVEL = 1
@@ -27,6 +26,7 @@ endef # Allow setting CC and AR, or setting CROSS_COMPILE as a prefix. $(call allow-override,CC,$(CROSS_COMPILE)gcc) $(call allow-override,AR,$(CROSS_COMPILE)ar) +$(call allow-override,PKG_CONFIG,pkg-config) EXT = -std=gnu99 INSTALL = install
@@ -47,6 +47,11 @@ libdir ?= $(prefix)/lib libdir_SQ = '$(subst ','\'',$(libdir))' includedir = $(prefix)/include includedir_SQ = '$(subst ','\'',$(includedir))' +pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \ + --variable pc_path pkg-config | tr ":" " ")) + +PKG_CONFIG_SOURCE_FILE = libtracefs.pc +PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE)) ifeq ($(prefix),/usr/local) etcdir ?= /etc
@@ -157,7 +162,7 @@ LIB_INSTALL := $(addprefix $(bdir)/,$(LIB_INSTALL)) TARGETS = $(LIBTRACEFS_SHARED) $(LIBTRACEFS_STATIC) -all_cmd: $(TARGETS) +all_cmd: $(TARGETS) $(PKG_CONFIG_FILE) libtracefs.a: $(LIBTRACEFS_STATIC) libtracefs.so: $(LIBTRACEFS_SHARED)
@@ -175,6 +180,25 @@ define find_tag_files ! -name '\.#' -print endef +define do_make_pkgconfig_file + cp -f ${PKG_CONFIG_SOURCE_FILE}.template ${PKG_CONFIG_FILE}; \ + sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; \ + sed -i "s|LIB_VERSION|${TRACEFS_VERSION}|g" ${PKG_CONFIG_FILE}; \ + sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \ + sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE}; +endef + +$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template + $(Q) $(call do_make_pkgconfig_file,$(prefix)) + +define do_install_pkgconfig_file + if [ -n "${pkgconfig_dir}" ]; then \ + $(call do_install,$(PKG_CONFIG_FILE),$(pkgconfig_dir),644); \ + else \ + (echo Failed to locate pkg-config directory) 1>&2; \ + fi +endef + tags: force $(RM) tags $(call find_tag_files) | xargs ctags --extra=+f --c-kinds=+px
@@ -187,7 +211,7 @@ cscope: force $(RM) cscope* $(call find_tag_files) | cscope -b -q -install_libs: libs +install_libs: libs install_pkgconfig $(Q)$(call do_install,$(LIBTRACEFS_SHARED),$(libdir_SQ)/tracefs); \ cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)/tracefs $(Q)$(call do_install,$(src)/include/tracefs.h,$(includedir_SQ)/tracefs)
@@ -195,6 +219,10 @@ install_libs: libs install: install_libs +install_pkgconfig: $(PKG_CONFIG_FILE) + $(Q)$(call , $(PKG_CONFIG_FILE)) \ + $(call do_install_pkgconfig_file,$(prefix)) + doc: $(MAKE) -C $(src)/Documentation all doc_gui:
@@ -262,5 +290,6 @@ endif clean: $(RM) $(TARGETS) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d + $(RM) $(PKG_CONFIG_FILE) .PHONY: clean
libtracefs.pc.template new file +10 -0
@@ -0,0 +1,10 @@ +prefix=INSTALL_PREFIX +libdir=LIB_DIR +includedir=HEADER_DIR + +Name: libtracefs +URL: https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ +Description: Library for accessing ftrace file system +Version: LIB_VERSION +Cflags: -I${includedir} +Libs: -L${libdir} -ltracefs
Signature · 1 line
2.28.0
PATCH 2/3 libtracefs: Add unit tests
In reply to Tzvetomir Stoyanov (VMware)From: Tzvetomir (VMware) Stoyanov <[email protected]>
The CUnit test infrastructure is integrated in libtracefs.
http://cunit.sourceforge.net/
The library and its headers must be installed on the machine, in order to build the libtracefs unit tests. For Fedora, these packages must be installed:
CUnit, CUnit-devel
A new directory is added:
utest
containing unit tests implementation.
Added new target to the top Makefile:
make test
which builds the unit test binary:
utest/trace-utest
--- Makefile | 3 +- utest/Makefile | 42 +++ utest/README | 15 ++ utest/trace-utest.c | 83 ++++++ utest/trace-utest.h | 11 + utest/tracefs-utest.c | 588 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 741 insertions(+), 1 deletion(-) create mode 100644 utest/Makefile create mode 100644 utest/README create mode 100644 utest/trace-utest.c create mode 100644 utest/trace-utest.h create mode 100644 utest/tracefs-utest.c
Makefile +2 -1
@@ -125,7 +125,7 @@ LIBTRACEFS_SHARED = $(LIBTRACEFS_DIR)/libtracefs.so.$(TRACEFS_VERSION) TRACE_LIBS = -L$(LIBTRACEFS_DIR) -ltracefs export LIBS TRACE_LIBS -export LIBTRACEFS_STATIC LIBTRACEFS_SHARED +export LIBTRACEFS_STATIC LIBTRACEFS_SHARED LIBTRACEFS_DIR export Q SILENT VERBOSE EXT
@@ -289,6 +289,7 @@ ifneq ($(dep_includes),) endif clean: + $(MAKE) -C $(src)/utest clean $(RM) $(TARGETS) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(RM) $(PKG_CONFIG_FILE)
utest/Makefile new file +42 -0
42 lines not on this page · raw message
utest/README new file +15 -0
@@ -0,0 +1,15 @@ + +Unit tests for tracefs library. The tests use CUnit framework: + http://cunit.sourceforge.net/ +which must be pre installed on the system, before building the unit tests. +The framework can be downloaded, compiled and installed manually, or +using a precompiled distro package: + + Fedora: + CUnit + CUnit-devel + + Ubuntu and Debian: + libcunit1 + libcunit1-doc + libcunit1-dev
utest/trace-utest.c new file +83 -0
83 lines not on this page · raw message
utest/trace-utest.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ +/* +* Copyright (C) 2020, VMware, Tzvetomir Stoyanov <[email protected]> +* +*/ +#ifndef _TRACE_UTEST_H_ +#define _TRACE_UTEST_H_ + +void test_tracefs_lib (void ); + +#endif /* _TRACE_UTEST_H_ */
utest/tracefs-utest.c new file +588 -0
588 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 3/3 libtracefs: Do not install library in a subfolder
In reply to Tzvetomir Stoyanov (VMware)From: Tzvetomir (VMware) Stoyanov <[email protected]>
Make the installation consistent with libtraceevent:
- Install tracefs.h in $(prefix)/include/tracefs/
- Install libtracefs* in $(prefix)/lib or $(prefix)/lib64
--- Makefile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
Makefile +14 -6
@@ -38,14 +38,22 @@ INSTALL = install DESTDIR ?= DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' +LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) +ifeq ($(LP64), 1) + libdir_relative_temp = lib64 +else + libdir_relative_temp = lib +endif + +libdir_relative ?= $(libdir_relative_temp) prefix ?= /usr/local bindir_relative = bin bindir = $(prefix)/$(bindir_relative) man_dir = $(prefix)/share/man man_dir_SQ = '$(subst ','\'',$(man_dir))' -libdir ?= $(prefix)/lib +libdir = $(prefix)/$(libdir_relative) libdir_SQ = '$(subst ','\'',$(libdir))' -includedir = $(prefix)/include +includedir = $(prefix)/include/tracefs includedir_SQ = '$(subst ','\'',$(includedir))' pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \ --variable pc_path pkg-config | tr ":" " "))
@@ -212,10 +220,10 @@ cscope: force $(call find_tag_files) | cscope -b -q install_libs: libs install_pkgconfig - $(Q)$(call do_install,$(LIBTRACEFS_SHARED),$(libdir_SQ)/tracefs); \ - cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)/tracefs - $(Q)$(call do_install,$(src)/include/tracefs.h,$(includedir_SQ)/tracefs) - $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/tracefs) + $(Q)$(call do_install,$(LIBTRACEFS_SHARED),$(libdir_SQ)); \ + cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ) + $(Q)$(call do_install,$(src)/include/tracefs.h,$(includedir_SQ)) + $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)) install: install_libs
Signature · 1 line
2.28.0