Skip to contentSkip to conversation

perf test: new testsuite: perf probe tests

PATCH In review Michael Petlan 1 participant 1 message Dec 7, 2015 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 6/9 perf test: new testsuite: perf probe tests

This commit adds tests for perf probe tool. Some of the tests are based on Masami Hiramatsu's perf-probe tests.

---
 tools/perf/testsuite/base_probe/cleanup.sh         |  22 ++
 tools/perf/testsuite/base_probe/examples/Makefile  |  13 ++
 .../perf/testsuite/base_probe/examples/advanced.c  |  40 ++++
 .../testsuite/base_probe/examples/exact_counts.c   |  35 ++++
 tools/perf/testsuite/base_probe/examples/test.c    |  35 ++++
 tools/perf/testsuite/base_probe/settings.sh        |  42 ++++
 tools/perf/testsuite/base_probe/setup.sh           |  23 +++
 .../base_probe/test_adding_blacklisted.sh          |  63 ++++++
 .../testsuite/base_probe/test_adding_kernel.sh     | 229 +++++++++++++++++++++
 tools/perf/testsuite/base_probe/test_advanced.sh   | 124 +++++++++++
 tools/perf/testsuite/base_probe/test_basic.sh      |  79 +++++++
 .../perf/testsuite/base_probe/test_exact_counts.sh | 106 ++++++++++
 .../testsuite/base_probe/test_invalid_options.sh   |  80 +++++++
 .../testsuite/base_probe/test_line_semantics.sh    |  56 +++++
 tools/perf/testsuite/base_probe/test_listing.sh    | 154 ++++++++++++++
 .../perf/testsuite/base_probe/test_probe_syntax.sh | 119 +++++++++++
 16 files changed, 1220 insertions(+)
 create mode 100755 tools/perf/testsuite/base_probe/cleanup.sh
 create mode 100644 tools/perf/testsuite/base_probe/examples/Makefile
 create mode 100644 tools/perf/testsuite/base_probe/examples/advanced.c
 create mode 100644 tools/perf/testsuite/base_probe/examples/exact_counts.c
 create mode 100644 tools/perf/testsuite/base_probe/examples/test.c
 create mode 100644 tools/perf/testsuite/base_probe/settings.sh
 create mode 100755 tools/perf/testsuite/base_probe/setup.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_adding_blacklisted.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_adding_kernel.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_advanced.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_basic.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_exact_counts.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_invalid_options.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_line_semantics.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_listing.sh
 create mode 100755 tools/perf/testsuite/base_probe/test_probe_syntax.sh
