Check that clear() and zero() only work with map.
authormpi <mpi@openbsd.org>
Tue, 7 Sep 2021 19:30:44 +0000 (19:30 +0000)
committermpi <mpi@openbsd.org>
Tue, 7 Sep 2021 19:30:44 +0000 (19:30 +0000)
regress/usr.sbin/btrace/Makefile
regress/usr.sbin/btrace/mapclear.bt [new file with mode: 0644]
regress/usr.sbin/btrace/mapclear.ok [new file with mode: 0644]
regress/usr.sbin/btrace/mapsyntax.bt [new file with mode: 0644]
regress/usr.sbin/btrace/mapsyntax.ok [new file with mode: 0644]
regress/usr.sbin/btrace/mapzero.bt [new file with mode: 0644]
regress/usr.sbin/btrace/mapzero.ok [new file with mode: 0644]

index 8fd429e..6025e77 100644 (file)
@@ -1,12 +1,14 @@
-# $OpenBSD: Makefile,v 1.13 2021/09/07 19:20:22 mpi Exp $
+# $OpenBSD: Makefile,v 1.14 2021/09/07 19:30:44 mpi Exp $
 
 BTRACE?=                /usr/sbin/btrace
 
 # scripts that don't need /dev/dt
-BT_LANG_SCRIPTS=       arithm beginend boolean comments delete exit if map \
-                       map-unnamed maxoperand min+max+sum multismts nsecs+var \
+BT_LANG_SCRIPTS=       arithm beginend boolean comments delete exit if \
+                       map mapclear mapsyntax mmapzero ap-unnamed \
+                       maxoperand min+max+sum multismts nsecs+var \
                        precedence print read-map-after-clear syntaxerror
 
+
 BT_KERN_SCRIPTS=
 
 REGRESS_EXPECTED_FAILURES=     run-maxoperand
diff --git a/regress/usr.sbin/btrace/mapclear.bt b/regress/usr.sbin/btrace/mapclear.bt
new file mode 100644 (file)
index 0000000..22a4b6e
--- /dev/null
@@ -0,0 +1,9 @@
+BEGIN {
+       @notamap = 123;
+
+       /*
+        * Parser doesn't know the type of a variable and these check
+        * are performed at run-time.
+        */
+       clear(@notamap);
+}
diff --git a/regress/usr.sbin/btrace/mapclear.ok b/regress/usr.sbin/btrace/mapclear.ok
new file mode 100644 (file)
index 0000000..20c759d
--- /dev/null
@@ -0,0 +1 @@
+btrace: invalid variable type for clear(@notamap)
diff --git a/regress/usr.sbin/btrace/mapsyntax.bt b/regress/usr.sbin/btrace/mapsyntax.bt
new file mode 100644 (file)
index 0000000..31073b4
--- /dev/null
@@ -0,0 +1,7 @@
+BEGIN {
+       zero(42);
+}
+
+END {
+       clear(0);
+}
diff --git a/regress/usr.sbin/btrace/mapsyntax.ok b/regress/usr.sbin/btrace/mapsyntax.ok
new file mode 100644 (file)
index 0000000..09ce285
--- /dev/null
@@ -0,0 +1,6 @@
+/usr/src/regress/usr.sbin/btrace/mapsyntax.bt:2:8: syntax error:
+       zero(42);
+              ^
+/usr/src/regress/usr.sbin/btrace/mapsyntax.bt:6:8: syntax error:
+       clear(0);
+              ^
diff --git a/regress/usr.sbin/btrace/mapzero.bt b/regress/usr.sbin/btrace/mapzero.bt
new file mode 100644 (file)
index 0000000..f2f21f1
--- /dev/null
@@ -0,0 +1,9 @@
+BEGIN {
+       @notamap = "bob";
+
+       /*
+        * Parser doesn't know the type of a variable and these check
+        * are performed at run-time.
+        */
+       zero(@notamap);
+}
diff --git a/regress/usr.sbin/btrace/mapzero.ok b/regress/usr.sbin/btrace/mapzero.ok
new file mode 100644 (file)
index 0000000..7561548
--- /dev/null
@@ -0,0 +1 @@
+btrace: invalid variable type for zero(@notamap)