[DTrace-devel] [PATCH 15/22] test: Clean up the specsize tests
Kris Van Hees
kris.van.hees at oracle.com
Sat Sep 14 17:57:15 UTC 2024
On Thu, Aug 29, 2024 at 01:22:12AM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> The tests had actions like
> printf("%lld: Lots of data\n", x);
> printf("%lld: Has to be crammed into this buffer\n", x);
> printf("%lld: Until it overflows\n", x);
> printf("%lld: And causes flops\n", x);
> suggesting that these strings were crowding the buffer, but these
> strings are not passed from producer to consumer at all.
>
> The tests also only tested one clause per speculation. It would be
> nice also to test multiple clauses per speculation.
>
> There is much replicated code from one of the tests to the other, a
> shortcoming that is amplified if we want to test more specsize values,
> which is the case when we test multiple clauses per speculation.
>
> Therefore, replace the multiple tests with a single test that checks
> multiple clauses per speculation and more values of specsize.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
> .../speculation/tst.SpecSizeVariations.r | 68 +++++++++++++++++
> .../speculation/tst.SpecSizeVariations.sh | 74 +++++++++++++++++++
> .../speculation/tst.SpecSizeVariations4.d | 66 -----------------
> .../speculation/tst.SpecSizeVariations4.r | 5 --
> .../speculation/tst.SpecSizeVariations5.d | 61 ---------------
> .../speculation/tst.SpecSizeVariations5.r | 7 --
> 6 files changed, 142 insertions(+), 139 deletions(-)
> create mode 100644 test/unittest/speculation/tst.SpecSizeVariations.r
> create mode 100755 test/unittest/speculation/tst.SpecSizeVariations.sh
> delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations4.d
> delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations4.r
> delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations5.d
> delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations5.r
>
> diff --git a/test/unittest/speculation/tst.SpecSizeVariations.r b/test/unittest/speculation/tst.SpecSizeVariations.r
> new file mode 100644
> index 00000000..51f0596c
> --- /dev/null
> +++ b/test/unittest/speculation/tst.SpecSizeVariations.r
> @@ -0,0 +1,68 @@
> +Speculative buffer ID: 1
> +counts: 0 1
> +
> +Speculative buffer ID: 1
> +123456700
> +123456701
> +123456702
> +123456703
> +123456704
> +123456705
> +123456706
> +counts: 1 1
> +
> +Speculative buffer ID: 1
> +123456700
> +123456701
> +123456702
> +123456703
> +123456704
> +123456705
> +123456706
> +counts: 1 1
> +
> +Speculative buffer ID: 1
> +123456700
> +123456701
> +123456702
> +123456703
> +123456704
> +123456705
> +123456706
> +counts: 2 1
> +
> +Speculative buffer ID: 1
> +123456700
> +123456701
> +123456702
> +123456703
> +123456704
> +123456705
> +123456706
> +counts: 2 1
> +
> +Speculative buffer ID: 1
> +123456700
> +123456701
> +123456702
> +123456703
> +123456704
> +123456705
> +123456706
> +123456800
> +123456801
> +123456802
> +123456803
> +123456804
> +123456805
> +123456806
> +123456807
> +123456808
> +counts: 2 1
> +
> +-- @@stderr --
> +dtrace: 2 speculative drops
> +dtrace: 1 speculative drop
> +dtrace: 1 speculative drop
> +dtrace: 1 speculative drop
> +dtrace: 1 speculative drop
> diff --git a/test/unittest/speculation/tst.SpecSizeVariations.sh b/test/unittest/speculation/tst.SpecSizeVariations.sh
> new file mode 100755
> index 00000000..75e527d9
> --- /dev/null
> +++ b/test/unittest/speculation/tst.SpecSizeVariations.sh
> @@ -0,0 +1,74 @@
> +#!/bin/bash
> +
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +#
> +
> +dtrace=$1
> +
> +for x in 63 64 79 80 143 144; do
> + $dtrace $dt_flags -xspecsize=$x -qn '
> + BEGIN
> + {
> + x = 123456700ll;
> + self->nspeculate = 0;
> + self->ncommit = 0;
> + self->spec = speculation();
> + printf("Speculative buffer ID: %d\n", self->spec);
> + }
> +
> + /* 16 + 7 * 8 = 72 bytes */
> + BEGIN
> + {
> + speculate(self->spec);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + self->nspeculate++;
> + }
> +
> + BEGIN
> + {
> + x = 123456800ll;
> + }
> +
> + /* 16 + 9 * 8 = 88 bytes */
> + BEGIN
> + {
> + speculate(self->spec);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + printf("%lld\n", x++);
> + self->nspeculate++;
> + }
> +
> + BEGIN
> + {
> + commit(self->spec);
> + self->ncommit++;
> + }
> +
> + BEGIN
> + {
> + printf("counts: %d %d\n", self->nspeculate, self->ncommit);
> + exit(0);
> + }
> +
> + ERROR
> + {
> + exit(1);
> + }'
> +done
> diff --git a/test/unittest/speculation/tst.SpecSizeVariations4.d b/test/unittest/speculation/tst.SpecSizeVariations4.d
> deleted file mode 100644
> index 4221c89e..00000000
> --- a/test/unittest/speculation/tst.SpecSizeVariations4.d
> +++ /dev/null
> @@ -1,66 +0,0 @@
> -/*
> - * Oracle Linux DTrace.
> - * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved.
> - * Licensed under the Universal Permissive License v 1.0 as shown at
> - * http://oss.oracle.com/licenses/upl.
> - */
> -
> -/*
> - * ASSERTION:
> - * Verify the behavior of speculations with changes in specsize.
> - *
> - * SECTION: Speculative Tracing/Options and Tuning;
> - * Options and Tunables/specsize
> - *
> - */
> -
> -#pragma D option quiet
> -#pragma D option specsize=39
> -
> -long long x;
> -
> -BEGIN
> -{
> - x = 123456789;
> - self->speculateFlag = 0;
> - self->commitFlag = 0;
> - self->spec = speculation();
> - printf("Speculative buffer ID: %d\n", self->spec);
> -}
> -
> -BEGIN
> -{
> - speculate(self->spec);
> - printf("%lld: Lots of data\n", x);
> - printf("%lld: Has to be crammed into this buffer\n", x);
> - printf("%lld: Until it overflows\n", x);
> - printf("%lld: And causes flops\n", x);
> - self->speculateFlag++;
> -
> -}
> -
> -BEGIN
> -/1 <= self->speculateFlag/
> -{
> - commit(self->spec);
> - self->commitFlag++;
> -}
> -
> -BEGIN
> -/1 <= self->commitFlag/
> -{
> - printf("Statement was executed\n");
> - exit(1);
> -}
> -
> -BEGIN
> -/1 > self->commitFlag/
> -{
> - printf("Statement wasn't executed\n");
> - exit(0);
> -}
> -
> -ERROR
> -{
> - exit(1);
> -}
> diff --git a/test/unittest/speculation/tst.SpecSizeVariations4.r b/test/unittest/speculation/tst.SpecSizeVariations4.r
> deleted file mode 100644
> index 7c4bb3b7..00000000
> --- a/test/unittest/speculation/tst.SpecSizeVariations4.r
> +++ /dev/null
> @@ -1,5 +0,0 @@
> -Speculative buffer ID: 1
> -Statement wasn't executed
> -
> --- @@stderr --
> -dtrace: 1 speculative drop
> diff --git a/test/unittest/speculation/tst.SpecSizeVariations5.d b/test/unittest/speculation/tst.SpecSizeVariations5.d
> deleted file mode 100644
> index fb71dfed..00000000
> --- a/test/unittest/speculation/tst.SpecSizeVariations5.d
> +++ /dev/null
> @@ -1,61 +0,0 @@
> -/*
> - * Oracle Linux DTrace.
> - * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
> - * Licensed under the Universal Permissive License v 1.0 as shown at
> - * http://oss.oracle.com/licenses/upl.
> - */
> -
> -/*
> - * ASSERTION:
> - * Verify the behavior of speculations with changes in specsize.
> - *
> - * SECTION: Speculative Tracing/Options and Tuning;
> - * Options and Tunables/specsize
> - *
> - */
> -
> -#pragma D option quiet
> -#pragma D option specsize=40
> -
> -long long x;
> -
> -BEGIN
> -{
> - x = 123456789;
> - self->speculateFlag = 0;
> - self->commitFlag = 0;
> - self->spec = speculation();
> - printf("Speculative buffer ID: %d\n", self->spec);
> -}
> -
> -BEGIN
> -{
> - speculate(self->spec);
> - printf("%lld: Lots of data\n", x);
> - printf("%lld: Has to be crammed into this buffer\n", x);
> - printf("%lld: Until it overflows\n", x);
> - printf("%lld: And causes flops\n", x);
> - self->speculateFlag++;
> -
> -}
> -
> -BEGIN
> -/1 <= self->speculateFlag/
> -{
> - commit(self->spec);
> - self->commitFlag++;
> -}
> -
> -BEGIN
> -/1 <= self->commitFlag/
> -{
> - printf("Statement was executed\n");
> - exit(0);
> -}
> -
> -BEGIN
> -/1 > self->commitFlag/
> -{
> - printf("Statement wasn't executed\n");
> - exit(1);
> -}
> diff --git a/test/unittest/speculation/tst.SpecSizeVariations5.r b/test/unittest/speculation/tst.SpecSizeVariations5.r
> deleted file mode 100644
> index d09013a2..00000000
> --- a/test/unittest/speculation/tst.SpecSizeVariations5.r
> +++ /dev/null
> @@ -1,7 +0,0 @@
> -Speculative buffer ID: 1
> -123456789: Lots of data
> -123456789: Has to be crammed into this buffer
> -123456789: Until it overflows
> -123456789: And causes flops
> -Statement was executed
> -
> --
> 2.43.5
>
More information about the DTrace-devel
mailing list