From f64bdaeadeb8ae81d219f1a3ddd23915a06672c2 Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 7 Sep 2021 19:30:44 +0000 Subject: [PATCH] Check that clear() and zero() only work with map. --- regress/usr.sbin/btrace/Makefile | 8 +++++--- regress/usr.sbin/btrace/mapclear.bt | 9 +++++++++ regress/usr.sbin/btrace/mapclear.ok | 1 + regress/usr.sbin/btrace/mapsyntax.bt | 7 +++++++ regress/usr.sbin/btrace/mapsyntax.ok | 6 ++++++ regress/usr.sbin/btrace/mapzero.bt | 9 +++++++++ regress/usr.sbin/btrace/mapzero.ok | 1 + 7 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 regress/usr.sbin/btrace/mapclear.bt create mode 100644 regress/usr.sbin/btrace/mapclear.ok create mode 100644 regress/usr.sbin/btrace/mapsyntax.bt create mode 100644 regress/usr.sbin/btrace/mapsyntax.ok create mode 100644 regress/usr.sbin/btrace/mapzero.bt create mode 100644 regress/usr.sbin/btrace/mapzero.ok diff --git a/regress/usr.sbin/btrace/Makefile b/regress/usr.sbin/btrace/Makefile index 8fd429e24a5..6025e775a4c 100644 --- a/regress/usr.sbin/btrace/Makefile +++ b/regress/usr.sbin/btrace/Makefile @@ -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 index 00000000000..22a4b6edfee --- /dev/null +++ b/regress/usr.sbin/btrace/mapclear.bt @@ -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 index 00000000000..20c759da82d --- /dev/null +++ b/regress/usr.sbin/btrace/mapclear.ok @@ -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 index 00000000000..31073b4f394 --- /dev/null +++ b/regress/usr.sbin/btrace/mapsyntax.bt @@ -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 index 00000000000..09ce285cc32 --- /dev/null +++ b/regress/usr.sbin/btrace/mapsyntax.ok @@ -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 index 00000000000..f2f21f1d1f8 --- /dev/null +++ b/regress/usr.sbin/btrace/mapzero.bt @@ -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 index 00000000000..75615480d61 --- /dev/null +++ b/regress/usr.sbin/btrace/mapzero.ok @@ -0,0 +1 @@ +btrace: invalid variable type for zero(@notamap) -- 2.20.1