From: Pedro Alves Date: Fri, 10 Dec 2021 22:41:54 +0000 (+0000) Subject: gdb/testsuite: Remove duplicates from gdb.base/dfp-exprs.exp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ffd5d21ae272aba3efdee3d677050b69c09e6f16;p=binutils-gdb.git 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 --- diff --git a/gdb/testsuite/gdb.base/dfp-exprs.exp b/gdb/testsuite/gdb.base/dfp-exprs.exp index 424725f9cfb..2684f70bd5a 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 {} {