Skip to content

Commit

Permalink
*BSD unit tests (#4269)
Browse files Browse the repository at this point in the history
* FreeBSD 14 unit tests

* FreeBSD 14 Vagrant

* OpenBSD 7.5 unit tests
  • Loading branch information
guedou committed Jun 22, 2024
1 parent 06afa39 commit 54fc9e9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/vagrant_ci/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Vagrant.configure("2") do |config|
end

config.vm.define "freebsd" do |bsd|
bsd.vm.box = "freebsd/FreeBSD-13.1-RELEASE"
bsd.vm.box = "freebsd/FreeBSD-14.0-RELEASE"
bsd.vm.provision "shell", path: "provision_freebsd.sh"
end

Expand Down
2 changes: 1 addition & 1 deletion doc/vagrant_ci/provision_freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# See https://scapy.net/ for more information
# Copyright (C) Philippe Biondi <phil@secdev.org>

PACKAGES="git python2 python39 py39-virtualenv py39-pip py27-sqlite3 py39-sqlite3 bash rust sudo"
PACKAGES="git python39 python311 py39-virtualenv py39-pip py39-sqlite3 py311-sqlite3 bash rust sudo"

pkg update
pkg install --yes $PACKAGES
Expand Down
2 changes: 1 addition & 1 deletion scapy/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def load(filename=None):
"Couldn't load cache from %s" % str(cachepath),
exc_info=True,
)
cachepath.unlink()
cachepath.unlink(missing_ok=True)
# Cache does not exist or is invalid.
content = func(filename)
data = {
Expand Down
3 changes: 2 additions & 1 deletion test/configs/bsd.utsc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"test/contrib/automotive/ecu_am.uts",
"test/contrib/automotive/gm/gmlanutils.uts",
"test/contrib/isotp_packet.uts",
"test/contrib/isotpscan.uts"
"test/contrib/isotpscan.uts",
"test/contrib/isotp_soft_socket.uts"
],
"onlyfailed": true,
"preexec": {
Expand Down
4 changes: 2 additions & 2 deletions test/imports.uts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import subprocess
import re
import time
import sys
from scapy.consts import WINDOWS
from scapy.consts import WINDOWS, OPENBSD

# DEV: to add your file to this list, make sure you have
# a GREAT reason.
Expand Down Expand Up @@ -47,7 +47,7 @@ ALL_FILES = [
x.split(".")[1] not in EXCEPTION_PACKAGES
]

NB_PROC = 1 if WINDOWS else 4
NB_PROC = 1 if WINDOWS or OPENBSD else 4

def append_processes(processes, filename):
processes.append(
Expand Down
6 changes: 4 additions & 2 deletions test/regression.uts
Original file line number Diff line number Diff line change
Expand Up @@ -1684,10 +1684,11 @@ assert country == 'US'
def _test():
with no_debug_dissector():
x = sr1(IP(dst="www.google.com")/ICMP(),timeout=3)
assert x is not None
x
assert x[IP].ottl() in [32, 64, 128, 255]
assert 0 <= x[IP].hops() <= 126
x is not None and ICMP in x and x[ICMP].type == 0
assert ICMP in x and x[ICMP].type == 0

retry_test(_test)

Expand Down Expand Up @@ -1996,7 +1997,8 @@ retry_test(_test)
~ netaccess needs_root tcpdump
* Let's test traceroute
def _test():
ans, unans = traceroute("www.slashdot.org")
with no_debug_dissector():
ans, unans = traceroute("www.slashdot.org")
ans.nsummary()
s,r=ans[0]
s.show()
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# minversion = 4.0
skip_missing_interpreters = true
# envlist = default when doing 'tox'
envlist = py{37,38,39,310,311,312}-{linux,bsd,windows}-non_root
envlist = py{37,38,39,310,311,312}-{linux,bsd,windows}-{non_root,root}

# Main tests

Expand Down Expand Up @@ -41,7 +41,7 @@ deps = mock
zstandard ; sys_platform != 'win32'
platform =
linux: linux
bsd: darwin|freebsd|openbsd|netbsd
bsd: (darwin|freebsd|openbsd|netbsd).*
windows: win32
commands =
linux-non_root: {envpython} {env:DISABLE_COVERAGE:-m coverage run} -m scapy.tools.UTscapy -c ./test/configs/linux.utsc -N {posargs}
Expand Down

0 comments on commit 54fc9e9

Please sign in to comment.