Skip to contentSkip to conversation

Tests: Add a test for invalid filters

PATCH New Christian Babeux 1 participant 4 messages Oct 16, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/5 Tests: Add a test for invalid filters

This test validate that an invalid filter (unmatched parenthesis, field dereferences, unsupported ops, etc.) are correctly flagged as such.

---
 tests/tools/filtering/Makefile.am     |   4 +-
 tests/tools/filtering/invalid-filters | 135 ++++++++++++++++++++++++++++++++++
 2 files changed, 137 insertions(+), 2 deletions(-)
 create mode 100755 tests/tools/filtering/invalid-filters
tests/tools/filtering/Makefile.am +2 -2
index 62f7099..5f3423a 100644
@@ -1,2 +1,2 @@
-noinst_SCRIPTS = unsupported-ops
-EXTRA_DIST = unsupported-ops
+noinst_SCRIPTS = unsupported-ops invalid-filters
+EXTRA_DIST = unsupported-ops invalid-filters
tests/tools/filtering/invalid-filters new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
1.7.12.2
#2 lore raw

PATCH 3/5 Tests: Add a trace statistics utility

In reply to a message not in the archive

The babelstats script output statistics on fields values for a particular tracepoint. At the moment, the script only show minimum and maximum value for each fields of a particular tracepoint.

The trace must be in the babeltrace text format. It can be passed via stdin.

The script output this format:
field_name min max

Sample usage:

Quoted 1 line

babeltrace sometracedir | babelstats.pl --tracepoint tp:tptest

_seqfield1_length 4 4
seqfield2 "test" "test"
stringfield2 "\*" "\*"
floatfield 2222 2222
netintfieldhex 0x0 0x63
_seqfield2_length 4 4
longfield 0 99
netintfield 0 99
intfield2 0x0 0x63
intfield 0 99
stringfield "test" "test"
doublefield 2 2
arrfield2 "test" "test"

Use case:
This script could be useful to validate that fields values are within some predefined expected ranges.

---
 tests/tools/filtering/Makefile.am   |   4 +-
 tests/tools/filtering/babelstats.pl | 174 ++++++++++++++++++++++++++++++++++++
 2 files changed, 176 insertions(+), 2 deletions(-)
 create mode 100755 tests/tools/filtering/babelstats.pl
tests/tools/filtering/Makefile.am +2 -2
index 5f3423a..df99e27 100644
@@ -1,2 +1,2 @@
-noinst_SCRIPTS = unsupported-ops invalid-filters
-EXTRA_DIST = unsupported-ops invalid-filters
+noinst_SCRIPTS = unsupported-ops invalid-filters babelstats.pl
+EXTRA_DIST = unsupported-ops invalid-filters babelstats.pl
tests/tools/filtering/babelstats.pl new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
1.7.12.2
#3 lore raw

PATCH 4/5 Tests: Add a test for valid filters

In reply to a message not in the archive

This test validate that for a given filter the expected trace output is conform to the expected filter behavior.

This test rely on the babelstats utility. With the help of this script, we can verify that the expected minimum and maximum values on fields of interest are within the expected ranges.

For example, given 100 iterations on a tracepoint with the field 'intfield', with values starting from 0 and incrementing on each iteration, and the filter expression 'intfield < 4', we would expect that the min-max range lie within [0,3].

Thus, if the babelstat computed range does not match the expected range, this could potentially indicate failure in the filtering mechanism.

---
 tests/tools/filtering/Makefile.am      |  20 +-
 tests/tools/filtering/gen-ust-events.c |  59 +++++
 tests/tools/filtering/tp.c             |  15 ++
 tests/tools/filtering/tp.h             |  57 +++++
 tests/tools/filtering/valid-filters    | 411 +++++++++++++++++++++++++++++++++
 5 files changed, 560 insertions(+), 2 deletions(-)
 create mode 100644 tests/tools/filtering/gen-ust-events.c
 create mode 100644 tests/tools/filtering/tp.c
 create mode 100644 tests/tools/filtering/tp.h
 create mode 100755 tests/tools/filtering/valid-filters
