gdb/testsuite: Remove duplicates from gdb.base/dfp-exprs.exp

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

Replace hand-written tests checking various comparison operators between
various decimal floating point types with a loop to programmatically
generate all the combinations.  This removes the need to eyeball for all
suffixes, which lead to the original duplication.

Also add a lot more combinations, testing all comparison operators
comprehensively.  The result is 262 unique tests vs 104 before this
patch.

Tested on x86_86-linux.

Change-Id: Id215a3d610aa8e032bf06ee160b5e3aed4a92d1e
This commit is contained in:
Pedro Alves
2021-12-10 22:41:54 +00:00
committed by Lancelot SIX
parent 0988568e6a
commit ffd5d21ae2

View File

@ -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"
set dsuffix {"dd" "df" "dl"}
gdb_test "p +1.2df" " = 1.2"
gdb_test "p +1.2dd" " = 1.2"
gdb_test "p +1.2dl" " = 1.2"
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.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"
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 {} {