Skip to content

Commit a03e6a9

Browse files
committed
Add unit tests
1 parent 61b4e30 commit a03e6a9

File tree

8 files changed

+147
-639
lines changed

8 files changed

+147
-639
lines changed

.github/check_spdx.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
# This file is part of Scapy RPC
5+
# See https://scapy.net/ for more information
6+
7+
# Check that all Scapy RPC files have a SPDX
8+
9+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
10+
ROOT_DIR=$SCRIPT_DIR/..
11+
12+
# http://mywiki.wooledge.org/BashFAQ/024
13+
# This documents an absolutely WTF behavior of bash.
14+
set +m
15+
shopt -s lastpipe
16+
17+
function check_path() {
18+
cd $ROOT_DIR
19+
RCODE=0
20+
for ext in "${@:2}"; do
21+
find $1 -name "*.$ext" | while read f; do
22+
if [[ -z $(grep "SPDX" $f) ]]; then
23+
echo "$f"
24+
RCODE=1
25+
fi
26+
done
27+
done
28+
return $RCODE
29+
}
30+
31+
check_path midl-to-scapy py || exit $?
32+
check_path scapy-rpc py || exit $?

.github/workflows/unittests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Scapy RPC unit tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [master]
9+
10+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: ${{ !contains(github.ref, 'master')}}
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
health:
20+
name: Code health check
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout Scapy-rpc
24+
uses: actions/checkout@v4
25+
- name: Setup Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.13"
29+
- name: Check black compliance
30+
uses: psf/black@stable
31+
- name: Run twine check
32+
run: tox -e twine
33+
spdx:
34+
name: Check SPDX identifiers
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout Scapy
38+
uses: actions/checkout@v4
39+
- name: Launch script
40+
run: bash .github/check_spdx.sh

midl-to-scapy/idl/idl_scraper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"extras": [
4343
# Protocols not listed in the "list"
4444
"ms-oxcrpc",
45-
]
45+
],
4646
},
4747
{
4848
"name": "SharePoint Protocols",

scapy-rpc/msrpcs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def scapy_ext(plg):
1313
plg.config("Scapy RPC", __version__)
14-
for lay in pathlib.Path(__file__).parent.glob('*.py'):
14+
for lay in pathlib.Path(__file__).parent.glob("*.py"):
1515
if lay.name == "__init__.py":
1616
continue
1717
plg.register(

0 commit comments

Comments
 (0)