tests/tools/filtering/Makefile.am +18 -2
index df99e27..a3bf866 100644
@@ -1,2 +1,18 @@
-noinst_SCRIPTS = unsupported-ops invalid-filters babelstats.pl
-EXTRA_DIST = unsupported-ops invalid-filters babelstats.pl
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests -I$(srcdir) -O2 -g
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+if HAVE_LIBLTTNG_UST_CTL
+noinst_PROGRAMS = gen-ust-events
+gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
+gen_ust_events_LDADD = -llttng-ust
+endif
+
+noinst_SCRIPTS = unsupported-ops invalid-filters valid-filters babelstats.pl
+EXTRA_DIST = unsupported-ops invalid-filters valid-filters babelstats.pl
tests/tools/filtering/gen-ust-events.c new file +59 -0

59 lines not on this page · raw message

tests/tools/filtering/tp.c new file +15 -0
new file mode 100644
index 0000000..a09561d
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) - 2012 David Goulet <[email protected]>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
+ * IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any purpose,
+ * provided the above notices are retained on all copies.  Permission to modify
+ * the code and to distribute modified code is granted, provided the above
+ * notices are retained, and a notice that the code was modified is included
+ * with the above copyright notice.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "tp.h"
tests/tools/filtering/tp.h new file +57 -0

57 lines not on this page · raw message

tests/tools/filtering/valid-filters new file +411 -0

411 lines not on this page · raw message

Signature · 1 line
1.7.12.2
#4 lore raw

PATCH 5/5 Tests: Add filtering tests to configure

In reply to a message not in the archive

Add filtering folder to top-level Makefile.am. Also add a runall script to run all filtering tests.

---
 configure.ac                      |  1 +
 tests/tools/Makefile.am           |  2 +-
 tests/tools/filtering/Makefile.am |  4 ++--
 tests/tools/filtering/runall      | 28 ++++++++++++++++++++++++++++
 tests/tools/runall.sh             |  2 +-
 5 files changed, 33 insertions(+), 4 deletions(-)
 create mode 100755 tests/tools/filtering/runall
configure.ac +1 -0
index cb5dc38..fbaae6f 100644
@@ -288,6 +288,7 @@ AC_CONFIG_FILES([
 	tests/kernel/Makefile
 	tests/tools/Makefile
 	tests/tools/streaming/Makefile
+	tests/tools/filtering/Makefile
 	tests/tools/health/Makefile
 	tests/ust/Makefile
 	tests/ust/nprocesses/Makefile
tests/tools/Makefile.am +1 -1
index 173dce2..56eda3a 100644
@@ -1,4 +1,4 @@
-SUBDIRS = streaming health
+SUBDIRS = streaming filtering health
 
 AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests -g -Wall
 AM_LDFLAGS = -lurcu -lurcu-cds
tests/tools/filtering/Makefile.am +2 -2
index a3bf866..e1e715d 100644
@@ -14,5 +14,5 @@ gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h
 gen_ust_events_LDADD = -llttng-ust
 endif
 
-noinst_SCRIPTS = unsupported-ops invalid-filters valid-filters babelstats.pl
-EXTRA_DIST = unsupported-ops invalid-filters valid-filters babelstats.pl
+noinst_SCRIPTS = runall unsupported-ops invalid-filters valid-filters babelstats.pl
+EXTRA_DIST = runall unsupported-ops invalid-filters valid-filters babelstats.pl
tests/tools/filtering/runall new file +28 -0
new file mode 100755
index 0000000..c92e399
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+DIR=$(dirname $0)
+
+tests=( $DIR/unsupported-ops $DIR/invalid-filters $DIR/valid-filters )
+exit_code=0
+
+function start_tests ()
+{
+	for bin in ${tests[@]};
+	do
+		if [ ! -e $bin ]; then
+			echo -e "$bin not found, passing"
+			continue
+		fi
+
+		./$bin
+		# Test must return 0 to pass.
+		if [ $? -ne 0 ]; then
+			exit_code=1
+			break
+		fi
+	done
+}
+
+start_tests
+
+exit $exit_code
tests/tools/runall.sh +1 -1
index 0ad7cf1..b2be91c 100755
@@ -3,7 +3,7 @@
 DIR=$(dirname $0)
 
 tests=( $DIR/test_kernel_data_trace $DIR/test_sessions $DIR/test_ust_data_trace \
-		$DIR/streaming/runall $DIR/health/runall )
+		$DIR/streaming/runall $DIR/health/runall $DIR/filtering/runall)
 
 exit_code=0
 
Signature · 1 line
1.7.12.2