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

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


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

commit cd26f4025367ff78a9a4a2016ec7584341621cb5
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Nov 4 18:05:10 2025 +0800

    branch-4.0: [chore](UT) Add --gdb option to run-be-ut.sh and 
run-cloud-ut.sh #57655 (#57686)
    
    Cherry-picked from #57655
    
    Co-authored-by: Gavin Chou <[email protected]>
---
 cloud/script/run_all_tests.sh | 20 ++++++++++++++------
 run-be-ut.sh                  | 21 ++++++++++++++++++---
 run-cloud-ut.sh               | 19 ++++++++++++-------
 3 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/cloud/script/run_all_tests.sh b/cloud/script/run_all_tests.sh
index 8f9a2159644..71290198a7f 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"
 COVERAGE_FORMAT=${COVERAGE_FORMAT:-html}
 if [[ $# != 1 ]]; then
@@ -44,6 +45,10 @@ if [[ $# != 1 ]]; then
             ENABLE_CLANG_COVERAGE="ON"
             shift 1
             ;;
+        --gdb)
+            gdb=1
+            shift 1
+            ;;
         --test)
             test="$2"
             shift 2
@@ -131,6 +136,9 @@ 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
@@ -144,12 +152,12 @@ for i in *_test; do
         if [[ "${fdb}" != "" ]]; then
             patchelf --set-rpath "$(pwd)" "${i}"
         fi
-
-        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}"
+        if [[ ${gdb} -ne 0 ]]; then
+            gdb --args "${i}" "${filter}"
+            continue
         fi
+
+        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
diff --git a/run-be-ut.sh b/run-be-ut.sh
index 4f82730cf5b..3d550b2a41c 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 --filter=xx  build and run specified ut
      --run --gen_out    generate expected check data for test
      --run --gen_regression_case    generate regression test cases 
corrresponding to ut cases for ut cases that support it
-     --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,gen_regression_case,coverage,benchmark,run,clean,filter: -- "$@")"; then
+if ! OPTS="$(getopt -n "$0" -o vhj:f: -l 
gen_out,gen_regression_case,coverage,benchmark,run,gdb,clean,filter: -- "$@")"; 
then
     usage
 fi
 
@@ -80,6 +84,7 @@ eval set -- "${OPTS}"
 
 CLEAN=0
 RUN=0
+GDB=0
 DENABLE_CLANG_COVERAGE='OFF'
 BUILD_AZURE='ON'
 FILTER=""
@@ -96,6 +101,10 @@ if [[ "$#" != 1 ]]; then
             RUN=1
             shift
             ;;
+        --gdb)
+            GDB=1
+            shift
+            ;;
         --coverage)
             DENABLE_CLANG_COVERAGE='ON'
             shift
@@ -465,6 +474,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 fe9ea3de61c..c0d258eba4b 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)
@@ -225,8 +234,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