[DTrace-devel] [PATCH] test: split tst.str_comparison-basic.d into with and without NULL testing

Eugene Loh eugene.loh at oracle.com
Tue Oct 11 22:43:13 UTC 2022


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
but:

1) s/fialing/failing/

2) One or both tests need copyright year update?

3)  The naming strikes me as quite odd.  I would think the "basic" name 
would be retained for the original test;  after all, that is the version 
we might expect to last into "perpetuity."  The "workaround" version 
without NULL pointers should be the new test, with some reasonable hope 
that we will retire it in the not-too-distant future.  Maybe even 
tst.str_comparison-basic-tmp.d.

On 10/11/22 17:40, Kris Van Hees via DTrace-devel wrote:
> Since NULL strings are not supported yet, the tst.str_comparison-basic.d
> test is fialing even though the non-NULL case should PASS without any
> problem.  The test is now written as two tests: one that exercises the
> case of NULL strings and one that does not.
>
> Signed-off-by: Kris Van Hees<kris.van.hees at oracle.com>
> ---
>   .../tst.str_comparison-basic-with-NULL.d      | 75 +++++++++++++++++++
>   .../operators/tst.str_comparison-basic.d      | 23 ------
>   2 files changed, 75 insertions(+), 23 deletions(-)
>   create mode 100644 test/unittest/operators/tst.str_comparison-basic-with-NULL.d
>
> diff --git a/test/unittest/operators/tst.str_comparison-basic-with-NULL.d b/test/unittest/operators/tst.str_comparison-basic-with-NULL.d
> new file mode 100644
> index 00000000..64bb0579
> --- /dev/null
> +++ b/test/unittest/operators/tst.str_comparison-basic-with-NULL.d
> @@ -0,0 +1,75 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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.
> + */
> +/* @@xfail: No support for NULL strings yet */
> +
> +/*
> + * ASSERTION: String comparisons work.
> + *
> + * SECTION:  Operators
> + */
> +
> +#pragma D option quiet
> +
> +BEGIN
> +{
> +	nerrors = 0;
> +
> +	s1 = "abcdefghi";
> +	s2 = "jklmnopqr";
> +	s3 = "stuvwxyz!";
> +
> +	nerrors += (s1 <= s2 ? 0 : 1);
> +	nerrors += (s1 <  s2 ? 0 : 1);
> +	nerrors += (s1 == s2 ? 1 : 0);
> +	nerrors += (s1 != s2 ? 0 : 1);
> +	nerrors += (s1 >= s2 ? 1 : 0);
> +	nerrors += (s1 >  s2 ? 1 : 0);
> +
> +	nerrors += (s2 <= s2 ? 0 : 1);
> +	nerrors += (s2 <  s2 ? 1 : 0);
> +	nerrors += (s2 == s2 ? 0 : 1);
> +	nerrors += (s2 != s2 ? 1 : 0);
> +	nerrors += (s2 >= s2 ? 0 : 1);
> +	nerrors += (s2 >  s2 ? 1 : 0);
> +
> +	nerrors += (s3 <= s2 ? 1 : 0);
> +	nerrors += (s3 <  s2 ? 1 : 0);
> +	nerrors += (s3 == s2 ? 1 : 0);
> +	nerrors += (s3 != s2 ? 0 : 1);
> +	nerrors += (s3 >= s2 ? 0 : 1);
> +	nerrors += (s3 >  s2 ? 0 : 1);
> +
> +	s2 = NULL;
> +	nerrors += (s3 <= s2 ? 1 : 0);
> +	nerrors += (s3 <  s2 ? 1 : 0);
> +	nerrors += (s3 == s2 ? 1 : 0);
> +	nerrors += (s3 != s2 ? 0 : 1);
> +	nerrors += (s3 >= s2 ? 0 : 0);
> +	nerrors += (s3 >  s2 ? 0 : 0);
> +
> +	nerrors += (s2 <= s3 ? 0 : 1);
> +	nerrors += (s2 <  s3 ? 0 : 1);
> +	nerrors += (s2 == s3 ? 1 : 0);
> +	nerrors += (s2 != s3 ? 0 : 1);
> +	nerrors += (s2 >= s3 ? 1 : 0);
> +	nerrors += (s2 >  s3 ? 1 : 0);
> +
> +	s3 = NULL;
> +	nerrors += (s2 <= s3 ? 0 : 1);
> +	nerrors += (s2 <  s3 ? 1 : 0);
> +	nerrors += (s2 == s3 ? 0 : 1);
> +	nerrors += (s2 != s3 ? 1 : 0);
> +	nerrors += (s2 >= s3 ? 0 : 1);
> +	nerrors += (s2 >  s3 ? 1 : 0);
> +
> +	printf("%d errors\n", nerrors);
> +	exit(nerrors == 0 ? 0 : 1);
> +}
> +ERROR
> +{
> +	exit(1);
> +}
> diff --git a/test/unittest/operators/tst.str_comparison-basic.d b/test/unittest/operators/tst.str_comparison-basic.d
> index 344a2cf0..1e13c70f 100644
> --- a/test/unittest/operators/tst.str_comparison-basic.d
> +++ b/test/unittest/operators/tst.str_comparison-basic.d
> @@ -42,29 +42,6 @@ BEGIN
>   	nerrors += (s3 >= s2 ? 0 : 1);
>   	nerrors += (s3 >  s2 ? 0 : 1);
>   
> -	s2 = NULL;
> -	nerrors += (s3 <= s2 ? 1 : 0);
> -	nerrors += (s3 <  s2 ? 1 : 0);
> -	nerrors += (s3 == s2 ? 1 : 0);
> -	nerrors += (s3 != s2 ? 0 : 1);
> -	nerrors += (s3 >= s2 ? 0 : 0);
> -	nerrors += (s3 >  s2 ? 0 : 0);
> -
> -	nerrors += (s2 <= s3 ? 0 : 1);
> -	nerrors += (s2 <  s3 ? 0 : 1);
> -	nerrors += (s2 == s3 ? 1 : 0);
> -	nerrors += (s2 != s3 ? 0 : 1);
> -	nerrors += (s2 >= s3 ? 1 : 0);
> -	nerrors += (s2 >  s3 ? 1 : 0);
> -
> -	s3 = NULL;
> -	nerrors += (s2 <= s3 ? 0 : 1);
> -	nerrors += (s2 <  s3 ? 1 : 0);
> -	nerrors += (s2 == s3 ? 0 : 1);
> -	nerrors += (s2 != s3 ? 1 : 0);
> -	nerrors += (s2 >= s3 ? 0 : 1);
> -	nerrors += (s2 >  s3 ? 1 : 0);
> -
>   	printf("%d errors\n", nerrors);
>   	exit(nerrors == 0 ? 0 : 1);
>   }
> -- 2.37.2 _______________________________________________ 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