This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 9ae35848832 branch-3.1: [chore](UT) Add --gdb option to run-be-ut.sh 
and run-cloud-ut.sh #57655 #56839 (#57826)
9ae35848832 is described below

commit 9ae35848832cbf53be9483d6f963554dd75e9fc2
Author: Gavin Chou <[email protected]>
AuthorDate: Mon Nov 10 11:03:54 2025 +0800

    branch-3.1: [chore](UT) Add --gdb option to run-be-ut.sh and 
run-cloud-ut.sh #57655 #56839 (#57826)
    
    pick #56839 #57655
---
 cloud/script/run_all_tests.sh | 27 ++++++++++++++++++++-------
 run-be-ut.sh                  | 21 ++++++++++++++++++---
 run-cloud-ut.sh               | 19 ++++++++++++-------
 3 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/cloud/script/run_all_tests.sh b/cloud/script/run_all_tests.sh
index 003510f91d4..e2266def8ec 100644
--- a/cloud/script/run_all_tests.sh
+++ b/cloud/script/run_all_tests.sh
@@ -25,7 +25,7 @@ function usage() {
     echo "    test_binary the unit test binary name, e.g. txn_kv_test"
     echo "    gtest_filter the filter for the test_binary unit test, e.g. 
TxnKvTest.BatchGet"
 }
-if ! OPTS=$(getopt -n "$0" -o a:b:c: -l test:,fdb:,filter:,coverage -- "$@"); 
then
+if ! OPTS=$(getopt -n "$0" -o a:b:c: -l test:,fdb:,filter:,coverage,gdb -- 
"$@"); then
     usage
     exit 1
 fi
@@ -35,6 +35,7 @@ eval set -- "${OPTS}"
 test=""
 fdb_conf=""
 filter=""
+gdb=0
 ENABLE_CLANG_COVERAGE="OFF"
 if [[ $# != 1 ]]; then
     while true; do
@@ -43,6 +44,10 @@ if [[ $# != 1 ]]; then
             ENABLE_CLANG_COVERAGE="ON"
             shift 1
             ;;
+        --gdb)
+            gdb=1
+            shift 1
+            ;;
         --test)
             test="$2"
             shift 2
@@ -129,6 +134,10 @@ function report_coverage() {
 
 export LSAN_OPTIONS=suppressions=./lsan_suppr.conf
 unittest_files=()
+ret=0
+if [[ "${filter}" != "" ]]; then
+    filter="--gtest_filter=${filter}"
+fi
 for i in *_test; do
     [[ -e "${i}" ]] || break
     if [[ "${test}" != "" ]]; then
@@ -142,14 +151,17 @@ for i in *_test; do
         if [[ "${fdb}" != "" ]]; then
             patchelf --set-rpath "$(pwd)" "${i}"
         fi
+        if [[ ${gdb} -ne 0 ]]; then
+            gdb --args "${i}" "${filter}"
+            continue
+        fi
 
-        set -euo pipefail
-        if [[ "${filter}" == "" ]]; then
-            LLVM_PROFILE_FILE="./report/${i}.profraw" "./${i}" 
--gtest_print_time=true --gtest_output="xml:${i}.xml"
-        else
-            LLVM_PROFILE_FILE="./report/${i}.profraw" "./${i}" 
--gtest_print_time=true --gtest_output="xml:${i}.xml" --gtest_filter="${filter}"
+        LLVM_PROFILE_FILE="./report/${i}.profraw" "./${i}" 
--gtest_print_time=true --gtest_output="xml:${i}.xml" "${filter}"
+        last_ret=$?
+        echo "${i} ret=${last_ret}"
+        if [[ ${ret} -eq 0 ]]; then
+            ret=${last_ret}
         fi
-        set +euo pipefail
         unittest_files[${#unittest_files[*]}]="${i}"
         echo "--------------------------"
     fi
@@ -159,4 +171,5 @@ if [[ "_${ENABLE_CLANG_COVERAGE}" == "_ON" ]]; then
     report_coverage "${unittest_files[*]}"
 fi
 
+exit ${ret}
 # vim: et ts=4 sw=4:
diff --git a/run-be-ut.sh b/run-be-ut.sh
index bdc71b46b45..40a9036b37b 100755
--- a/run-be-ut.sh
+++ b/run-be-ut.sh
@@ -23,6 +23,8 @@
 #     --clean            clean and build ut
 #     --run              build and run all ut
 #     --run --filter=xx  build and run specified ut
+#     --gdb              debug with gdb, does not take effect if --run is not 
specified
+#     --coverage         generate coverage report, does not take effect if 
--gdb is specified
 #     -j                 build parallel
 #     -h                 print this help message
 #
@@ -52,7 +54,8 @@ Usage: $0 <options>
      --run              build and run all ut
      --run --filter=xx  build and run specified ut
      --run --gen_out    generate expected check data for test
-     --coverage         coverage after run ut
+     --gdb              debug with gdb, DOES NOT take effect if --run is not 
specified
+     --coverage         generage coverage after run ut, DOES NOT take effect 
if --gdb is specified
      -j                 build parallel
      -h                 print this help message
 
@@ -67,12 +70,13 @@ Usage: $0 <options>
     $0 --run --filter=FooTest.*:BarTest.*-FooTest.Bar:BarTest.Foo   runs 
everything in test suite FooTest except FooTest.Bar and everything in test 
suite BarTest except BarTest.Foo
     $0 --clean                                                      clean and 
build tests
     $0 --clean --run                                                clean, 
build and run all tests
-    $0 --clean --run --coverage                                     clean, 
build, run all tests and coverage
+    $0 --clean --run --coverage                                     clean, 
build, run all tests and generate coverage report
+    $0 --clean --run --gdb --filter=FooTest.*-FooTest.Bar           clean, 
build, run all tests and debug FooTest with gdb
   "
     exit 1
 }
 
-if ! OPTS="$(getopt -n "$0" -o vhj:f: -l 
gen_out,coverage,benchmark,run,clean,filter: -- "$@")"; then
+if ! OPTS="$(getopt -n "$0" -o vhj:f: -l 
gen_out,coverage,benchmark,run,gdb,clean,filter: -- "$@")"; then
     usage
 fi
 
@@ -81,6 +85,7 @@ eval set -- "${OPTS}"
 CLEAN=0
 RUN=0
 BUILD_BENCHMARK_TOOL='OFF'
+GDB=0
 DENABLE_CLANG_COVERAGE='OFF'
 BUILD_AZURE='ON'
 FILTER=""
@@ -100,6 +105,10 @@ if [[ "$#" != 1 ]]; then
             BUILD_BENCHMARK_TOOL='ON'
             shift
             ;;
+        --gdb)
+            GDB=1
+            shift
+            ;;
         --coverage)
             DENABLE_CLANG_COVERAGE='ON'
             shift
