* [PATCH 3/3] libtracefs: Add test instructions for openSUSE
@ 2022-08-26 14:33 Alexandre Vicenzi
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Vicenzi @ 2022-08-26 14:33 UTC (permalink / raw)
To: linux-trace-devel; +Cc: rostedt, Alexandre Vicenzi
Add CUnit setup instructions for openSUSE and SLE.
---
utest/README | 3 +++
1 file changed, 3 insertions(+)
diff --git a/utest/README b/utest/README
index ed92042..647e460 100644
--- a/utest/README
+++ b/utest/README
@@ -13,3 +13,6 @@ using a precompiled distro package:
libcunit1
libcunit1-doc
libcunit1-dev
+
+ openSUSE and SLE:
+ cunit-devel
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] libtracefs: Add test instructions for openSUSE
@ 2022-08-26 14:35 Alexandre Vicenzi
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Vicenzi @ 2022-08-26 14:35 UTC (permalink / raw)
To: linux-trace-devel; +Cc: rostedt, Alexandre Vicenzi
Add CUnit setup instructions for openSUSE and SLE.
Signed-off-by: Alexandre Vicenzi <alexandre.vicenzi@suse.com>
---
utest/README | 3 +++
1 file changed, 3 insertions(+)
diff --git a/utest/README b/utest/README
index ed92042..647e460 100644
--- a/utest/README
+++ b/utest/README
@@ -13,3 +13,6 @@ using a precompiled distro package:
libcunit1
libcunit1-doc
libcunit1-dev
+
+ openSUSE and SLE:
+ cunit-devel
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 1/3] libtracefs: Add tracefs_tracer_available helper
@ 2022-08-26 14:24 Alexandre Vicenzi
2022-08-26 14:24 ` [PATCH 3/3] libtracefs: Add test instructions for openSUSE Alexandre Vicenzi
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Vicenzi @ 2022-08-26 14:24 UTC (permalink / raw)
To: linux-trace-devel; +Cc: rostedt, Alexandre Vicenzi
Add tracefs_tracer_available helper function to check if a giver tracer is available.
Signed-off-by: Alexandre Vicenzi <alexandre.vicenzi@suse.com>
---
Documentation/libtracefs-utils.txt | 11 +++++++++--
Documentation/libtracefs.txt | 1 +
include/tracefs.h | 2 ++
src/tracefs-utils.c | 28 ++++++++++++++++++++++++++++
utest/tracefs-utest.c | 3 +++
5 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/Documentation/libtracefs-utils.txt b/Documentation/libtracefs-utils.txt
index ddbd675..ab16cc6 100644
--- a/Documentation/libtracefs-utils.txt
+++ b/Documentation/libtracefs-utils.txt
@@ -3,8 +3,8 @@ libtracefs(3)
NAME
----
-tracefs_tracers, tracefs_get_clock, tracefs_list_free, tracefs_list_add,
-tracefs_list_size - Helper functions for working with trace file system.
+tracefs_tracers, tracefs_tracer_available, tracefs_get_clock, tracefs_list_free,
+tracefs_list_add, tracefs_list_size - Helper functions for working with trace file system.
SYNOPSIS
--------
@@ -13,6 +13,7 @@ SYNOPSIS
*#include <tracefs.h>*
char pass:[*]pass:[*]*tracefs_tracers*(const char pass:[*]_tracing_dir_);
+bool *tracefs_tracer_available*(const char pass:[*]_tracing_dir_, const char pass:[*]_tracer_);
char pass:[*]*tracefs_get_clock*(struct tracefs_instance pass:[*]_instance_);
void *tracefs_list_free*(char pass:[*]pass:[*]_list_);
char pass:[**]*tracefs_list_add*(char **_list_, const char *_string_);
@@ -30,6 +31,9 @@ for the trace systems of the local machine, or it may be a path to a copy
of the tracefs directory from another machine. The last entry in the array
as a NULL pointer. The array must be freed with *tracefs_list_free()* API.
+The *tracefs_tracer_available()* returns true if the _tracer_ is available
+in the given _tracing_dir_director_, and false otherwise.
+
The *tracefs_get_clock()* function returns name of the current trace clock,
used in the given _instance_. If _instance_ is NULL, the clock of the main
trace instance is returned. The returned string must be freed with free().
@@ -56,6 +60,9 @@ The *tracefs_tracers()* returns array of strings. The last element in that
array is a NULL pointer. The array must be freed with *tracefs_list_free()* API.
In case of an error, NULL is returned.
+The *tracefs_tracer_available()* returns true if the _tracer_ is available,
+and false otherwise.
+
The *tracefs_get_clock()* returns string, that must be freed with free(), or NULL
in case of an error.
diff --git a/Documentation/libtracefs.txt b/Documentation/libtracefs.txt
index 82cb574..4f016f7 100644
--- a/Documentation/libtracefs.txt
+++ b/Documentation/libtracefs.txt
@@ -112,6 +112,7 @@ Trace options:
Ftrace tracers:
char pass:[*]pass:[*]*tracefs_tracers*(const char pass:[*]_tracing_dir_);
+ bool *tracefs_tracer_available*(const char pass:[*]_tracing_dir_, const char pass:[*]_tracer_);
int *tracefs_tracer_set*(struct tracefs_instance pass:[*]_instance_, enum tracefs_tracers _tracer_);
int *tracefs_tracer_set*(struct tracefs_instance pass:[*]_instance_, enum tracefs_tracers _tracer_, const char pass:[*]_name_);
int *tracefs_tracer_clear*(struct tracefs_instance pass:[*]_instance_);
diff --git a/include/tracefs.h b/include/tracefs.h
index 693860d..ffa6842 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -77,6 +77,8 @@ void tracefs_list_free(char **list);
char **tracefs_list_add(char **list, const char *string);
int tracefs_list_size(char **list);
+bool tracefs_tracer_available(const char *tracing_dir, const char *tracer);
+
/**
* tracefs_trace_on_get_fd - Get a file descriptor of "tracing_on" in given instance
* @instance: ftrace instance, can be NULL for the top instance
diff --git a/src/tracefs-utils.c b/src/tracefs-utils.c
index 22f82af..766ed1b 100644
--- a/src/tracefs-utils.c
+++ b/src/tracefs-utils.c
@@ -514,3 +514,31 @@ int tracefs_list_size(char **list)
list--;
return (int)*(unsigned long *)list;
}
+
+/**
+ * tracefs_tracer_available - test if a tracer is available
+ * @tracing_dir: The directory that contains the tracing directory
+ * @tracer: The name of the tracer
+ *
+ * Return true if the tracer is available
+ */
+bool tracefs_tracer_available(const char *tracing_dir, const char *tracer)
+{
+ bool ret = false;
+ char **tracers = NULL;
+ int i;
+
+ tracers = tracefs_tracers(tracing_dir);
+ if (!tracers)
+ return false;
+
+ for (i = 0; tracers[i]; i++) {
+ if (strcmp(tracer, tracers[i]) == 0) {
+ ret = true;
+ break;
+ }
+ }
+
+ tracefs_list_free(tracers);
+ return ret;
+}
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 3f63837..1ab43d2 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -1404,6 +1404,9 @@ static void test_instance_tracers(struct tracefs_instance *instance)
tracers = tracefs_tracers(tdir);
CU_TEST(tracers != NULL);
+ for (i = 0; tracers[i]; i++)
+ CU_TEST(tracefs_tracer_available(tdir, tracers[i]));
+
tfile = tracefs_instance_file_read(NULL, ALL_TRACERS, NULL);
tracer = strtok(tfile, " ");
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-26 14:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-26 14:33 [PATCH 3/3] libtracefs: Add test instructions for openSUSE Alexandre Vicenzi
-- strict thread matches above, loose matches on Subject: below --
2022-08-26 14:35 Alexandre Vicenzi
2022-08-26 14:24 [PATCH 1/3] libtracefs: Add tracefs_tracer_available helper Alexandre Vicenzi
2022-08-26 14:24 ` [PATCH 3/3] libtracefs: Add test instructions for openSUSE Alexandre Vicenzi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).