osmith submitted this change.

View Change

Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve
log_merge: use same prefix as for pcap files

In some testsuites we have tests in ttcn3 files other than the main
testsuite executable. In that case we save the pcap files with the name
of the ttcn3 file with the test, but before this patch the merged log
file has the name of the main testsuite. This is inconsistent and may
lead to a conflict if a test exists in multiple ttcn3 files.

Fix this by getting the same prefix as we use for the pcap from the
logfile itself. Fall back to using the same prefix as without this patch
in case we can't parse the log line.

Fixes: OS#6787
Change-Id: Id2937d711a54a34c0d87d080199b4c3d5a5d6e06
---
M log_merge.sh
1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/log_merge.sh b/log_merge.sh
index 7560fe9..65a3003 100755
--- a/log_merge.sh
+++ b/log_merge.sh
@@ -10,6 +10,37 @@
#
# the output files will be called "Module-Testcase.merged"

+# OS#6787: Get the same prefix as for the pcap files by parsing the external
+# command line from the logfile, e.g:
+# 11:34:37.106541 STP_Tests_M3UA.ttcn:877 Starting external command `/home/user/…/ttcn3-tcpdump-start.sh STP_Tests_M3UA.TC_rkm_unreg_active'.
+get_new_prefix() {
+ local prefix="$1"
+ local prefix_new
+ local start_cmd_line
+
+ for i in "$prefix"-*.log; do
+ if ! [ -e "$i" ]; then
+ continue
+ fi
+
+ start_cmd_line="$(grep -o 'Starting external command `.*-start.sh.*' "$i")"
+ if [ -z "$start_cmd_line" ]; then
+ continue
+ fi
+
+ prefix_new="$(echo "${start_cmd_line##* }" | cut -d "'" -f 1)"
+ if [ -z "$prefix_new" ]; then
+ continue
+ fi
+
+ echo "$prefix_new"
+ return
+ done
+
+ >&2 echo "log_merge: WARNING: get_new_prefix failed for: $prefix"
+ echo "$prefix"
+}
+
if [ "x$1" = "x" ]; then
echo "You have to specify the Test Suite prefix"
exit 2
@@ -22,7 +53,7 @@

for t in $TEST_CASES; do
PREFIX="$BASE_NAME-$t"
- OUTPUT="$BASE_NAME.$t.merged"
+ OUTPUT="$(get_new_prefix "$PREFIX").merged"
if [ -e "$OUTPUT" ]; then
>&2 echo "log_merge: ERROR: file already exists: $OUTPUT"
exit 1

To view, visit change 40213. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Id2937d711a54a34c0d87d080199b4c3d5a5d6e06
Gerrit-Change-Number: 40213
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>