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

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 05a61d6fd4 GH-35361: [C++] Remove Perl dependency from 
cpp/build-support/run-test.sh (#35362)
05a61d6fd4 is described below

commit 05a61d6fd4fee0c998ae650fa0e67881681e4a5a
Author: Sutou Kouhei <[email protected]>
AuthorDate: Fri Apr 28 13:55:15 2023 +0900

    GH-35361: [C++] Remove Perl dependency from cpp/build-support/run-test.sh 
(#35362)
    
    ### Rationale for this change
    
    Because Perl in conda doesn't work on Manjaro Linux.
    
    ### What changes are included in this PR?
    
    * Use `sed` instead of `perl`.
    * Remove `stacktrace_addr2line.pl`. If we still need it, we can 
re-implement the addr2line filter in other language such as Python or shell 
later.
    
    ### Are these changes tested?
    
    Yes by hand on Manjaro Linux.
    
    ### Are there any user-facing changes?
    
    No.
    * Closes: #35361
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/build-support/run-test.sh             | 21 ++++---
 cpp/build-support/stacktrace_addr2line.pl | 92 -------------------------------
 2 files changed, 10 insertions(+), 103 deletions(-)

diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh
index 7f68abd31c..8e42438a23 100755
--- a/cpp/build-support/run-test.sh
+++ b/cpp/build-support/run-test.sh
@@ -39,7 +39,7 @@ TEST_DIRNAME=$(cd $(dirname $1); pwd)
 TEST_FILENAME=$(basename $1)
 shift
 TEST_EXECUTABLE="$TEST_DIRNAME/$TEST_FILENAME"
-TEST_NAME=$(echo $TEST_FILENAME | perl -pe 's/\..+?$//') # Remove path and 
extension (if any).
+TEST_NAME=$(echo $TEST_FILENAME | sed -E -e 's/\..+$//') # Remove path and 
extension (if any).
 
 # We run each test in its own subdir to avoid core file related races.
 TEST_WORKDIR=$OUTPUT_ROOT/build/test-work/$TEST_NAME
@@ -97,7 +97,6 @@ function run_test() {
   cat $LOGFILE.raw \
     | ${PYTHON:-python} $ROOT/build-support/asan_symbolize.py \
     | ${CXXFILT:-c++filt} \
-    | $ROOT/build-support/stacktrace_addr2line.pl $TEST_EXECUTABLE \
     | $pipe_cmd 2>&1 | tee $LOGFILE
   rm -f $LOGFILE.raw
 
@@ -157,15 +156,15 @@ function post_process_tests() {
   # case result to the XML file for the leak report. Otherwise Jenkins won't 
show
   # us which tests had LSAN errors.
   if grep -E -q "ERROR: LeakSanitizer: detected memory leaks" $LOGFILE ; then
-      echo Test had memory leaks. Editing XML
-      perl -p -i -e '
-      if (m#</testsuite>#) {
-        print "<testcase name=\"LeakSanitizer\" status=\"run\" 
classname=\"LSAN\">\n";
-        print "  <failure message=\"LeakSanitizer failed\" type=\"\">\n";
-        print "    See txt log file for details\n";
-        print "  </failure>\n";
-        print "</testcase>\n";
-      }' $XMLFILE
+    echo Test had memory leaks. Editing XML
+    sed -i.bak -e '/<\/testsuite>/ i\
+  <testcase name="LeakSanitizer" status="run" classname="LSAN">\
+    <failure message="LeakSanitizer failed" type="">\
+      See txt log file for details\
+    </failure>\
+  </testcase>' \
+      $XMLFILE
+    mv $XMLFILE.bak $XMLFILE
   fi
 }
 
diff --git a/cpp/build-support/stacktrace_addr2line.pl 
b/cpp/build-support/stacktrace_addr2line.pl
deleted file mode 100755
index caedc5c074..0000000000
--- a/cpp/build-support/stacktrace_addr2line.pl
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2014 Cloudera, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#######################################################################
-# This script will convert a stack trace with addresses:
-#     @           0x5fb015 kudu::master::Master::Init()
-#     @           0x5c2d38 kudu::master::MiniMaster::StartOnPorts()
-#     @           0x5c31fa kudu::master::MiniMaster::Start()
-#     @           0x58270a kudu::MiniCluster::Start()
-#     @           0x57dc71 kudu::CreateTableStressTest::SetUp()
-# To one with line numbers:
-#     @           0x5fb015 kudu::master::Master::Init() at 
/home/mpercy/src/kudu/src/master/master.cc:54
-#     @           0x5c2d38 kudu::master::MiniMaster::StartOnPorts() at 
/home/mpercy/src/kudu/src/master/mini_master.cc:52
-#     @           0x5c31fa kudu::master::MiniMaster::Start() at 
/home/mpercy/src/kudu/src/master/mini_master.cc:33
-#     @           0x58270a kudu::MiniCluster::Start() at 
/home/mpercy/src/kudu/src/integration-tests/mini_cluster.cc:48
-#     @           0x57dc71 kudu::CreateTableStressTest::SetUp() at 
/home/mpercy/src/kudu/src/integration-tests/create-table-stress-test.cc:61
-#
-# If the script detects that the output is not symbolized, it will also attempt
-# to determine the function names, i.e. it will convert:
-#     @           0x5fb015
-#     @           0x5c2d38
-#     @           0x5c31fa
-# To:
-#     @           0x5fb015 kudu::master::Master::Init() at 
/home/mpercy/src/kudu/src/master/master.cc:54
-#     @           0x5c2d38 kudu::master::MiniMaster::StartOnPorts() at 
/home/mpercy/src/kudu/src/master/mini_master.cc:52
-#     @           0x5c31fa kudu::master::MiniMaster::Start() at 
/home/mpercy/src/kudu/src/master/mini_master.cc:33
-#######################################################################
-use strict;
-use warnings;
-
-if (!@ARGV) {
-  die <<EOF
-Usage: $0 executable [stack-trace-file]
-
-This script will read addresses from a file containing stack traces and
-will convert the addresses that conform to the pattern " @ 0x123456" to line
-numbers by calling addr2line on the provided executable.
-If no stack-trace-file is specified, it will take input from stdin.
-EOF
-}
-
-# el6 and other older systems don't support the -p flag,
-# so we do our own "pretty" parsing.
-sub parse_addr2line_output($$) {
-  defined(my $output = shift) or die;
-  defined(my $lookup_func_name = shift) or die;
-  my @lines = grep { $_ ne '' } split("\n", $output);
-  my $pretty_str = '';
-  if ($lookup_func_name) {
-    $pretty_str .= ' ' . $lines[0];
-  }
-  $pretty_str .= ' at ' . $lines[1];
-  return $pretty_str;
-}
-
-my $binary = shift @ARGV;
-if (! -x $binary || ! -r $binary) {
-  die "Error: Cannot access executable ($binary)";
-}
-
-# Cache lookups to speed processing of files with repeated trace addresses.
-my %addr2line_map = ();
-
-# Disable stdout buffering
-$| = 1;
-
-# Reading from <ARGV> is magical in Perl.
-while (defined(my $input = <ARGV>)) {
-  if ($input =~ /^\s+\@\s+(0x[[:xdigit:]]{6,})(?:\s+(\S+))?/) {
-    my $addr = $1;
-    my $lookup_func_name = (!defined $2);
-    if (!exists($addr2line_map{$addr})) {
-      $addr2line_map{$addr} = `addr2line -ifC -e $binary $addr`;
-    }
-    chomp $input;
-    $input .= parse_addr2line_output($addr2line_map{$addr}, $lookup_func_name) 
. "\n";
-  }
-  print $input;
-}
-
-exit 0;

Reply via email to