kou commented on code in PR #51121:
URL: https://github.com/apache/arrow/pull/51121#discussion_r3911292833


##########
cpp/build-support/run-test.sh:
##########
@@ -139,23 +139,30 @@ function print_coredumps() {
   FILENAME=$(basename "${TEST_EXECUTABLE}")
   FILENAME=$(echo "${FILENAME}" | cut -c-15)
 
-  COREFILES=$(find /tmp -maxdepth 1 -type f -name "core.${FILENAME}*" -exec 
basename {} \;)
-  if [ -n "$COREFILES" ]; then
-    for COREFILE in $COREFILES; do
-      COREPATH="/tmp/${COREFILE}"
-      echo 
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
-      echo "Running '${TEST_EXECUTABLE}' produced core dump at '${COREPATH}', 
printing backtrace:"
-      # Print backtrace
-      if [ "$(uname)" == "Darwin" ]; then
-        lldb -c "${COREPATH}" --batch --one-line "thread backtrace all -e true"
-      else
-        gdb -c "${COREPATH}" "$TEST_EXECUTABLE" -ex "thread apply all bt" -ex 
"set pagination 0" -batch
-      fi
-      echo 
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
-      # Remove the coredump, it can be regenerated via running the test case 
directly
-      rm "${COREPATH}"
-    done
-  fi
+  for COREPATH in "/tmp/core.${FILENAME}"*; do
+    # Skip if the glob did not match any core files.
+    if [[ "${COREPATH}" == *\* ]]; then
+      continue
+    fi
+
+    if [ ! -e "${COREPATH}" ]; then
+      echo "Core file '${COREPATH}' no longer exists. It may have been removed 
by another process."
+      continue
+    fi

Review Comment:
   Can we simplify this?
   
   ```suggestion
       # Skip if the glob did not match any core files or the core file has 
been removed by another process.
       if [ ! -e "${COREPATH}" ]; then
         continue
       fi
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to