Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Lancelot SIX <lsix@lancelotsix.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 13/29] gdb/testsuite: Remove duplicates from gdb.base/dfp-exprs.exp
Date: Fri, 10 Dec 2021 23:03:57 +0000	[thread overview]
Message-ID: <0e6cef60-84ed-011b-8113-bc4bac1cce0e@palves.net> (raw)
In-Reply-To: <20211121175636.779325-14-lsix@lancelotsix.com>

On 2021-11-21 17:56, Lancelot SIX via Gdb-patches wrote:
> When I run the testsuite, I have:
> 
>     Running ../gdb/testsuite/gdb.base/dfp-exprs.exp ...
>     DUPLICATE: gdb.base/dfp-exprs.exp: p 1.2dl < 1.3df
> 
> Fix by removing the duplicated test.
> 
> Tested on x86_64-linux.
> ---
>  gdb/testsuite/gdb.base/dfp-exprs.exp | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.base/dfp-exprs.exp b/gdb/testsuite/gdb.base/dfp-exprs.exp
> index 355b8f04a1f..cce743d3ffe 100644
> --- a/gdb/testsuite/gdb.base/dfp-exprs.exp
> +++ b/gdb/testsuite/gdb.base/dfp-exprs.exp
> @@ -154,7 +154,6 @@ proc test_dfp_arithmetic_expressions {} {
>      gdb_test "p 1.2dd < 1.3dd" " = 1"
>      gdb_test "p 1.2dd < 1.3dl" " = 1"
>      gdb_test "p 1.2dl < 1.3dl" " = 1"
> -    gdb_test "p 1.2dl < 1.3df" " = 1"

Hmm, it's not super obvious to me what the intention was here.  For one, I can't spot a pattern in
the sequence here.  Am I missing it?  

If we alpha sort the lines (sort-lines in emacs), and then add the missing combinations, we end up with:

    # Keep the list alpha sorted.
    gdb_test "p 1.2dd < 1.3dd" " = 1"
    gdb_test "p 1.2dd < 1.3df" " = 1"
    gdb_test "p 1.2dd < 1.3dl" " = 1"
    gdb_test "p 1.2df < 1.3dd" " = 1"
    gdb_test "p 1.2df < 1.3df" " = 1"
    gdb_test "p 1.2df < 1.3dl" " = 1"
    gdb_test "p 1.2dl < 1.3dd" " = 1"
    gdb_test "p 1.2dl < 1.3df" " = 1"
    gdb_test "p 1.2dl < 1.3dl" " = 1"

But then, the == tests are also missing some combinations.  I think that if we do this
programmatically with a for loop, we can exercise all the combinations in much clearer code,
removing the need to eyeball for all suffixes.  See patch below.

I've also added a lot more combinations, testing all comparison operators comprehensively.

The result is 262 unique tests vs 104 today.

Let me know what you think.

>      gdb_test "p 1.2df > 1" " = 1"
>      gdb_test "p 1.2dl > 2" " = 0"
>      gdb_test "p 2 > 1.2dd" " = 1"
> 

From fe8eed9a83b6c5608bc3b7d496a438628e7fc3a5 Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Fri, 10 Dec 2021 22:41:54 +0000
Subject: [PATCH] Programmatic

Change-Id: Id215a3d610aa8e032bf06ee160b5e3aed4a92d1e
---
 gdb/testsuite/gdb.base/dfp-exprs.exp | 94 +++++++++++++++++-----------
 1 file changed, 57 insertions(+), 37 deletions(-)

diff --git a/gdb/testsuite/gdb.base/dfp-exprs.exp b/gdb/testsuite/gdb.base/dfp-exprs.exp
index 355b8f04a1f..e735e6df6d8 100644
--- a/gdb/testsuite/gdb.base/dfp-exprs.exp
+++ b/gdb/testsuite/gdb.base/dfp-exprs.exp
@@ -122,43 +122,63 @@ proc test_dfp_arithmetic_expressions {} {
     gdb_test "p 1.2df + 1.2f" "Mixing decimal floating types with other floating types is not allowed."
 
     # Test other operations with DFP operands
-    gdb_test "p !0.df" " = 1"
-    gdb_test "p !0.dd" " = 1"
-    gdb_test "p !0.dl" " = 1"
-    gdb_test "p !0.5df" " = 0"
-    gdb_test "p !0.5dd" " = 0"
-    gdb_test "p !0.5dl" " = 0"
-
-    gdb_test "p 1.2df == 1.2df" " = 1"
-    gdb_test "p 1.2df == 1.2dd" " = 1"
-    gdb_test "p 1.2df == 1.2dl" " = 1"
-    gdb_test "p 1.2dd == 1.2df" " = 1"
-    gdb_test "p 1.2dd == 1.2dl" " = 1"
-    gdb_test "p 1.2dl == 1.2df" " = 1"
-    gdb_test "p 1.2dl == 1.2dd" " = 1"
-    gdb_test "p 1.2df == 1.3df" " = 0"
-    gdb_test "p 1.2df == 1.3dd" " = 0"
-    gdb_test "p 1.2df == 1.3dl" " = 0"
-    gdb_test "p 1.2dd == 1.3df" " = 0"
-    gdb_test "p 1.2dd == 1.3dl" " = 0"
-    gdb_test "p 1.2dl == 1.3df" " = 0"
-    gdb_test "p 1.2dl == 1.3dd" " = 0"
-
-    gdb_test "p +1.2df" " = 1.2"
-    gdb_test "p +1.2dd" " = 1.2"
-    gdb_test "p +1.2dl" " = 1.2"
-
-    gdb_test "p 1.2df < 1.3df" " = 1"
-    gdb_test "p 1.2df < 1.3dd" " = 1"
-    gdb_test "p 1.2dl < 1.3df" " = 1"
-    gdb_test "p 1.2dd < 1.3dd" " = 1"
-    gdb_test "p 1.2dd < 1.3dl" " = 1"
-    gdb_test "p 1.2dl < 1.3dl" " = 1"
-    gdb_test "p 1.2dl < 1.3df" " = 1"
-    gdb_test "p 1.2df > 1" " = 1"
-    gdb_test "p 1.2dl > 2" " = 0"
-    gdb_test "p 2 > 1.2dd" " = 1"
-    gdb_test "p 2 > 3.1dl" " = 0"
+
+    set dsuffix {"dd" "df" "dl"}
+
+    foreach l $dsuffix {
+        foreach r $dsuffix {
+	    gdb_test "p 1.2${l} == 1.2${r}" " = 1"
+	    gdb_test "p 1.2${l} == 1.3${r}" " = 0"
+
+	    gdb_test "p 1.2${l} < 1.2${r}" " = 0"
+	    gdb_test "p 1.2${l} < 1.3${r}" " = 1"
+	    gdb_test "p 1.3${l} < 1.2${r}" " = 0"
+
+	    gdb_test "p 1.2${l} > 1.2${r}" " = 0"
+	    gdb_test "p 1.2${l} > 1.3${r}" " = 0"
+	    gdb_test "p 1.3${l} > 1.2${r}" " = 1"
+
+	    gdb_test "p 1.2${l} <= 1.2${r}" " = 1"
+	    gdb_test "p 1.2${l} <= 1.3${r}" " = 1"
+	    gdb_test "p 1.3${l} <= 1.2${r}" " = 0"
+
+	    gdb_test "p 1.2${l} >= 1.2${r}" " = 1"
+	    gdb_test "p 1.2${l} >= 1.3${r}" " = 0"
+	    gdb_test "p 1.3${l} >= 1.2${r}" " = 1"
+	}
+
+	gdb_test "p !0.${l}" " = 1"
+	gdb_test "p !0.5${l}" " = 0"
+
+	gdb_test "p +1.2${l}" " = 1.2"
+
+	# This checks GDB doesn't convert to int and rounds up/down.
+	gdb_test "p 1.2${l} == 1" " = 0"
+	gdb_test "p 1.2${l} == 2" " = 0"
+
+	gdb_test "p 1.2${l} == 1.2" \
+	    "Mixing decimal floating types with other floating types is not allowed\\."
+
+	gdb_test "p 1.2${l} > 1" " = 1"
+	gdb_test "p 1.2${l} > 2" " = 0"
+	gdb_test "p 1.2${l} >= 1" " = 1"
+	gdb_test "p 1.2${l} >= 2" " = 0"
+
+	gdb_test "p 1.2${l} < 1" " = 0"
+	gdb_test "p 1.2${l} < 2" " = 1"
+	gdb_test "p 1.2${l} <= 1" " = 0"
+	gdb_test "p 1.2${l} <= 2" " = 1"
+
+	gdb_test "p 1 < 1.2${l}" " = 1"
+	gdb_test "p 2 < 1.2${l}" " = 0"
+	gdb_test "p 1 <= 1.2${l}" " = 1"
+	gdb_test "p 2 <= 1.2${l}" " = 0"
+
+	gdb_test "p 1 > 1.2${l}" " = 0"
+	gdb_test "p 2 > 1.2${l}" " = 1"
+	gdb_test "p 1 >= 1.2${l}" " = 0"
+	gdb_test "p 2 >= 1.2${l}" " = 1"
+    }
 }
 
 proc test_dfp_conversions {} {

base-commit: 43f7c3581f5c615b65f7c15c298c9be20c2597cf
-- 
2.26.2


  reply	other threads:[~2021-12-10 23:04 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-21 17:56 [PATCH 00/29] Remove DUPLICATEs from testsuite/gdb.base/*.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 01/29] gdb/testsuite: Remove duplicates from gdb.base/stack-checking.exp Lancelot SIX via Gdb-patches
2022-01-04 13:59   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 02/29] gdb/testsuite: Remove duplicates from gdb.base/miscexprs.exp Lancelot SIX via Gdb-patches
2021-12-10 22:06   ` Pedro Alves
2021-12-14 23:28     ` Lancelot SIX via Gdb-patches
2021-12-15 11:52       ` Pedro Alves
2022-01-04 14:00   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 03/29] gdb/testsuite: Remove duplicates from gdb.base/interp.exp Lancelot SIX via Gdb-patches
2021-11-22 14:13   ` Pedro Alves
2021-11-22 17:33     ` Lancelot SIX via Gdb-patches
2021-12-10 22:01       ` Pedro Alves
2021-11-21 17:56 ` [PATCH 04/29] gdb/testsuite: Remove duplicates from gdb.base/realname-expand.exp Lancelot SIX via Gdb-patches
2022-01-04 14:06   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 05/29] gdb/testsuite: Remove duplicates from gdb.base/pie-fork.exp Lancelot SIX via Gdb-patches
2022-01-04 14:07   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 06/29] gdb/testsuite: Remove duplicates from gdb.base/checkpoint.exp Lancelot SIX via Gdb-patches
2022-01-04 14:11   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 07/29] gdb/testsuite: Remove duplicates from gdb.base/pending.exp Lancelot SIX via Gdb-patches
2022-01-04 14:12   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 08/29] gdb/testsuite: Remove duplicates from gdb.base/decl-before-def.exp Lancelot SIX via Gdb-patches
2022-01-04 14:13   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 09/29] gdb/testsuite: Remove duplicates from gdb.base/solib-display.exp Lancelot SIX via Gdb-patches
2022-01-04 14:17   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 10/29] gdb/testsuite: Remove duplicates from gdb.base/del.exp Lancelot SIX via Gdb-patches
2022-01-04 14:20   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 11/29] gdb/testsuite: Remove duplicates from gdb.base/dfp-test.exp Lancelot SIX via Gdb-patches
2022-01-04 14:26   ` Andrew Burgess via Gdb-patches
2022-01-05 22:03     ` Lancelot SIX via Gdb-patches
2022-01-06  9:34       ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 12/29] gdb/testsuite: Remove duplicates from gdb.base/ptype.exp Lancelot SIX via Gdb-patches
2022-01-04 15:13   ` Andrew Burgess via Gdb-patches
2021-11-21 17:56 ` [PATCH 13/29] gdb/testsuite: Remove duplicates from gdb.base/dfp-exprs.exp Lancelot SIX via Gdb-patches
2021-12-10 23:03   ` Pedro Alves [this message]
2021-12-15  0:01     ` Lancelot SIX via Gdb-patches
2021-12-15 11:54       ` Pedro Alves
2021-11-21 17:56 ` [PATCH 14/29] gdb/testsuite: Remove duplicates from gdb.base/subst.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 15/29] gdb/testsuite: Remove duplicates from gdb.base/complete-empty.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 16/29] gdb/testsuite: Remove duplicates from gdb.base/ui-redirect.exp Lancelot SIX via Gdb-patches
2021-12-10 23:15   ` Pedro Alves
2021-12-15  0:26     ` Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 17/29] gdb/testsuite: Remove duplicates from gdb.base/pretty-array.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 18/29] gdb/testsuite: Remove duplicates from gdb.base/readline.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 19/29] gdb/testsuite: Remove duplicates from gdb.base/exprs.exp Lancelot SIX via Gdb-patches
2021-12-10 23:15   ` Pedro Alves
2021-12-15  0:21     ` Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 20/29] gdb/testsuite: Remove duplicates from gdb.base/set-cfd.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 21/29] gdb/testsuite: Remove duplicates from gdb.base/shlib-call.exp Lancelot SIX via Gdb-patches
2021-12-10 23:24   ` Pedro Alves
2021-12-16 22:57     ` Lancelot SIX via Gdb-patches
2021-12-17 11:58       ` Pedro Alves
2021-11-21 17:56 ` [PATCH 22/29] gdb/testsuite: Remove duplicates from gdb.base/funcargs.exp Lancelot SIX via Gdb-patches
2021-12-10 23:26   ` Pedro Alves
2021-12-16 23:08     ` Lancelot SIX via Gdb-patches
2021-12-17 12:00       ` Pedro Alves
2021-11-21 17:56 ` [PATCH 23/29] gdb/testsuite: Remove duplicates from gdb.base/define-prefix.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 24/29] gdb/testsuite: Remove duplicates from gdb.base/unload.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 25/29] gdb/testsuite: Remove duplicates from gdb.base/pointers.exp Lancelot SIX via Gdb-patches
2021-12-10 23:27   ` Pedro Alves
2021-12-16 23:14     ` Lancelot SIX via Gdb-patches
2021-12-17 12:18       ` Pedro Alves
2021-12-17 23:14         ` Lancelot SIX via Gdb-patches
2022-01-05 16:05           ` Pedro Alves
2021-11-21 17:56 ` [PATCH 26/29] gdb/testsuite: Remove duplicates from gdb.base/call-signal-resume.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 27/29] gdb/testsuite: Remove duplicates from gdb.base/nested-subp2.exp Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 28/29] gdb/testsuite: Remove duplicates from gdb.base/watchpoints.exp Lancelot SIX via Gdb-patches
2021-12-10 23:30   ` Pedro Alves
2021-12-16 23:15     ` Lancelot SIX via Gdb-patches
2021-11-21 17:56 ` [PATCH 29/29] gdb/testsuite: Remove duplicates from gdb.base/corefile-buildid.exp Lancelot SIX via Gdb-patches
2021-12-10 23:38   ` Pedro Alves
2021-12-10 23:40 ` [PATCH 00/29] Remove DUPLICATEs from testsuite/gdb.base/*.exp Pedro Alves
2021-12-18  0:39   ` Lancelot SIX via Gdb-patches
2022-01-05 16:23     ` Pedro Alves
2022-01-07 22:36 ` Lancelot SIX via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0e6cef60-84ed-011b-8113-bc4bac1cce0e@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox