summaryrefslogtreecommitdiffstats
path: root/test/test_pcap.py
diff options
context:
space:
mode:
authorPratikshya Prasai <pratikshyaprasai2112@gmail.com>2022-08-18 11:09:38 -0400
committerDave Wallace <dwallacelf@gmail.com>2022-11-09 21:22:33 -0500
commit657bdf781ae876c945ca034e52cf25cccb09f71e (patch)
tree9ae70d0cb644ea9f609509ba4e83c84f687a264e /test/test_pcap.py
parent4dbd641136db81ba969a5a1c0374ec9c24525526 (diff)
tests: initial asf framework refactoring for 'make test'
Type: refactor Change-Id: I41455b759a5d302ad5c4247c13634c471e7d49a8 Signed-off-by: Pratikshya Prasai <pratikshyaprasai2112@gmail.com> Signed-off-by: Saima Yunus <yunus.saima.234@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'test/test_pcap.py')
-rw-r--r--test/test_pcap.py91
1 files changed, 0 insertions, 91 deletions
diff --git a/test/test_pcap.py b/test/test_pcap.py
deleted file mode 100644
index 7405d2e5153..00000000000
--- a/test/test_pcap.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-import unittest
-
-from framework import VppTestCase, VppTestRunner
-from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
-
-
-class TestPcap(VppTestCase):
- """Pcap Unit Test Cases"""
-
- @classmethod
- def setUpClass(cls):
- super(TestPcap, cls).setUpClass()
-
- @classmethod
- def tearDownClass(cls):
- super(TestPcap, cls).tearDownClass()
-
- def setUp(self):
- super(TestPcap, self).setUp()
-
- def tearDown(self):
- super(TestPcap, self).tearDown()
-
- # This is a code coverage test, but it only runs for 0.3 seconds
- # might as well just run it...
- def test_pcap_unittest(self):
- """PCAP Capture Tests"""
- cmds = [
- "loop create",
- "set int ip address loop0 11.22.33.1/24",
- "set int state loop0 up",
- "loop create",
- "set int ip address loop1 11.22.34.1/24",
- "set int state loop1 up",
- "set ip neighbor loop1 11.22.34.44 03:00:11:22:34:44",
- "packet-generator new {\n"
- " name s0\n"
- " limit 10\n"
- " size 128-128\n"
- " interface loop0\n"
- " tx-interface loop1\n"
- " node loop1-output\n"
- " buffer-flags ip4 offload\n"
- " buffer-offload-flags offload-ip-cksum offload-udp-cksum\n"
- " data {\n"
- " IP4: 1.2.3 -> dead.0000.0001\n"
- " UDP: 11.22.33.44 -> 11.22.34.44\n"
- " ttl 2 checksum 13\n"
- " UDP: 1234 -> 2345\n"
- " checksum 11\n"
- " incrementing 114\n"
- " }\n"
- "}",
- "pcap dispatch trace on max 100 buffer-trace pg-input 10",
- "pa en",
- "pcap dispatch trace off",
- "pcap trace rx tx max 1000 intfc any",
- "pa en",
- "pcap trace status",
- "pcap trace rx tx off",
- "classify filter pcap mask l3 ip4 src match l3 ip4 src 11.22.33.44",
- "pcap trace rx tx max 1000 intfc any file filt.pcap filter",
- "show cla t verbose 2",
- "show cla t verbose",
- "show cla t",
- "pa en",
- "pcap trace rx tx off",
- "classify filter pcap del mask l3 ip4 src",
- ]
-
- for cmd in cmds:
- r = self.vapi.cli_return_response(cmd)
- if r.retval != 0:
- if hasattr(r, "reply"):
- self.logger.info(cmd + " FAIL reply " + r.reply)
- else:
- self.logger.info(cmd + " FAIL retval " + str(r.retval))
-
- self.assertTrue(os.path.exists("/tmp/dispatch.pcap"))
- self.assertTrue(os.path.exists("/tmp/rxtx.pcap"))
- self.assertTrue(os.path.exists("/tmp/filt.pcap"))
- os.remove("/tmp/dispatch.pcap")
- os.remove("/tmp/rxtx.pcap")
- os.remove("/tmp/filt.pcap")
-
-
-if __name__ == "__main__":
- unittest.main(testRunner=VppTestRunner)
f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2018 Cisco and/or its affiliates.
 * 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.
 */

#include <vnet/ethernet/mac_address.h>

/* *INDENT-OFF* */
const mac_address_t ZERO_MAC_ADDRESS = {
  .bytes = {
    0, 0, 0, 0, 0, 0,
  },
};
/* *INDENT-ON* */

u8 *
format_mac_address_t (u8 * s, va_list * args)
{
  const mac_address_t *mac = va_arg (*args, mac_address_t *);

  return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
		 mac->bytes[0], mac->bytes[1], mac->bytes[2],
		 mac->bytes[3], mac->bytes[4], mac->bytes[5]);
}

uword
unformat_mac_address_t (unformat_input_t * input, va_list * args)
{
  mac_address_t *mac = va_arg (*args, mac_address_t *);
  u32 i, a[3];

  if (unformat (input, "%_%X:%X:%X:%X:%X:%X%_",
		1, &mac->bytes[0], 1, &mac->bytes[1], 1, &mac->bytes[2],
		1, &mac->bytes[3], 1, &mac->bytes[4], 1, &mac->bytes[5]))
    return (1);
  else if (unformat (input, "%_%x.%x.%x%_", &a[0], &a[1], &a[2]))
    {
      for (i = 0; i < ARRAY_LEN (a); i++)
	if (a[i] >= (1 << 16))
	  return 0;

      mac->bytes[0] = (a[0] >> 8) & 0xff;
      mac->bytes[1] = (a[0] >> 0) & 0xff;
      mac->bytes[2] = (a[1] >> 8) & 0xff;
      mac->bytes[3] = (a[1] >> 0) & 0xff;
      mac->bytes[4] = (a[2] >> 8) & 0xff;
      mac->bytes[5] = (a[2] >> 0) & 0xff;

      return (1);
    }
  return (0);
}

void
mac_address_increment (mac_address_t * mac)
{
  u64 a;

  a = ethernet_mac_address_u64 (mac->bytes);
  a++;
  ethernet_mac_address_from_u64 (a, mac->bytes);
}

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */