diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
index 7c0abdece..400469c88 100644
--- a/tests/ovn-macros.at
+++ b/tests/ovn-macros.at
@@ -882,6 +882,10 @@ wake_up_ovsdb() {
   AT_CHECK([kill -CONT $(cat $1/ovsdb-server.pid)])
 }
 
+trim_zeros() {
+    sed 's/\(00\)\{1,\}$//'
+}
+
 OVS_END_SHELL_HELPERS
 
 m4_define([OVN_POPULATE_ARP], [AT_CHECK(ovn_populate_arp__, [0], [ignore])])
diff --git a/tests/ovn.at b/tests/ovn.at
index 31e41c012..8ebf55580 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -7326,10 +7326,6 @@ check ovn-nbctl --wait=hv sync
 # Start with 0 because the first request will not have NXT_RESUME
 n_resume=0
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 # This shell function sends a DHCPv6 request packet
 # test_dhcpv6 INPORT SRC_MAC SRC_LLA DHCPv6_MSG_TYPE OFFER_IP OUTPORT...
 # The OUTPORTs (zero or more) list the VIFs on which the original DHCPv6
@@ -9049,10 +9045,6 @@ packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111
 # Send IP packet destined to 8.8.8.8 from lsp1lp2
 as hv1 ovs-appctl netdev-dummy/receive hv1-ls1lp2 $packet
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 # ARP packet should be received with Target IP Address set to 192.168.1.254 and
 # not 8.8.8.8
 
@@ -9108,9 +9100,6 @@ AT_CAPTURE_FILE([sbflows])
 
 # Wait for packet to be received.
 OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 140])
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros |sort | uniq > packets
 AT_CHECK([sort packets], [0], [dnl
 fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001
@@ -9307,9 +9296,6 @@ ovn-nbctl list logical_router_port lrp0
 ovn-nbctl show
 # Wait for packet to be received.
 OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50])
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | sort | uniq > packets
 expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001"
 echo $expected > expout
@@ -9330,9 +9316,6 @@ ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" exclud
 
 # Wait for packets to be received.
 OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 250])
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
 
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets
 g0="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001"
@@ -10751,10 +10734,6 @@ OVN_POPULATE_ARP
 wait_for_ports_up
 check ovn-nbctl --wait=hv sync
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 # Send ip packets between foo1 and bar1
 # (East-west traffic should flow normally)
 src_mac="f00000010203"
@@ -12187,9 +12166,6 @@ OVN_WAIT_PATCH_PORT_FLOWS(["ln_port"], ["hv2"])
 
 # Wait for packets to be received.
 OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100])
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets
 expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001"
 echo $expected > expout
@@ -12221,10 +12197,6 @@ OVN_WAIT_PATCH_PORT_FLOWS(["ln_port"], ["hv3"])
 # Re-add nat-addresses option
 ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router"
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 garp_1="fffffffffffff0000000000308060001080006040001f00000000003c0a80003000000000000c0a80003"
 echo $garp_1 > expected_out
 garp_2="fffffffffffff0000000000408060001080006040001f00000000004c0a80004000000000000c0a80004"
@@ -13835,10 +13807,6 @@ as hv1 reset_pcap_file snoopvif hv1/snoopvif
 # add nat-addresses option
 ovn-nbctl --wait=hv lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router"
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 only_broadcast_from_lrp1() {
     grep "fffffffffffff00000000001"
 }
@@ -13869,10 +13837,6 @@ ovn-nbctl --wait=hv \
 as hv3 reset_pcap_file br-phys_n1 hv3/br-phys_n1
 as hv1 reset_pcap_file snoopvif hv1/snoopvif
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 OVN_CHECK_PACKETS_CONTAIN([hv1/snoopvif-tx.pcap], [expected_out], "trim_zeros")
 OVN_CHECK_PACKETS_CONTAIN([hv3/br-phys_n1-tx.pcap], [expected_out], "trim_zeros")
 $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx
@@ -13907,10 +13871,6 @@ ovn-nbctl --wait=hv lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="rout
 OVS_WAIT_UNTIL([test 1 = `ovn-sbctl --bare --columns nat_addresses find port_binding \
 logical_port=lrp0-rp | grep is_chassis | wc -l`])
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 garp="fffffffffffff00000000001810007de08060001080006040001f00000000001c0a80064000000000000c0a80064"
 echo $garp > expected_out
 
@@ -14256,10 +14216,6 @@ wc -l], [0], [4
 chassis_uuid=$(fetch_column Chassis _uuid name=hv1)
 wait_row_count Port_Binding 1 logical_port=cr-ip6_public chassis=$chassis_uuid
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 # Test the IPv6 Neighbor Solicitation (NS) - nd_ns action for unknown MAC
 # addresses. ovn-controller should generate an IPv6 NS request for IPv6
 # packets whose MAC is unknown (in the ARP_REQUEST router pipeline stage.
@@ -19729,11 +19685,6 @@ test_dhcp() {
     as hv1 ovs-appctl netdev-dummy/receive hv${inport}-ext${inport} $request
 }
 
-
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 # This shell function sends a DHCPv6 request packet
 # test_dhcpv6 INPORT SRC_MAC SRC_LLA DHCPv6_MSG_TYPE OFFER_IP OUTPORT...
 # The OUTPORTs (zero or more) list the VIFs on which the original DHCPv6
@@ -31365,10 +31316,6 @@ send_icmp_packet() {
     as hv$hv ovs-appctl netdev-dummy/receive hv$hv-vif$inport $packet
 }
 
-trim_zeros() {
-    sed 's/\(00\)\{1,\}$//'
-}
-
 AS_BOX([Wait for all ports to be up])
 wait_for_ports_up
 