@@ -471,6 +480,12 @@ test="${DORIS_TEST_BINARY_DIR}/doris_be_test"
 profraw=${DORIS_TEST_BINARY_DIR}/doris_be_test.profraw
 profdata=${DORIS_TEST_BINARY_DIR}/doris_be_test.profdata
 
+
+if [[ ${GDB} -ge 1 ]]; then
+    gdb --args "${test}" "${FILTER}"
+    exit
+fi
+
 file_name="${test##*/}"
 if [[ -f "${test}" ]]; then
     if [[ "_${DENABLE_CLANG_COVERAGE}" == "_ON" ]]; then
diff --git a/run-cloud-ut.sh b/run-cloud-ut.sh
index 62f84c1b6eb..f4f2fb365c1 100755
--- a/run-cloud-ut.sh
+++ b/run-cloud-ut.sh
@@ -47,13 +47,14 @@ Usage: $0 <options>
   Optional options:
      --clean            clean and build ut
      --run              build and run all ut
-     --coverage         coverage after run ut
+     --coverage         coverage after run ut, does not take if --gdb is 
specified
      --run --filter=x   build and run specified ut, filter x format is 
<binary_name>:<gtest_filter>,
                         a <binary_name> is the name of a cpp file without 
'.cpp' suffix.
                         e.g. binary_name of xxx_test.cpp is xxx_test
      --fdb              run with a specific fdb connection string, e.g 
fdb_cluster0:[email protected]:4500
      -j                 build parallel
      -h                 print this help message
+     --gdb              debug with gdb, does not take effect if --run is not 
specified
 
   Eg.
     $0                                                                         
 build tests
@@ -67,11 +68,12 @@ Usage: $0 <options>
     $0 --run --coverage                                                        
 run with coverage report
     $0 --clean                                                                 
 clean and build tests
     $0 --clean --run                                                           
 clean, build and run all tests
+    $0 --clean --run --gdb --filter=recycler_test:FooTest.*-FooTest.Bar        
clean, build, run all tests and debug FooTest with gdb
     "
     exit 1
 }
 
-if ! OPTS=$(getopt -n "$0" -o vhj:f: -l run,clean,filter:,fdb:,coverage -- 
"$@"); then
+if ! OPTS=$(getopt -n "$0" -o vhj:f: -l run,gdb,clean,filter:,fdb:,coverage -- 
"$@"); then
     usage
 fi
 
@@ -85,6 +87,8 @@ CLEAN=0
 RUN=0
 FILTER=""
 FDB=""
+GDB=""
+COVERAGE=""
 ENABLE_CLANG_COVERAGE=OFF
 BUILD_AZURE="ON"
 
@@ -100,8 +104,13 @@ if [[ $# != 1 ]]; then
             RUN=1
             shift
             ;;
+        --gdb)
+            GDB="--gdb"
+            shift
+            ;;
         --coverage)
             ENABLE_CLANG_COVERAGE="ON"
+            COVERAGE="--coverage"
             shift
             ;;
         --fdb)
@@ -230,8 +239,4 @@ cd test
 # FILTER: meta_service_test:DetachSchemaKVTest.*
 # ./run_all_tests.sh --test "\"$(echo "${FILTER}" | awk -F: '{print $1}')\"" 
--filter "\"$(echo "${FILTER}" | awk -F: '{print $2}')\"" --fdb "\"${FDB}\""
 set -euo pipefail
-if [[ "_${ENABLE_CLANG_COVERAGE}" == "_ON" ]]; then
-    bash -x ./run_all_tests.sh --coverage --test "$(echo "${FILTER}" | awk -F: 
'{print $1}')" --filter "$(echo "${FILTER}" | awk -F: '{print $2}')" --fdb 
"${FDB}"
-else
-    bash ./run_all_tests.sh --test "$(echo "${FILTER}" | awk -F: '{print 
$1}')" --filter "$(echo "${FILTER}" | awk -F: '{print $2}')" --fdb "${FDB}"
-fi
+bash -x ./run_all_tests.sh "${COVERAGE}" --test "$(echo "${FILTER}" | awk -F: 
'{print $1}')" --filter "$(echo "${FILTER}" | awk -F: '{print $2}')" --fdb 
"${FDB}" "${GDB}"


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to