Fix some test cases fail to be executed, Resolve the sc2168 warning detected by the shellcheck tool.

This commit is contained in:
langfei 2023-07-03 22:07:29 +08:00
parent 54586b5245
commit 73a0b1c45b
5 changed files with 204 additions and 1 deletions

View File

@ -0,0 +1,63 @@
From 5d0424e51857d5f706e78d6d962f380fa70f49f0 Mon Sep 17 00:00:00 2001
From: langfei <langfei@huawei.com>
Date: Wed, 5 Jul 2023 10:27:11 +0800
Subject: [PATCH] fix network tcp test error
Signed-off-by: langfei <langfei@huawei.com>
---
tapset/linux/ipmib.stp | 4 ++--
tapset/linux/linuxmib.stp | 2 +-
testsuite/systemtap.examples/network/tcp_trace.stp | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tapset/linux/ipmib.stp b/tapset/linux/ipmib.stp
index 6f51dfd..603c5d4 100644
--- a/tapset/linux/ipmib.stp
+++ b/tapset/linux/ipmib.stp
@@ -271,7 +271,7 @@ probe ipmib.InAddrErrors=kernel.function("ip_route_input_noref").return!,
* IPSTATS_MIB_INUNKNOWNPROTOS)
*/
/* icmp_send() is called by ip_local_deliver_finish() */
-probe ipmib.InUnknownProtos=kernel.function("icmp_send")
+probe ipmib.InUnknownProtos=kernel.function("__icmp_send")
{
skb = $skb_in;
op = 1;
@@ -360,7 +360,7 @@ probe ipmib.OutRequests=kernel.function("ip_output"),
* counted in the global @ReasmTimeout (equivalent to SNMP's MIB
* IPSTATS_MIB_REASMTIMEOUT)
*/
-probe ipmib.ReasmTimeout=kernel.function("icmp_send")
+probe ipmib.ReasmTimeout=kernel.function("__icmp_send")
{
skb = $skb_in;
op = 0;
diff --git a/tapset/linux/linuxmib.stp b/tapset/linux/linuxmib.stp
index 63ec248..cb92875 100644
--- a/tapset/linux/linuxmib.stp
+++ b/tapset/linux/linuxmib.stp
@@ -30,7 +30,7 @@ probe linuxmib.DelayedACKs = _linuxmib.DelayedACKs.* {}
probe _linuxmib.DelayedACKs.A = kernel.function("tcp_send_ack")
{
- sk=$sk
+ sk=pointer_arg(1)
if ( !indelack_timer[sk] ) next
op=1
key = linuxmib_filter_key(sk,op);
diff --git a/testsuite/systemtap.examples/network/tcp_trace.stp b/testsuite/systemtap.examples/network/tcp_trace.stp
index 65a32f2..98c77c0 100755
--- a/testsuite/systemtap.examples/network/tcp_trace.stp
+++ b/testsuite/systemtap.examples/network/tcp_trace.stp
@@ -192,7 +192,7 @@ probe kernel.{function("tcp_rcv_established"),
}
}
-probe kernel.function("tcp_transmit_skb")
+probe kernel.function("__tcp_transmit_skb")
{
sk = $sk
key = filter_key(sk)
--
2.33.0

View File

@ -0,0 +1,59 @@
From af456ec9eefd320b496ce54686ca2099c26ca301 Mon Sep 17 00:00:00 2001
From: langfei <langfei@huawei.com>
Date: Wed, 5 Jul 2023 10:32:14 +0800
Subject: [PATCH] fix py3example script run fail
Signed-off-by: langfei <langfei@huawei.com>
---
.../general/tapset/python_local.stpm | 37 ++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/testsuite/systemtap.examples/general/tapset/python_local.stpm b/testsuite/systemtap.examples/general/tapset/python_local.stpm
index 84f9a55..f02ff7a 100644
--- a/testsuite/systemtap.examples/general/tapset/python_local.stpm
+++ b/testsuite/systemtap.examples/general/tapset/python_local.stpm
@@ -7,5 +7,40 @@
# Set this to the location of the python 3 .so
@define PYTHON3_LIBRARY
%(
- "/usr/lib64/libpython3.4m.so.1.0"
+ "/usr/lib64/libpython3.7m.so.1.0"
+%)
+
+@define Py3DictKeysObject(object) %(
+ @cast(@object, "PyDictKeysObject", @PYTHON3_LIBRARY)
+ %)
+@define Py3DictKeyEntry(object) %(
+ @cast(@object, "PyDictKeyEntry", @PYTHON3_LIBRARY)
+ %)
+
+@define DK_SIZE(dk) %(
+ @Py3DictKeysObject(@dk)->dk_size
+%)
+@define DK_IXSIZE(dk) %(
+ %( CONFIG_64BIT == "y" %?
+ %( CONFIG_COMPAT == "y" %?
+ (@__compat_task
+ ? (@DK_SIZE(@dk) <= 0xff ? 1 : (@DK_SIZE(@dk) <= 0xffff ? 2
+: 4))
+ : (@DK_SIZE(@dk) <= 0xff ?
+ 1 : (@DK_SIZE(@dk) <= 0xffff ?
+ 2 : (@DK_SIZE(@dk) <= 0xffffffff ? 4 : 8))))
+ %:
+ (@DK_SIZE(@dk) <= 0xff ?
+ 1 : (@DK_SIZE(@dk) <= 0xffff ?
+ 2 : (@DK_SIZE(@dk) <= 0xffffffff ? 4 : 8)))
+ %)
+ %:
+ (@DK_SIZE(@dk) <= 0xff ? 1 : (@DK_SIZE(@dk) <= 0xffff ? 2 : 4))
+ %)
+%)
+
+@define DK_ENTRIES(dk) %(
+ (@choose_defined(@Py3DictKeysObject(@dk)->dk_entries,
+(&@Py3DictKeyEntry(&@Py3DictKeysObject(@dk)->dk_indices[@DK_SIZE(@dk) *
+@DK_IXSIZE(@dk)]))))
%)
--
2.33.0

View File

@ -0,0 +1,44 @@
From ee556777a8f7d46ccfe0d53dd1088ab1724c9e42 Mon Sep 17 00:00:00 2001
From: langfei <langfei@huawei.com>
Date: Wed, 5 Jul 2023 10:40:41 +0800
Subject: [PATCH] fix py3example script run fail2
Signed-off-by: langfei <langfei@huawei.com>
---
.../systemtap.examples/general/tapset/python3_local.stp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/testsuite/systemtap.examples/general/tapset/python3_local.stp b/testsuite/systemtap.examples/general/tapset/python3_local.stp
index 4e26946..197be47 100644
--- a/testsuite/systemtap.examples/general/tapset/python3_local.stp
+++ b/testsuite/systemtap.examples/general/tapset/python3_local.stp
@@ -182,7 +182,7 @@ function p3_get_dict_hash (dict, i) {
n = @cast (dict, "PyDictObject", @PYTHON3_LIBRARY)->ma_used;
if (i > n || entries == 0)
return 0
- return @cast (entries, "PyDictKeysObject", @PYTHON3_LIBRARY)->dk_entries[i]->me_hash
+ return @cast (@DK_ENTRIES(entries), "PyDictKeyEntry", @PYTHON3_LIBRARY)[i]->me_hash
}
# FUNCTION P3_GET_DICT_KEY
@@ -195,7 +195,7 @@ function p3_get_dict_key (dict, i) {
n = @cast (dict, "PyDictObject", @PYTHON3_LIBRARY)->ma_used;
if (i > n || entries == 0)
return 0
- return @cast (entries, "PyDictKeysObject", @PYTHON3_LIBRARY)->dk_entries[i]->me_key
+ return @cast (@DK_ENTRIES(entries), "PyDictKeyEntry", @PYTHON3_LIBRARY)[i]->me_key
}
# FUNCTION P3_GET_DICT_VALUE
@@ -214,7 +214,7 @@ function p3_get_dict_value (dict, i) {
n = @cast (dict, "PyDictObject", @PYTHON3_LIBRARY)->ma_used;
if (i > n || entries == 0)
return 0
- return @cast (entries, "PyDictKeysObject", @PYTHON3_LIBRARY)->dk_entries[i]->me_value
+ return @cast (@DK_ENTRIES(entries), "PyDictKeyEntry", @PYTHON3_LIBRARY)[i]->me_value
}
}
--
2.33.0

View File

@ -0,0 +1,26 @@
From cea3c6a744e5f0d2017e5cc11033b8d226b482f9 Mon Sep 17 00:00:00 2001
From: langfei <langfei@huawei.com>
Date: Wed, 5 Jul 2023 10:45:23 +0800
Subject: [PATCH] local is only valid in functions for shellcheck sc2168
Signed-off-by: langfei <langfei@huawei.com>
---
doc/Tapset_Reference_Guide/publicanize.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/Tapset_Reference_Guide/publicanize.sh b/doc/Tapset_Reference_Guide/publicanize.sh
index 330409e..97254fe 100755
--- a/doc/Tapset_Reference_Guide/publicanize.sh
+++ b/doc/Tapset_Reference_Guide/publicanize.sh
@@ -22,7 +22,7 @@ do
val=`printf %s $1 | awk -F= '{print $2}'`
shift
if test -z "$val"; then
- local possibleval=$1
+ possibleval=$1
printf %s $1 "$possibleval" | grep ^- >/dev/null 2>&1
if test "$?" != "0"; then
val=$possibleval
--
2.33.0

View File

@ -22,7 +22,7 @@
Name: systemtap
Version: 4.5
Release: 5
Release: 6
Summary: Linux trace and probe tool
License: GPLv2+ and Public Domain
URL: http://sourceware.org/systemtap
@ -31,6 +31,11 @@ Source: https://sourceware.org/systemtap/ftp/releases/%{name}-%{version}.tar.gz
Patch1: 0001-Add-init-type-cast-to-resolve-gcc-issue.patch
Patch2: 0001-PR29094-Include-rpm-rpmcrypto.h-when-required.patch
Patch9000: huawei-fix-py3example-script-run-fail.patch
Patch9001: huawei-fix-py3example-script-run-fail2.patch
Patch9002: huawei-fix-network-tcp-test-error.patch
Patch9003: huawei-local-is-only-valid-in-functions-for-shellche-sc2168.patch
BuildRequires: gcc-c++ emacs systemd python3-setuptools
BuildRequires: gettext-devel rpm-devel readline-devel
BuildRequires: pkgconfig(nss) pkgconfig(avahi-client)
@ -457,6 +462,12 @@ exit 0
%{_mandir}/man[1378]/*
%changelog
* Wed Jul 5 2023 langfei<langfei@huawei.com> - 4.5-6
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:Fix some test cases fail to be executed, Resolve the sc2168 warning detected by the shellcheck tool.
* Mon Feb 6 2023 langfei<langfei@huawei.com> - 4.5-5
- Type:bugfix
- CVE:NA