[DTrace-devel] [PATCH 3/3] test: Add trunc tests
Kris Van Hees
kris.van.hees at oracle.com
Thu Aug 17 16:51:31 UTC 2023
On Tue, Aug 08, 2023 at 05:24:25PM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> Theoretically, funny race conditions could arise between producer
> and consumer, especially for functions like trunc(), which are
> generated in the producer but then executed in the consumer.
It is more than theoretical, but I'm not going to nitpick :)
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
> Add some trunc tests that should be robust against such races.
> They are patterned after similar clear() tests. Specifically,
> many aggregations are performed and then followed immediately by
> the trunc() call to be tested. Then, the test waits, protecting
> it from variations in update rates, before a final aggregation is
> performed and results dumped out.
Thanks for the extra tests.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
> test/unittest/aggs/tst.trunc-lquantize-5.d | 45 +++++++++++++++
> test/unittest/aggs/tst.trunc-lquantize-5.r | 55 +++++++++++++++++++
> .../aggs/tst.trunc-lquantize-default.d | 45 +++++++++++++++
> .../aggs/tst.trunc-lquantize-default.r | 10 ++++
> test/unittest/aggs/tst.trunc-lquantize-neg5.d | 45 +++++++++++++++
> test/unittest/aggs/tst.trunc-lquantize-neg5.r | 55 +++++++++++++++++++
> test/unittest/aggs/tst.trunc-sum-5.d | 39 +++++++++++++
> test/unittest/aggs/tst.trunc-sum-5.r | 7 +++
> test/unittest/aggs/tst.trunc-sum-default.d | 39 +++++++++++++
> test/unittest/aggs/tst.trunc-sum-default.r | 2 +
> test/unittest/aggs/tst.trunc-sum-neg5.d | 39 +++++++++++++
> test/unittest/aggs/tst.trunc-sum-neg5.r | 7 +++
> 12 files changed, 388 insertions(+)
> create mode 100644 test/unittest/aggs/tst.trunc-lquantize-5.d
> create mode 100644 test/unittest/aggs/tst.trunc-lquantize-5.r
> create mode 100644 test/unittest/aggs/tst.trunc-lquantize-default.d
> create mode 100644 test/unittest/aggs/tst.trunc-lquantize-default.r
> create mode 100644 test/unittest/aggs/tst.trunc-lquantize-neg5.d
> create mode 100644 test/unittest/aggs/tst.trunc-lquantize-neg5.r
> create mode 100644 test/unittest/aggs/tst.trunc-sum-5.d
> create mode 100644 test/unittest/aggs/tst.trunc-sum-5.r
> create mode 100644 test/unittest/aggs/tst.trunc-sum-default.d
> create mode 100644 test/unittest/aggs/tst.trunc-sum-default.r
> create mode 100644 test/unittest/aggs/tst.trunc-sum-neg5.d
> create mode 100644 test/unittest/aggs/tst.trunc-sum-neg5.r
>
> diff --git a/test/unittest/aggs/tst.trunc-lquantize-5.d b/test/unittest/aggs/tst.trunc-lquantize-5.d
> new file mode 100644
> index 00000000..062511f1
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-lquantize-5.d
> @@ -0,0 +1,45 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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.
> + */
> +/* @@trigger: bogus-ioctl */
> +/* @@nosort */
> +
> +#pragma D option quiet
> +
> +BEGIN
> +{
> + i = 0;
> + nsecs = 1000000000 * (long long)3;
> + tstop = timestamp + nsecs;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i < 100/
> +{
> + @[100 + i] = lquantize(i + 1, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 2, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 3, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 4, 0, 150, 1, 10000 + i);
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i == 100/
> +{
> + trunc(@, 5);
> + tstop = timestamp + nsecs;
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i > 100 && timestamp > tstop/
> +{
> + @[200 + i] = lquantize(i + 1, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 2, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 3, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 4, 0, 150, 1, 20000 + i);
> + exit(0);
> +}
> diff --git a/test/unittest/aggs/tst.trunc-lquantize-5.r b/test/unittest/aggs/tst.trunc-lquantize-5.r
> new file mode 100644
> index 00000000..7022ad96
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-lquantize-5.r
> @@ -0,0 +1,55 @@
> +
> + 195
> + value ------------- Distribution ------------- count
> + 95 | 0
> + 96 |@@@@@@@@@@ 10095
> + 97 |@@@@@@@@@@ 10095
> + 98 |@@@@@@@@@@ 10095
> + 99 |@@@@@@@@@@ 10095
> + 100 | 0
> +
> + 196
> + value ------------- Distribution ------------- count
> + 96 | 0
> + 97 |@@@@@@@@@@ 10096
> + 98 |@@@@@@@@@@ 10096
> + 99 |@@@@@@@@@@ 10096
> + 100 |@@@@@@@@@@ 10096
> + 101 | 0
> +
> + 197
> + value ------------- Distribution ------------- count
> + 97 | 0
> + 98 |@@@@@@@@@@ 10097
> + 99 |@@@@@@@@@@ 10097
> + 100 |@@@@@@@@@@ 10097
> + 101 |@@@@@@@@@@ 10097
> + 102 | 0
> +
> + 198
> + value ------------- Distribution ------------- count
> + 98 | 0
> + 99 |@@@@@@@@@@ 10098
> + 100 |@@@@@@@@@@ 10098
> + 101 |@@@@@@@@@@ 10098
> + 102 |@@@@@@@@@@ 10098
> + 103 | 0
> +
> + 199
> + value ------------- Distribution ------------- count
> + 99 | 0
> + 100 |@@@@@@@@@@ 10099
> + 101 |@@@@@@@@@@ 10099
> + 102 |@@@@@@@@@@ 10099
> + 103 |@@@@@@@@@@ 10099
> + 104 | 0
> +
> + 301
> + value ------------- Distribution ------------- count
> + 101 | 0
> + 102 |@@@@@@@@@@ 20101
> + 103 |@@@@@@@@@@ 20101
> + 104 |@@@@@@@@@@ 20101
> + 105 |@@@@@@@@@@ 20101
> + 106 | 0
> +
> diff --git a/test/unittest/aggs/tst.trunc-lquantize-default.d b/test/unittest/aggs/tst.trunc-lquantize-default.d
> new file mode 100644
> index 00000000..bca0d6e0
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-lquantize-default.d
> @@ -0,0 +1,45 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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.
> + */
> +/* @@trigger: bogus-ioctl */
> +/* @@nosort */
> +
> +#pragma D option quiet
> +
> +BEGIN
> +{
> + i = 0;
> + nsecs = 1000000000 * (long long)3;
> + tstop = timestamp + nsecs;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i < 100/
> +{
> + @[100 + i] = lquantize(i + 1, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 2, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 3, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 4, 0, 150, 1, 10000 + i);
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i == 100/
> +{
> + trunc(@);
> + tstop = timestamp + nsecs;
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i > 100 && timestamp > tstop/
> +{
> + @[200 + i] = lquantize(i + 1, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 2, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 3, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 4, 0, 150, 1, 20000 + i);
> + exit(0);
> +}
> diff --git a/test/unittest/aggs/tst.trunc-lquantize-default.r b/test/unittest/aggs/tst.trunc-lquantize-default.r
> new file mode 100644
> index 00000000..2f9e4a7f
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-lquantize-default.r
> @@ -0,0 +1,10 @@
> +
> + 301
> + value ------------- Distribution ------------- count
> + 101 | 0
> + 102 |@@@@@@@@@@ 20101
> + 103 |@@@@@@@@@@ 20101
> + 104 |@@@@@@@@@@ 20101
> + 105 |@@@@@@@@@@ 20101
> + 106 | 0
> +
> diff --git a/test/unittest/aggs/tst.trunc-lquantize-neg5.d b/test/unittest/aggs/tst.trunc-lquantize-neg5.d
> new file mode 100644
> index 00000000..97c8b7fc
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-lquantize-neg5.d
> @@ -0,0 +1,45 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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.
> + */
> +/* @@trigger: bogus-ioctl */
> +/* @@nosort */
> +
> +#pragma D option quiet
> +
> +BEGIN
> +{
> + i = 0;
> + nsecs = 1000000000 * (long long)3;
> + tstop = timestamp + nsecs;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i < 100/
> +{
> + @[100 + i] = lquantize(i + 1, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 2, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 3, 0, 150, 1, 10000 + i);
> + @[100 + i] = lquantize(i + 4, 0, 150, 1, 10000 + i);
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i == 100/
> +{
> + trunc(@, -5);
> + tstop = timestamp + nsecs;
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i > 100 && timestamp > tstop/
> +{
> + @[200 + i] = lquantize(i + 1, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 2, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 3, 0, 150, 1, 20000 + i);
> + @[200 + i] = lquantize(i + 4, 0, 150, 1, 20000 + i);
> + exit(0);
> +}
> diff --git a/test/unittest/aggs/tst.trunc-lquantize-neg5.r b/test/unittest/aggs/tst.trunc-lquantize-neg5.r
> new file mode 100644
> index 00000000..5af13f50
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-lquantize-neg5.r
> @@ -0,0 +1,55 @@
> +
> + 100
> + value ------------- Distribution ------------- count
> + 0 | 0
> + 1 |@@@@@@@@@@ 10000
> + 2 |@@@@@@@@@@ 10000
> + 3 |@@@@@@@@@@ 10000
> + 4 |@@@@@@@@@@ 10000
> + 5 | 0
> +
> + 101
> + value ------------- Distribution ------------- count
> + 1 | 0
> + 2 |@@@@@@@@@@ 10001
> + 3 |@@@@@@@@@@ 10001
> + 4 |@@@@@@@@@@ 10001
> + 5 |@@@@@@@@@@ 10001
> + 6 | 0
> +
> + 102
> + value ------------- Distribution ------------- count
> + 2 | 0
> + 3 |@@@@@@@@@@ 10002
> + 4 |@@@@@@@@@@ 10002
> + 5 |@@@@@@@@@@ 10002
> + 6 |@@@@@@@@@@ 10002
> + 7 | 0
> +
> + 103
> + value ------------- Distribution ------------- count
> + 3 | 0
> + 4 |@@@@@@@@@@ 10003
> + 5 |@@@@@@@@@@ 10003
> + 6 |@@@@@@@@@@ 10003
> + 7 |@@@@@@@@@@ 10003
> + 8 | 0
> +
> + 104
> + value ------------- Distribution ------------- count
> + 4 | 0
> + 5 |@@@@@@@@@@ 10004
> + 6 |@@@@@@@@@@ 10004
> + 7 |@@@@@@@@@@ 10004
> + 8 |@@@@@@@@@@ 10004
> + 9 | 0
> +
> + 301
> + value ------------- Distribution ------------- count
> + 101 | 0
> + 102 |@@@@@@@@@@ 20101
> + 103 |@@@@@@@@@@ 20101
> + 104 |@@@@@@@@@@ 20101
> + 105 |@@@@@@@@@@ 20101
> + 106 | 0
> +
> diff --git a/test/unittest/aggs/tst.trunc-sum-5.d b/test/unittest/aggs/tst.trunc-sum-5.d
> new file mode 100644
> index 00000000..47e3479b
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-sum-5.d
> @@ -0,0 +1,39 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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.
> + */
> +/* @@trigger: bogus-ioctl */
> +/* @@nosort */
> +
> +#pragma D option quiet
> +
> +BEGIN
> +{
> + i = 0;
> + nsecs = 1000000000 * (long long)3;
> + tstop = timestamp + nsecs;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i < 100/
> +{
> + @[100 + i] = sum(1000 + i);
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i == 100/
> +{
> + trunc(@, 5);
> + tstop = timestamp + nsecs;
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i > 100 && timestamp > tstop/
> +{
> + @[200 + i] = sum(2000 + i);
> + exit(0);
> +}
> diff --git a/test/unittest/aggs/tst.trunc-sum-5.r b/test/unittest/aggs/tst.trunc-sum-5.r
> new file mode 100644
> index 00000000..f0b172f6
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-sum-5.r
> @@ -0,0 +1,7 @@
> +
> + 195 1095
> + 196 1096
> + 197 1097
> + 198 1098
> + 199 1099
> + 301 2101
> diff --git a/test/unittest/aggs/tst.trunc-sum-default.d b/test/unittest/aggs/tst.trunc-sum-default.d
> new file mode 100644
> index 00000000..c08ba4c2
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-sum-default.d
> @@ -0,0 +1,39 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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.
> + */
> +/* @@trigger: bogus-ioctl */
> +/* @@nosort */
> +
> +#pragma D option quiet
> +
> +BEGIN
> +{
> + i = 0;
> + nsecs = 1000000000 * (long long)3;
> + tstop = timestamp + nsecs;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i < 100/
> +{
> + @[100 + i] = sum(1000 + i);
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i == 100/
> +{
> + trunc(@);
> + tstop = timestamp + nsecs;
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i > 100 && timestamp > tstop/
> +{
> + @[200 + i] = sum(2000 + i);
> + exit(0);
> +}
> diff --git a/test/unittest/aggs/tst.trunc-sum-default.r b/test/unittest/aggs/tst.trunc-sum-default.r
> new file mode 100644
> index 00000000..32e489f0
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-sum-default.r
> @@ -0,0 +1,2 @@
> +
> + 301 2101
> diff --git a/test/unittest/aggs/tst.trunc-sum-neg5.d b/test/unittest/aggs/tst.trunc-sum-neg5.d
> new file mode 100644
> index 00000000..c6cf99dd
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-sum-neg5.d
> @@ -0,0 +1,39 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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.
> + */
> +/* @@trigger: bogus-ioctl */
> +/* @@nosort */
> +
> +#pragma D option quiet
> +
> +BEGIN
> +{
> + i = 0;
> + nsecs = 1000000000 * (long long)3;
> + tstop = timestamp + nsecs;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i < 100/
> +{
> + @[100 + i] = sum(1000 + i);
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i == 100/
> +{
> + trunc(@, -5);
> + tstop = timestamp + nsecs;
> + i++;
> +}
> +
> +syscall::ioctl:entry
> +/pid == $target && i > 100 && timestamp > tstop/
> +{
> + @[200 + i] = sum(2000 + i);
> + exit(0);
> +}
> diff --git a/test/unittest/aggs/tst.trunc-sum-neg5.r b/test/unittest/aggs/tst.trunc-sum-neg5.r
> new file mode 100644
> index 00000000..3e49d909
> --- /dev/null
> +++ b/test/unittest/aggs/tst.trunc-sum-neg5.r
> @@ -0,0 +1,7 @@
> +
> + 100 1000
> + 101 1001
> + 102 1002
> + 103 1003
> + 104 1004
> + 301 2101
> --
> 2.31.1
>
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list