tools/perf/testsuite/base_probe/cleanup.sh new file +22 -0
new file mode 100755
index 0000000..7a7eec4
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+#
+#	cleanup.sh of perf probe test
+#	Author: Michael Petlan <[email protected]>
+#	Author: Masami Hiramatsu <[email protected]>
+#
+#
+
+# include working environment
+. ../common/init.sh
+. ./settings.sh
+
+THIS_TEST_NAME=`basename $0 .sh`
+
+clear_all_probes
+find . -name \*.log | xargs -r rm
+find . -name \*.err | xargs -r rm
+make -s -C examples clean
+
+print_results 0 0 "clean-up - removing all probes and deleting logs"
+exit $?
tools/perf/testsuite/base_probe/examples/Makefile new file +13 -0
new file mode 100644
index 0000000..0ae9638
@@ -0,0 +1,13 @@
+CC=gcc
+CFLAGS=-g -O0
+
+SRCS = $(wildcard *.c)
+PROGS = $(patsubst %.c,%,$(SRCS))
+
+all: $(PROGS)
+
+%: %.c
+	$(CC) $(CFLAGS) -o $@ $<
+
+clean:
+	rm -f $(PROGS)
tools/perf/testsuite/base_probe/examples/advanced.c new file +40 -0
new file mode 100644
index 0000000..1851e4b
@@ -0,0 +1,40 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+static int counter = 0;
+
+int incr(void)
+{
+	int a;
+	a = counter++ * 2;
+	return a;
+}
+
+int isprime(int a)
+{
+	int i;
+	if(a <= 1)
+		return 0;
+	for(i = 2; i <= a / 2; i++)
+		if(!(a % i))
+			return 0;
+	return 1;
+}
+
+int main(int argc, char **argv)
+{
+	int numbers[] = { 2, 3, 4, 5, 6, 7, 13, 17, 19 };
+	int i;
+
+	for(i = 0; i < 9; i++)
+	{
+		printf("%i %s prime\n", numbers[i], (isprime(numbers[i]))? "is" : "is not");
+	}
+
+	for(i = 0; i < 9; i++)
+	{
+		printf("Now the state is %i.\n", incr());
+	}
+
+	return 0;
+}
tools/perf/testsuite/base_probe/examples/exact_counts.c new file +35 -0
new file mode 100644
index 0000000..f5cb8fa
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int f_1x(void) { return 1; }
+int f_2x(void) { return 2; }
+int f_3x(void) { return 3; }
+int f_103x(void) { return 103; }
+int f_997x(void) { return 997; }
+int f_65535x(void) {return 65535; }
+
+int main(int argc, char **argv)
+{
+	int i, a;
+
+	for(i = 0; i < 1; i++)
+		a = f_1x();
+
+	for(i = 0; i < 2; i++)
+		a = f_2x();
+
+	for(i = 0; i < 3; i++)
+		a = f_3x();
+
+	for(i = 0; i < 103; i++)
+		a = f_103x();
+
+	for(i = 0; i < 997; i++)
+		a = f_997x();
+
+	for(i = 0; i < 65535; i++)
+		a = f_65535x();
+
+	return 0;
+}
tools/perf/testsuite/base_probe/examples/test.c new file +35 -0
new file mode 100644
index 0000000..5972f8e
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int some_function_with_a_really_long_name_that_must_be_longer_than_64_bytes(int some_argument_with_a_really_long_name_that_must_be_longer_than_64_bytes)
+{
+	int some_variable_with_a_really_long_name_that_must_be_longer_than_64_bytes = 0;
+	int i;
+
+	for(i = 0; i <= some_argument_with_a_really_long_name_that_must_be_longer_than_64_bytes; i++)
+	{
+		some_variable_with_a_really_long_name_that_must_be_longer_than_64_bytes += i;
+	}
+
+	return some_variable_with_a_really_long_name_that_must_be_longer_than_64_bytes;
+}
+
+int some_normal_function(int a)
+{
+	return a * a * a;
+}
+
+int main(int argc, char **argv)
+{
+	int x = 20, y, z;
+
+	if(argc > 1)
+		x = atoi(argv[1]);
+
+	y = some_function_with_a_really_long_name_that_must_be_longer_than_64_bytes(x);
+	z = some_normal_function(x);
+
+	printf("f1(%i) = %i\nf2(%i) = %i\n", x, y, x, z);
+
+	return 0;
+}
tools/perf/testsuite/base_probe/settings.sh new file +42 -0

42 lines not on this page · raw message

tools/perf/testsuite/base_probe/setup.sh new file +23 -0
new file mode 100755
index 0000000..8f32bc2
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+#
+#	setup.sh of perf probe test
+#	Author: Michael Petlan <[email protected]>
+#
+#	Description:
+#
+#		We need to clean-up all the previously added probes
+#		FIXME
+#
+#
+
+# include working environment
+. ../common/init.sh
+. ./settings.sh
+
+THIS_TEST_NAME=`basename $0 .sh`
+
+make -s -C examples
+
+print_results $? 0 "building examples"
+exit $?
tools/perf/testsuite/base_probe/test_adding_blacklisted.sh new file +63 -0

63 lines not on this page · raw message

tools/perf/testsuite/base_probe/test_adding_kernel.sh new file +229 -0

229 lines not on this page · raw message

tools/perf/testsuite/base_probe/test_advanced.sh new file +124 -0

124 lines not on this page · raw message

tools/perf/testsuite/base_probe/test_basic.sh new file +79 -0

79 lines not on this page · raw message

tools/perf/testsuite/base_probe/test_exact_counts.sh new file +106 -0

106 lines not on this page · raw message

tools/perf/testsuite/base_probe/test_invalid_options.sh new file +80 -0

80 lines not on this page · raw message

tools/perf/testsuite/base_probe/test_line_semantics.sh new file +56 -0

56 lines not on this page · raw message

tools/perf/testsuite/base_probe/test_listing.sh new file +154 -0

154 lines not on this page · raw message

tools/perf/testsuite/base_probe/test_probe_syntax.sh new file +119 -0

119 lines not on this page · raw message