Skip to content

Commit

Permalink
Add XDP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seladb committed Oct 28, 2023
1 parent 7c78331 commit d710637
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ jobs:
run: |
sudo apt update && sudo apt -y install libpcap-dev libbpf-dev
- name: Check python version
run: |
python -V
python3 -V
- name: Configure PcapPlusPlus
run: cmake -DPCAPPP_USE_XDP=ON -S . -B $BUILD_DIR

- name: Build PcapPlusPlus
run: cmake --build $BUILD_DIR -j

- name: Test PcapPlusPlus
run: |
python -m pip install -U pip
python -m pip install -r ci/run_tests/requirements.txt
python ci/run_tests/run_tests_xdp.py --interface eth0 --use-sudo
# pre-commit:
# runs-on: ubuntu-latest
# container: seladb/alpine317
Expand Down
36 changes: 36 additions & 0 deletions ci/run_tests/run_tests_xdp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
import subprocess
import argparse
import netifaces as ni

PCAP_FILE_PATH = os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap")


def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--interface", "-i", type=str, required=True, help="interface to use"
)
parser.add_argument(
"--use-sudo", "-s", action="store_true", help="use sudo when running tests"
)

args = parser.parse_args()

ip_address = ni.ifaddresses(args.interface)[ni.AF_INET][0]["addr"]
print("IP address is: %s" % ip_address)

use_sudo = ["sudo"] if args.use_sudo else []

completed_process = subprocess.run(
use_sudo
+ [os.path.join("Bin", "Pcap++Test"), "-i", ip_address, "-t", "xdp"]
+ args.test_args.split(),
cwd="Tests/Pcap++Test",
)
if completed_process.returncode != 0:
exit(completed_process.returncode)


if __name__ == "__main__":
main()

0 comments on commit d710637

Please sign in to comment.