diff options
| author | guopeixu <[email protected]> | 2022-11-22 13:49:33 +0800 |
|---|---|---|
| committer | guopeixu <[email protected]> | 2022-11-22 13:49:33 +0800 |
| commit | 6f9be1d44acf0542cd2e30e7aee38c86dba4c207 (patch) | |
| tree | fc7b273fc9595565c4d2fc33b11bc95495ca91d6 | |
| parent | 1ba7813f8db2c0ec08b6c6a26bf228668086605c (diff) | |
feat(TSG-12795): ptf单元测试
| -rw-r--r-- | .gitlab-ci.yml | 38 | ||||
| -rwxr-xr-x | tools/ptf_mrzcpd/test.py | 39 |
2 files changed, 77 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae5d2a4..5808016 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,6 +6,7 @@ variables: stages: - build - package +- test - deploy .build_before_script: @@ -239,3 +240,40 @@ testing-package-release-for-centos8: +ptf_test_mrzcpd_for_centos7: + stage: test + image: $BUILD_IMAGE_CENTOS7 + extends: .build_before_script + script: + - cd ~ + - git clone https://github.com/p4lang/ptf.git + - cd ./ptf + - python3 setup.py install + - pip3 install -r requirements.txt + - pip3 install scapy==2.4.5 + - pip3 install -r requirements-dev.txt + - cp /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX/$CI_PROJECT_PATH/tools/ptf_mrzcpd ./ -rf + - python3 ./ptf --test-dir ./ptf_mrzcpd --interface 0-1@lo + tags: + - share + + +ptf_test_mrzcpd_for_centos8: + stage: test + image: $BUILD_IMAGE_CENTOS8 + extends: .build_before_script + script: + - cd ~ + - git clone https://github.com/p4lang/ptf.git + - cd ./ptf + - python3 setup.py install + - pip3 install -r requirements.txt + - pip3 install scapy==2.4.5 + - pip3 install -r requirements-dev.txt + - cp /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX/$CI_PROJECT_PATH/tools/ptf_mrzcpd ./ -rf + - python3 ./ptf --test-dir ./ptf_mrzcpd --interface 0-1@lo + tags: + - share + + + diff --git a/tools/ptf_mrzcpd/test.py b/tools/ptf_mrzcpd/test.py new file mode 100755 index 0000000..de44dbc --- /dev/null +++ b/tools/ptf_mrzcpd/test.py @@ -0,0 +1,39 @@ +import ptf +from ptf.base_tests import BaseTest +from ptf.mask import Mask +from ptf import config +import ptf.testutils as testutils + +class DataplaneBaseTest(BaseTest): + def __init__(self): + BaseTest.__init__(self) + + def setUp(self): + self.dataplane = ptf.dataplane_instance + self.dataplane.flush() + if config["log_dir"] != None: + filename = os.path.join(config["log_dir"], str(self)) + ".pcap" + self.dataplane.start_pcap(filename) + + def tearDown(self): + if config["log_dir"] != None: + self.dataplane.stop_pcap() + +class SimpleTcpPacketTest(DataplaneBaseTest): + def __init__(self): + DataplaneBaseTest.__init__(self) + def setUp(self): + self.dataplane = ptf.dataplane_instance + print() + print("im in setup") + def tearDown(self): + print("im in teardown") + def runTest(self): + print("im in runtest") + pktlen = 400 + pkt = testutils.simple_tcp_packet(pktlen=pktlen) + self.assertEqual(len(pkt), pktlen) + testutils.send_packet(self, (0, 1), pkt) + print("packet sent") + #testutils.verify_packet(self, pkt, (1, 1)) + #testutils.verify_no_other_packets(self, 1) |
