From: Michael Jeanson Date: Tue, 16 Feb 2021 21:51:47 +0000 (-0500) Subject: fix: remove 'src/' from modules install path X-Git-Tag: v2.13.0-rc1~12 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=600da0c9c2a133a3154bd5ad6df428d8e3256e30;p=lttng-modules.git fix: remove 'src/' from modules install path The move of the modules sources in the 'src/' subdirectory had the unexpected side effect of adding 'src/' to the module install path inside '/lib/modules/$(uname -r)/extra'. Adjust the Makefiles to return to the initial behavior. Change-Id: I280fe8a1e5ef367edeec0a6351351a233cc6f0be Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers Change-Id: Ifcc64ea95c0e1435567150d976d42e3add3f7523 --- diff --git a/Kbuild.common b/Kbuild.common deleted file mode 100644 index f64cb09d..00000000 --- a/Kbuild.common +++ /dev/null @@ -1,62 +0,0 @@ -# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only) - -ccflags-y += -DLTTNG_LINUX_MAJOR=$(VERSION) -ccflags-y += -DLTTNG_LINUX_MINOR=$(PATCHLEVEL) -ccflags-y += -DLTTNG_LINUX_PATCH=$(SUBLEVEL) - -# Work-around for distro-specific public modules ABI breakages. -# Some distributions break the public module instrumentation ABI -# compared to upstream stable kernels without providing other mean than -# the kernel EXTRAVERSION to figure it out. Translate this information -# into a define visible from the C preprocessor. - -DEB_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-debian-version.sh $(CURDIR)) - -ifneq ($(DEB_API_VERSION), 0) - ccflags-y += -DDEBIAN_API_VERSION=$(DEB_API_VERSION) -endif - -RHEL_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-rhel-version.sh $(CURDIR)) - -ifneq ($(RHEL_API_VERSION), 0) - ccflags-y += -DRHEL_API_VERSION=$(RHEL_API_VERSION) -endif - -SLE_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-sle-version.sh $(CURDIR)) - -ifneq ($(SLE_API_VERSION), 0) - ccflags-y += -DSLE_API_VERSION=$(SLE_API_VERSION) -endif - -FEDORA_REVISION_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-fedora-version.sh $(CURDIR)) - -ifneq ($(FEDORA_REVISION_VERSION), 0) - ccflags-y += -DFEDORA_REVISION_VERSION=$(FEDORA_REVISION_VERSION) -endif - -RT_PATCH_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/rt-patch-version.sh $(CURDIR)) - -ifneq ($(RT_PATCH_VERSION), 0) - ccflags-y += -DRT_PATCH_VERSION=$(RT_PATCH_VERSION) -endif - -EXTRA_VERSION_NAME:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-name.sh $(TOP_LTTNG_MODULES_DIR)) - -ifneq ($(EXTRA_VERSION_NAME), 0) - ccflags-y += -DLTTNG_EXTRA_VERSION_NAME='"$(EXTRA_VERSION_NAME)"' -endif - -EXTRA_VERSION_GIT:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-git.sh $(TOP_LTTNG_MODULES_DIR)) - -ifneq ($(EXTRA_VERSION_GIT), 0) - ccflags-y += -DLTTNG_EXTRA_VERSION_GIT='"$(EXTRA_VERSION_GIT)"' -endif - -EXTRA_VERSION_PATCHES:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-patches.sh $(TOP_LTTNG_MODULES_DIR)) - -mnt_ns_dep = $(srctree)/fs/mount.h -ifeq ($(wildcard $(mnt_ns_dep)),) - ccflags-y += -DLTTNG_MNT_NS_MISSING_HEADER -endif - -# vim:syntax=make diff --git a/Kconfig b/Kconfig deleted file mode 100644 index 85946faf..00000000 --- a/Kconfig +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - -config LTTNG - tristate "LTTng support" - select TRACING - help - LTTng is an open source tracing framework for Linux. - - See https://lttng.org/ - - To compile as a set of modules, choose M here. To compile into - the Linux kernel image, choose Y. - - If unsure, say N. - -source "lttng/tests/Kconfig" diff --git a/Makefile b/Makefile index c586efed..37eb389b 100644 --- a/Makefile +++ b/Makefile @@ -2,33 +2,10 @@ ifneq ($(KERNELRELEASE),) - # This part of the Makefile is used when called by the kernel build system - # and defines the modules to be built. - - ifdef CONFIG_LOCALVERSION # Check if dot-config is included. - ifeq ($(CONFIG_TRACEPOINTS),) - $(error The option CONFIG_TRACEPOINTS needs to be enabled in your kernel configuration) - endif # CONFIG_TRACEPOINTS - endif # ifdef CONFIG_LOCALVERSION - - TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST))) - - lttng_check_linux_version = $(shell pwd)/include/linux/version.h - lttng_check_generated_linux_version = $(shell pwd)/include/generated/uapi/linux/version.h - - # - # Check for stale version.h, which can be a leftover from an old Linux - # kernel tree moved to a newer kernel version, only pruned by make - # distclean. - # - ifneq ($(wildcard $(lttng_check_linux_version)),) - ifneq ($(wildcard $(lttng_check_generated_linux_version)),) - $(error Duplicate version.h files found in $(lttng_check_linux_version) and $(lttng_check_generated_linux_version). Consider running make distclean on your kernel, or removing the stale $(lttng_check_linux_version) file) - endif - endif - - obj-$(CONFIG_LTTNG) += src/ - obj-$(CONFIG_LTTNG) += tests/ +# This part of the Makefile is used when called by the kernel build system +# and defines the modules to be built. + +obj-$(CONFIG_LTTNG) += src/ else # KERNELRELEASE @@ -43,15 +20,15 @@ CFLAGS = $(EXTCFLAGS) default: modules modules: - $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules + $(MAKE) -C $(KERNELDIR) M=$(PWD)/src CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules modules_install: - $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules_install + $(MAKE) -C $(KERNELDIR) M=$(PWD)/src CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules_install clean: - $(MAKE) -C $(KERNELDIR) M=$(PWD) clean + $(MAKE) -C $(KERNELDIR) M=$(PWD)/src clean %.i: %.c - $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m $@ + $(MAKE) -C $(KERNELDIR) M=$(PWD)/src CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m $@ endif # KERNELRELEASE diff --git a/src/Kbuild b/src/Kbuild index e7593fd8..a5a840a7 100644 --- a/src/Kbuild +++ b/src/Kbuild @@ -1,8 +1,28 @@ # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) +ifdef CONFIG_LOCALVERSION # Check if dot-config is included. + ifeq ($(CONFIG_TRACEPOINTS),) + $(error The option CONFIG_TRACEPOINTS needs to be enabled in your kernel configuration) + endif # CONFIG_TRACEPOINTS +endif # ifdef CONFIG_LOCALVERSION + TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/.. -include $(TOP_LTTNG_MODULES_DIR)/Kbuild.common +lttng_check_linux_version = $(shell pwd)/include/linux/version.h +lttng_check_generated_linux_version = $(shell pwd)/include/generated/uapi/linux/version.h + +# +# Check for stale version.h, which can be a leftover from an old Linux +# kernel tree moved to a newer kernel version, only pruned by make +# distclean. +# +ifneq ($(wildcard $(lttng_check_linux_version)),) + ifneq ($(wildcard $(lttng_check_generated_linux_version)),) + $(error Duplicate version.h files found in $(lttng_check_linux_version) and $(lttng_check_generated_linux_version). Consider running make distclean on your kernel, or removing the stale $(lttng_check_linux_version) file) + endif +endif + +include $(TOP_LTTNG_MODULES_DIR)/src/Kbuild.common ccflags-y += -I$(TOP_LTTNG_MODULES_DIR)/include @@ -125,3 +145,4 @@ lttng-statedump-objs := lttng-statedump-impl.o obj-$(CONFIG_LTTNG) += probes/ obj-$(CONFIG_LTTNG) += lib/ +obj-$(CONFIG_LTTNG) += tests/ diff --git a/src/Kbuild.common b/src/Kbuild.common new file mode 100644 index 00000000..f64cb09d --- /dev/null +++ b/src/Kbuild.common @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only) + +ccflags-y += -DLTTNG_LINUX_MAJOR=$(VERSION) +ccflags-y += -DLTTNG_LINUX_MINOR=$(PATCHLEVEL) +ccflags-y += -DLTTNG_LINUX_PATCH=$(SUBLEVEL) + +# Work-around for distro-specific public modules ABI breakages. +# Some distributions break the public module instrumentation ABI +# compared to upstream stable kernels without providing other mean than +# the kernel EXTRAVERSION to figure it out. Translate this information +# into a define visible from the C preprocessor. + +DEB_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-debian-version.sh $(CURDIR)) + +ifneq ($(DEB_API_VERSION), 0) + ccflags-y += -DDEBIAN_API_VERSION=$(DEB_API_VERSION) +endif + +RHEL_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-rhel-version.sh $(CURDIR)) + +ifneq ($(RHEL_API_VERSION), 0) + ccflags-y += -DRHEL_API_VERSION=$(RHEL_API_VERSION) +endif + +SLE_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-sle-version.sh $(CURDIR)) + +ifneq ($(SLE_API_VERSION), 0) + ccflags-y += -DSLE_API_VERSION=$(SLE_API_VERSION) +endif + +FEDORA_REVISION_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-fedora-version.sh $(CURDIR)) + +ifneq ($(FEDORA_REVISION_VERSION), 0) + ccflags-y += -DFEDORA_REVISION_VERSION=$(FEDORA_REVISION_VERSION) +endif + +RT_PATCH_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/rt-patch-version.sh $(CURDIR)) + +ifneq ($(RT_PATCH_VERSION), 0) + ccflags-y += -DRT_PATCH_VERSION=$(RT_PATCH_VERSION) +endif + +EXTRA_VERSION_NAME:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-name.sh $(TOP_LTTNG_MODULES_DIR)) + +ifneq ($(EXTRA_VERSION_NAME), 0) + ccflags-y += -DLTTNG_EXTRA_VERSION_NAME='"$(EXTRA_VERSION_NAME)"' +endif + +EXTRA_VERSION_GIT:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-git.sh $(TOP_LTTNG_MODULES_DIR)) + +ifneq ($(EXTRA_VERSION_GIT), 0) + ccflags-y += -DLTTNG_EXTRA_VERSION_GIT='"$(EXTRA_VERSION_GIT)"' +endif + +EXTRA_VERSION_PATCHES:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-patches.sh $(TOP_LTTNG_MODULES_DIR)) + +mnt_ns_dep = $(srctree)/fs/mount.h +ifeq ($(wildcard $(mnt_ns_dep)),) + ccflags-y += -DLTTNG_MNT_NS_MISSING_HEADER +endif + +# vim:syntax=make diff --git a/src/Kconfig b/src/Kconfig new file mode 100644 index 00000000..85946faf --- /dev/null +++ b/src/Kconfig @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + +config LTTNG + tristate "LTTng support" + select TRACING + help + LTTng is an open source tracing framework for Linux. + + See https://lttng.org/ + + To compile as a set of modules, choose M here. To compile into + the Linux kernel image, choose Y. + + If unsure, say N. + +source "lttng/tests/Kconfig" diff --git a/src/lib/Kbuild b/src/lib/Kbuild index b0f49b6b..b356736c 100644 --- a/src/lib/Kbuild +++ b/src/lib/Kbuild @@ -2,7 +2,7 @@ TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/../.. -include $(TOP_LTTNG_MODULES_DIR)/Kbuild.common +include $(TOP_LTTNG_MODULES_DIR)/src/Kbuild.common ccflags-y += -I$(TOP_LTTNG_MODULES_DIR)/include diff --git a/src/probes/Kbuild b/src/probes/Kbuild index 0fc7e9c2..e26b4359 100644 --- a/src/probes/Kbuild +++ b/src/probes/Kbuild @@ -2,7 +2,7 @@ TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/../.. -include $(TOP_LTTNG_MODULES_DIR)/Kbuild.common +include $(TOP_LTTNG_MODULES_DIR)/src/Kbuild.common ccflags-y += -I$(TOP_LTTNG_MODULES_DIR)/include diff --git a/src/tests/Kbuild b/src/tests/Kbuild new file mode 100644 index 00000000..9cf13342 --- /dev/null +++ b/src/tests/Kbuild @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + +TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/../.. + +include $(TOP_LTTNG_MODULES_DIR)/src/Kbuild.common + +ccflags-y += -I$(TOP_LTTNG_MODULES_DIR)/include + +obj-$(CONFIG_LTTNG) += lttng-test.o +lttng-test-objs := probes/lttng-test.o + +obj-$(CONFIG_LTTNG_CLOCK_PLUGIN_TEST) += lttng-clock-plugin-test.o +lttng-clock-plugin-test-objs := clock-plugin/lttng-clock-plugin-test.o + +# vim:syntax=make diff --git a/src/tests/Kconfig b/src/tests/Kconfig new file mode 100644 index 00000000..974fa10d --- /dev/null +++ b/src/tests/Kconfig @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + +config LTTNG_CLOCK_PLUGIN_TEST + tristate "Use test plugin as trace clock" + depends on LTTNG + help + Use the test clock as trace clock. This plugin freezes the + time with 1 KHz for regression test. + It's recommended to build this as a module to work with the + lttng-tools test suite. diff --git a/src/tests/clock-plugin/lttng-clock-plugin-test.c b/src/tests/clock-plugin/lttng-clock-plugin-test.c new file mode 100644 index 00000000..6c4213bd --- /dev/null +++ b/src/tests/clock-plugin/lttng-clock-plugin-test.c @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng-clock-plugin-test.c + * + * Copyright (C) 2014, 2016 Mathieu Desnoyers + */ + +#include +#include +#include +#include + +#include +#include /* From lttng-modules */ + +static u64 trace_clock_read64_example(void) +{ + /* Freeze time. */ + return 0; +} + +static u64 trace_clock_freq_example(void) +{ + return 1000; /* 1KHz */ +} + +static int trace_clock_uuid_example(char *uuid) +{ + const char myuuid[] = "83c63deb-7aa4-48fb-abda-946f400d76e6"; + memcpy(uuid, myuuid, LTTNG_MODULES_UUID_STR_LEN); + return 0; +} + +static const char *trace_clock_name_example(void) +{ + return "lttng_test_clock_override"; +} + +static const char *trace_clock_description_example(void) +{ + return "Freeze time with 1KHz for regression test"; +} + +static +struct lttng_trace_clock ltc = { + .read64 = trace_clock_read64_example, + .freq = trace_clock_freq_example, + .uuid = trace_clock_uuid_example, + .name = trace_clock_name_example, + .description = trace_clock_description_example, +}; + +static __init +int lttng_clock_plugin_init(void) +{ + return lttng_clock_register_plugin(<c, THIS_MODULE); +} +fs_initcall(lttng_clock_plugin_init); + +static __exit +void lttng_clock_plugin_exit(void) +{ + lttng_clock_unregister_plugin(<c, THIS_MODULE); +} +module_exit(lttng_clock_plugin_exit); + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Mathieu Desnoyers "); +MODULE_DESCRIPTION("LTTng Clock Plugin Example"); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION) + LTTNG_MODULES_EXTRAVERSION); diff --git a/src/tests/probes/lttng-test.c b/src/tests/probes/lttng-test.c new file mode 100644 index 00000000..86007e5e --- /dev/null +++ b/src/tests/probes/lttng-test.c @@ -0,0 +1,144 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng-test.c + * + * Linux Trace Toolkit Next Generation Test Module + * + * Copyright 2015 Mathieu Desnoyers + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#define TP_MODULE_NOAUTOLOAD +#define LTTNG_PACKAGE_BUILD +#define CREATE_TRACE_POINTS +#define TRACE_INCLUDE_PATH instrumentation/events +#define TRACE_INCLUDE_FILE lttng-test +#define LTTNG_INSTRUMENTATION +#include + +LTTNG_DEFINE_TRACE(lttng_test_filter_event, + PARAMS(int anint, int netint, long *values, + char *text, size_t textlen, + char *etext, uint32_t * net_values), + PARAMS(anint, netint, values, text, textlen, etext, net_values) +); + +#define LTTNG_TEST_FILTER_EVENT_FILE "lttng-test-filter-event" + +#define LTTNG_WRITE_COUNT_MAX 64 + +static struct proc_dir_entry *lttng_test_filter_event_dentry; + +static +void trace_test_event(unsigned int nr_iter) +{ + int i, netint; + long values[] = { 1, 2, 3 }; + uint32_t net_values[] = { 1, 2, 3 }; + char text[10] = "test"; + char escape[10] = "\\*"; + + for (i = 0; i < 3; i++) { + net_values[i] = htonl(net_values[i]); + } + for (i = 0; i < nr_iter; i++) { + netint = htonl(i); + trace_lttng_test_filter_event(i, netint, values, text, strlen(text), escape, net_values); + } +} + +/** + * lttng_filter_event_write - trigger a lttng_test_filter_event + * @file: file pointer + * @user_buf: user string + * @count: length to copy + * + * Return -1 on error, with EFAULT errno. Returns count on success. + */ +static +ssize_t lttng_test_filter_event_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + unsigned int nr_iter; + ssize_t written; + int ret; + + /* Get the number of iterations */ + ret = kstrtouint_from_user(user_buf, count, 10, &nr_iter); + if (ret) { + written = ret; + goto end; + } + /* Trace the event */ + trace_test_event(nr_iter); + written = count; + *ppos += written; +end: + return written; +} + +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0)) +static const struct proc_ops lttng_test_filter_event_proc_ops = { + .proc_write = lttng_test_filter_event_write, +}; +#else +static const struct file_operations lttng_test_filter_event_proc_ops = { + .write = lttng_test_filter_event_write, +}; +#endif + +static +int __init lttng_test_init(void) +{ + int ret = 0; + + (void) wrapper_lttng_fixup_sig(THIS_MODULE); + wrapper_vmalloc_sync_mappings(); + lttng_test_filter_event_dentry = + proc_create_data(LTTNG_TEST_FILTER_EVENT_FILE, + S_IRUGO | S_IWUGO, NULL, + <tng_test_filter_event_proc_ops, NULL); + if (!lttng_test_filter_event_dentry) { + printk(KERN_ERR "Error creating LTTng test filter file\n"); + ret = -ENOMEM; + goto error; + } + ret = __lttng_events_init__lttng_test(); + if (ret) + goto error_events; + return ret; + +error_events: + remove_proc_entry(LTTNG_TEST_FILTER_EVENT_FILE, NULL); +error: + return ret; +} + +module_init(lttng_test_init); + +static +void __exit lttng_test_exit(void) +{ + __lttng_events_exit__lttng_test(); + if (lttng_test_filter_event_dentry) + remove_proc_entry(LTTNG_TEST_FILTER_EVENT_FILE, NULL); +} + +module_exit(lttng_test_exit); + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Mathieu Desnoyers "); +MODULE_DESCRIPTION("LTTng Test"); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION) + LTTNG_MODULES_EXTRAVERSION); diff --git a/tests/Kbuild b/tests/Kbuild deleted file mode 100644 index 906cbac8..00000000 --- a/tests/Kbuild +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - -TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/.. - -include $(TOP_LTTNG_MODULES_DIR)/Kbuild.common - -ccflags-y += -I$(TOP_LTTNG_MODULES_DIR)/include - -obj-$(CONFIG_LTTNG) += lttng-test.o -lttng-test-objs := probes/lttng-test.o - -obj-$(CONFIG_LTTNG_CLOCK_PLUGIN_TEST) += lttng-clock-plugin-test.o -lttng-clock-plugin-test-objs := clock-plugin/lttng-clock-plugin-test.o - -# vim:syntax=make diff --git a/tests/Kconfig b/tests/Kconfig deleted file mode 100644 index 974fa10d..00000000 --- a/tests/Kconfig +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - -config LTTNG_CLOCK_PLUGIN_TEST - tristate "Use test plugin as trace clock" - depends on LTTNG - help - Use the test clock as trace clock. This plugin freezes the - time with 1 KHz for regression test. - It's recommended to build this as a module to work with the - lttng-tools test suite. diff --git a/tests/clock-plugin/lttng-clock-plugin-test.c b/tests/clock-plugin/lttng-clock-plugin-test.c deleted file mode 100644 index 6c4213bd..00000000 --- a/tests/clock-plugin/lttng-clock-plugin-test.c +++ /dev/null @@ -1,73 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-clock-plugin-test.c - * - * Copyright (C) 2014, 2016 Mathieu Desnoyers - */ - -#include -#include -#include -#include - -#include -#include /* From lttng-modules */ - -static u64 trace_clock_read64_example(void) -{ - /* Freeze time. */ - return 0; -} - -static u64 trace_clock_freq_example(void) -{ - return 1000; /* 1KHz */ -} - -static int trace_clock_uuid_example(char *uuid) -{ - const char myuuid[] = "83c63deb-7aa4-48fb-abda-946f400d76e6"; - memcpy(uuid, myuuid, LTTNG_MODULES_UUID_STR_LEN); - return 0; -} - -static const char *trace_clock_name_example(void) -{ - return "lttng_test_clock_override"; -} - -static const char *trace_clock_description_example(void) -{ - return "Freeze time with 1KHz for regression test"; -} - -static -struct lttng_trace_clock ltc = { - .read64 = trace_clock_read64_example, - .freq = trace_clock_freq_example, - .uuid = trace_clock_uuid_example, - .name = trace_clock_name_example, - .description = trace_clock_description_example, -}; - -static __init -int lttng_clock_plugin_init(void) -{ - return lttng_clock_register_plugin(<c, THIS_MODULE); -} -fs_initcall(lttng_clock_plugin_init); - -static __exit -void lttng_clock_plugin_exit(void) -{ - lttng_clock_unregister_plugin(<c, THIS_MODULE); -} -module_exit(lttng_clock_plugin_exit); - -MODULE_LICENSE("GPL and additional rights"); -MODULE_AUTHOR("Mathieu Desnoyers "); -MODULE_DESCRIPTION("LTTng Clock Plugin Example"); -MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." - __stringify(LTTNG_MODULES_MINOR_VERSION) "." - __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION) - LTTNG_MODULES_EXTRAVERSION); diff --git a/tests/probes/lttng-test.c b/tests/probes/lttng-test.c deleted file mode 100644 index 86007e5e..00000000 --- a/tests/probes/lttng-test.c +++ /dev/null @@ -1,144 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-test.c - * - * Linux Trace Toolkit Next Generation Test Module - * - * Copyright 2015 Mathieu Desnoyers - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#define TP_MODULE_NOAUTOLOAD -#define LTTNG_PACKAGE_BUILD -#define CREATE_TRACE_POINTS -#define TRACE_INCLUDE_PATH instrumentation/events -#define TRACE_INCLUDE_FILE lttng-test -#define LTTNG_INSTRUMENTATION -#include - -LTTNG_DEFINE_TRACE(lttng_test_filter_event, - PARAMS(int anint, int netint, long *values, - char *text, size_t textlen, - char *etext, uint32_t * net_values), - PARAMS(anint, netint, values, text, textlen, etext, net_values) -); - -#define LTTNG_TEST_FILTER_EVENT_FILE "lttng-test-filter-event" - -#define LTTNG_WRITE_COUNT_MAX 64 - -static struct proc_dir_entry *lttng_test_filter_event_dentry; - -static -void trace_test_event(unsigned int nr_iter) -{ - int i, netint; - long values[] = { 1, 2, 3 }; - uint32_t net_values[] = { 1, 2, 3 }; - char text[10] = "test"; - char escape[10] = "\\*"; - - for (i = 0; i < 3; i++) { - net_values[i] = htonl(net_values[i]); - } - for (i = 0; i < nr_iter; i++) { - netint = htonl(i); - trace_lttng_test_filter_event(i, netint, values, text, strlen(text), escape, net_values); - } -} - -/** - * lttng_filter_event_write - trigger a lttng_test_filter_event - * @file: file pointer - * @user_buf: user string - * @count: length to copy - * - * Return -1 on error, with EFAULT errno. Returns count on success. - */ -static -ssize_t lttng_test_filter_event_write(struct file *file, const char __user *user_buf, - size_t count, loff_t *ppos) -{ - unsigned int nr_iter; - ssize_t written; - int ret; - - /* Get the number of iterations */ - ret = kstrtouint_from_user(user_buf, count, 10, &nr_iter); - if (ret) { - written = ret; - goto end; - } - /* Trace the event */ - trace_test_event(nr_iter); - written = count; - *ppos += written; -end: - return written; -} - -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0)) -static const struct proc_ops lttng_test_filter_event_proc_ops = { - .proc_write = lttng_test_filter_event_write, -}; -#else -static const struct file_operations lttng_test_filter_event_proc_ops = { - .write = lttng_test_filter_event_write, -}; -#endif - -static -int __init lttng_test_init(void) -{ - int ret = 0; - - (void) wrapper_lttng_fixup_sig(THIS_MODULE); - wrapper_vmalloc_sync_mappings(); - lttng_test_filter_event_dentry = - proc_create_data(LTTNG_TEST_FILTER_EVENT_FILE, - S_IRUGO | S_IWUGO, NULL, - <tng_test_filter_event_proc_ops, NULL); - if (!lttng_test_filter_event_dentry) { - printk(KERN_ERR "Error creating LTTng test filter file\n"); - ret = -ENOMEM; - goto error; - } - ret = __lttng_events_init__lttng_test(); - if (ret) - goto error_events; - return ret; - -error_events: - remove_proc_entry(LTTNG_TEST_FILTER_EVENT_FILE, NULL); -error: - return ret; -} - -module_init(lttng_test_init); - -static -void __exit lttng_test_exit(void) -{ - __lttng_events_exit__lttng_test(); - if (lttng_test_filter_event_dentry) - remove_proc_entry(LTTNG_TEST_FILTER_EVENT_FILE, NULL); -} - -module_exit(lttng_test_exit); - -MODULE_LICENSE("GPL and additional rights"); -MODULE_AUTHOR("Mathieu Desnoyers "); -MODULE_DESCRIPTION("LTTng Test"); -MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." - __stringify(LTTNG_MODULES_MINOR_VERSION) "." - __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION) - LTTNG_MODULES_EXTRAVERSION);