summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/btrace
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2020-01-21 16:27:18 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2020-01-21 16:27:18 +0000
commitbc58c866669a43fa8818f23b451a651599675871 (patch)
tree4477f35ecd95d59fc40282ab39e65a96b52564e9 /regress/usr.sbin/btrace
parent7dc6594a1c296e2c7d3a04755cdae046f2b9b180 (diff)
Regression tests for btrace(8).
Diffstat (limited to 'regress/usr.sbin/btrace')
-rw-r--r--regress/usr.sbin/btrace/Makefile19
-rw-r--r--regress/usr.sbin/btrace/arithm.bt15
-rw-r--r--regress/usr.sbin/btrace/arithm.ok3
-rw-r--r--regress/usr.sbin/btrace/beginend.bt13
-rw-r--r--regress/usr.sbin/btrace/beginend.ok2
-rw-r--r--regress/usr.sbin/btrace/comments.bt10
-rw-r--r--regress/usr.sbin/btrace/comments.ok1
-rw-r--r--regress/usr.sbin/btrace/delete.bt12
-rw-r--r--regress/usr.sbin/btrace/exit.bt10
-rw-r--r--regress/usr.sbin/btrace/exit.ok1
-rw-r--r--regress/usr.sbin/btrace/map.bt29
-rw-r--r--regress/usr.sbin/btrace/map.ok13
-rw-r--r--regress/usr.sbin/btrace/maxoperand.bt9
-rw-r--r--regress/usr.sbin/btrace/maxoperand.ok2
-rw-r--r--regress/usr.sbin/btrace/multismts.bt5
-rw-r--r--regress/usr.sbin/btrace/multismts.ok1
-rw-r--r--regress/usr.sbin/btrace/nsecs+var.bt11
-rw-r--r--regress/usr.sbin/btrace/nsecs+var.ok1
18 files changed, 157 insertions, 0 deletions
diff --git a/regress/usr.sbin/btrace/Makefile b/regress/usr.sbin/btrace/Makefile
new file mode 100644
index 00000000000..1a301ae69f3
--- /dev/null
+++ b/regress/usr.sbin/btrace/Makefile
@@ -0,0 +1,19 @@
+# $OpenBSD: Makefile,v 1.1 2020/01/21 16:27:17 mpi Exp $
+
+BTRACE?= ${.CURDIR}/../../../usr.sbin/btrace/obj/btrace
+
+# scripts that don't need /dev/dt
+BT_LANG_SCRIPTS= arithm beginend comments delete exit map maxoperand \
+ multismts nsecs+var
+
+BT_KERN_SCRIPTS=
+
+${BT_LANG_SCRIPTS}:
+ ${BTRACE} ${.CURDIR}/${.TARGET}.bt 2>/dev/null | \
+ diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin
+
+REGRESS_TARGETS=${BT_LANG_SCRIPTS}
+.PHONY: ${REGRESS_TARGETS}
+
+.include <bsd.regress.mk>
+
diff --git a/regress/usr.sbin/btrace/arithm.bt b/regress/usr.sbin/btrace/arithm.bt
new file mode 100644
index 00000000000..552ce9082f0
--- /dev/null
+++ b/regress/usr.sbin/btrace/arithm.bt
@@ -0,0 +1,15 @@
+BEGIN
+{
+ @a = 10;
+ @b = 5;
+
+ printf("a + b = %d\n", @a + @b);
+}
+
+END
+{
+ printf("a - b = %d\n", @a - @b);
+
+ @c = @a + 2 * @b;
+ printf("c = %d, total = %d\n", @c, (@c - @b) / 5);
+}
diff --git a/regress/usr.sbin/btrace/arithm.ok b/regress/usr.sbin/btrace/arithm.ok
new file mode 100644
index 00000000000..9575561d2be
--- /dev/null
+++ b/regress/usr.sbin/btrace/arithm.ok
@@ -0,0 +1,3 @@
+a + b = 15
+a - b = 5
+c = 20, total = 3
diff --git a/regress/usr.sbin/btrace/beginend.bt b/regress/usr.sbin/btrace/beginend.bt
new file mode 100644
index 00000000000..a2469966995
--- /dev/null
+++ b/regress/usr.sbin/btrace/beginend.bt
@@ -0,0 +1,13 @@
+// Test BEGIN & END special rules as well as comments...
+// ...inside & outside action blocks
+BEGIN
+{
+
+ printf("Hello from BEGIN\n");
+}
+
+END
+{
+ // Comment inside of a block
+ printf("Bye from END\n");
+}
diff --git a/regress/usr.sbin/btrace/beginend.ok b/regress/usr.sbin/btrace/beginend.ok
new file mode 100644
index 00000000000..8d52c32c3bd
--- /dev/null
+++ b/regress/usr.sbin/btrace/beginend.ok
@@ -0,0 +1,2 @@
+Hello from BEGIN
+Bye from END
diff --git a/regress/usr.sbin/btrace/comments.bt b/regress/usr.sbin/btrace/comments.bt
new file mode 100644
index 00000000000..ab20560f673
--- /dev/null
+++ b/regress/usr.sbin/btrace/comments.bt
@@ -0,0 +1,10 @@
+/*
+ * Multi-lines comment.
+ */
+END
+// comment after probe
+{
+ printf("followed by a comment\n");
+ // comment that should be skipped (off-by one test)
+}
+/* Another comment */
diff --git a/regress/usr.sbin/btrace/comments.ok b/regress/usr.sbin/btrace/comments.ok
new file mode 100644
index 00000000000..99150de493b
--- /dev/null
+++ b/regress/usr.sbin/btrace/comments.ok
@@ -0,0 +1 @@
+followed by a comment
diff --git a/regress/usr.sbin/btrace/delete.bt b/regress/usr.sbin/btrace/delete.bt
new file mode 100644
index 00000000000..feffff2033c
--- /dev/null
+++ b/regress/usr.sbin/btrace/delete.bt
@@ -0,0 +1,12 @@
+BEGIN
+{
+ @map[3 + 1] = 9999;
+ print(@map);
+}
+
+END
+{
+ printf("=> Print after delete:\n");
+ delete(@map[4]);
+ print(@map);
+}
diff --git a/regress/usr.sbin/btrace/exit.bt b/regress/usr.sbin/btrace/exit.bt
new file mode 100644
index 00000000000..d7a980641bf
--- /dev/null
+++ b/regress/usr.sbin/btrace/exit.bt
@@ -0,0 +1,10 @@
+BEGIN
+{
+ printf("exiting now...\n");
+ exit();
+}
+
+END
+{
+ printf("not executed\n");
+}
diff --git a/regress/usr.sbin/btrace/exit.ok b/regress/usr.sbin/btrace/exit.ok
new file mode 100644
index 00000000000..9c13bebc7ef
--- /dev/null
+++ b/regress/usr.sbin/btrace/exit.ok
@@ -0,0 +1 @@
+exiting now...
diff --git a/regress/usr.sbin/btrace/map.bt b/regress/usr.sbin/btrace/map.bt
new file mode 100644
index 00000000000..2f7bd07bb38
--- /dev/null
+++ b/regress/usr.sbin/btrace/map.bt
@@ -0,0 +1,29 @@
+BEGIN
+{
+ @map[8 - 1] = count();
+ printf("=> Print with one element\n");
+ print(@map);
+
+ zero(@map);
+ printf("=> Print after zero:\n");
+ print(@map);
+
+ @map[7] = count();
+ @map[5] = 42;
+ @map[3 + 1] = 9999;
+ @map[897123] = 9997;
+ @top = 2;
+ printf("=> Print top %d:\n", @top);
+ print(@map, @top);
+}
+
+END
+{
+ @map[7] = count();
+ printf("=> Print all map:\n");
+ print(@map);
+
+ clear(@map);
+ printf("=> Print after clear:\n");
+ print(@map);
+}
diff --git a/regress/usr.sbin/btrace/map.ok b/regress/usr.sbin/btrace/map.ok
new file mode 100644
index 00000000000..35703d068ed
--- /dev/null
+++ b/regress/usr.sbin/btrace/map.ok
@@ -0,0 +1,13 @@
+=> Print with one element
+@map[7]: 1
+=> Print after zero:
+@map[7]: 0
+=> Print top 2:
+@map[4]: 9999
+@map[897123]: 9997
+=> Print all map:
+@map[4]: 9999
+@map[897123]: 9997
+@map[5]: 42
+@map[7]: 2
+=> Print after clear:
diff --git a/regress/usr.sbin/btrace/maxoperand.bt b/regress/usr.sbin/btrace/maxoperand.bt
new file mode 100644
index 00000000000..d1764b5e056
--- /dev/null
+++ b/regress/usr.sbin/btrace/maxoperand.bt
@@ -0,0 +1,9 @@
+/*
+ * Check the hard limit of operands
+ */
+BEGIN
+{
+ @ok = 1 + 2 * 3 - 4 + 5;
+ printf("That's ok: '%d'\n", @ok);
+ @notok = 6 * 5 - 4 / 3 + 2 - 1;
+}
diff --git a/regress/usr.sbin/btrace/maxoperand.ok b/regress/usr.sbin/btrace/maxoperand.ok
new file mode 100644
index 00000000000..c1a7d5ea482
--- /dev/null
+++ b/regress/usr.sbin/btrace/maxoperand.ok
@@ -0,0 +1,2 @@
+That's ok: '8'
+btrace: too many operands (>5) in expression
diff --git a/regress/usr.sbin/btrace/multismts.bt b/regress/usr.sbin/btrace/multismts.bt
new file mode 100644
index 00000000000..74eaa498676
--- /dev/null
+++ b/regress/usr.sbin/btrace/multismts.bt
@@ -0,0 +1,5 @@
+// Test multiple statements inside a single block;
+BEGIN {
+ printf("One"); printf(", %d", "2");
+ printf(" %s three%c\n", "and", "!");
+}
diff --git a/regress/usr.sbin/btrace/multismts.ok b/regress/usr.sbin/btrace/multismts.ok
new file mode 100644
index 00000000000..a23b9aa48a1
--- /dev/null
+++ b/regress/usr.sbin/btrace/multismts.ok
@@ -0,0 +1 @@
+One, 2 and three!
diff --git a/regress/usr.sbin/btrace/nsecs+var.bt b/regress/usr.sbin/btrace/nsecs+var.bt
new file mode 100644
index 00000000000..54866e4efd4
--- /dev/null
+++ b/regress/usr.sbin/btrace/nsecs+var.bt
@@ -0,0 +1,11 @@
+// Test parsing nsecs in a BEGIN block
+BEGIN {
+ @start = nsecs;
+ @var = 82;
+}
+
+// Overwrite `start' and print everything
+END {
+ @start = 3;
+ printf("start=%u, var=%u\n", @start, @var);
+}
diff --git a/regress/usr.sbin/btrace/nsecs+var.ok b/regress/usr.sbin/btrace/nsecs+var.ok
new file mode 100644
index 00000000000..6d1656a0838
--- /dev/null
+++ b/regress/usr.sbin/btrace/nsecs+var.ok
@@ -0,0 +1 @@
+start=3, var=82