forked from chipsec/chipsec
-
Notifications
You must be signed in to change notification settings - Fork 0
255 lines (216 loc) · 10 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: Run tests
on: [push, pull_request]
jobs:
build-linux-km:
name: Linux kernel module
strategy:
matrix:
distro:
- {name: "alpine", tag: "3.18", variant: "-lts", image_prefix: "docker.io/library/"}
- {name: "alpine", tag: "3.17", variant: "-lts", image_prefix: "docker.io/library/"}
- {name: "alpine", tag: "3.16", variant: "-lts", image_prefix: "docker.io/library/"}
- {name: "alpine", tag: "3.15", variant: "-lts", image_prefix: "docker.io/library/"}
- {name: "alpine", tag: "3.14", variant: "-lts", image_prefix: "docker.io/library/"}
- {name: "archlinux", tag: "latest", image_prefix: "docker.io/library/"}
- {name: "archlinux", tag: "latest", variant: "-lts", image_prefix: "docker.io/library/"}
- {name: "archlinux", tag: "latest", variant: "-zen", image_prefix: "docker.io/library/"}
- {name: "archlinux", tag: "base", image_prefix: "docker.io/library/"}
- {name: "centos", tag: "stream9", image_prefix: "quay.io/centos/"}
- {name: "centos", tag: "stream8", image_prefix: "quay.io/centos/"}
- {name: "centos", tag: "7", image_prefix: "quay.io/centos/"}
- {name: "debian", tag: "bookworm-slim", image_prefix: "docker.io/library/"}
- {name: "debian", tag: "11", image_prefix: "docker.io/library/"}
- {name: "debian", tag: "10", image_prefix: "docker.io/library/"}
- {name: "ubuntu", tag: "23.04", image_prefix: "docker.io/library/"}
- {name: "ubuntu", tag: "22.04", image_prefix: "docker.io/library/"}
- {name: "ubuntu", tag: "20.04", image_prefix: "docker.io/library/"}
- {name: "ubuntu", tag: "18.04", image_prefix: "docker.io/library/"}
- {name: "ubuntu", tag: "16.04", image_prefix: "docker.io/library/"}
runs-on: ubuntu-22.04
container:
image: docker://${{ matrix.distro.image_prefix }}${{ matrix.distro.name }}:${{ matrix.distro.tag }}
steps:
- uses: actions/checkout@v3
- name: Install Alpine dependencies
if: matrix.distro.name == 'alpine'
run: |
apk --no-cache --update add linux${{ matrix.distro.variant }} linux${{ matrix.distro.variant }}-dev nasm
# DKMS is not yet packaged in Alpine
apk --no-cache --update add bash gcc git make
git clone --depth=1 --branch=v3.0.5 https://github.com/dell/dkms /opt/dkms
make -C /opt/dkms install
- name: Install Arch Linux dependencies
if: matrix.distro.name == 'archlinux'
run: |
pacman -Syu --noconfirm dkms linux${{ matrix.distro.variant }}-headers nasm
- name: Install CentOS dependencies
if: matrix.distro.name == 'centos'
run: |
if [ "${{ matrix.distro.tag }}" = 7 ] ; then
yum install -y kernel kernel-devel nasm
yum install -y elfutils-libelf-devel gcc git make
elif [ "${{ matrix.distro.tag }}" = stream8 ] ; then
dnf install -y --enablerepo=powertools kernel kernel-devel nasm
dnf install -y elfutils-libelf-devel gcc git make
elif [ "${{ matrix.distro.tag }}" = stream9 ] ; then
dnf install -y --enablerepo=crb kernel kernel-devel nasm
dnf install -y elfutils-libelf-devel gcc git make
fi
# DKMS is not longer packaged in CentOS Stream
if ! command -v dkms > /dev/null 2>&1 ; then
git clone --depth=1 --branch=v3.0.5 https://github.com/dell/dkms /opt/dkms
make -C /opt/dkms install
fi
- name: Install Debian dependencies
if: matrix.distro.name == 'debian'
run: |
apt-get update -q
apt-get install -qqy dkms nasm
- name: Install Ubuntu dependencies
if: matrix.distro.name == 'ubuntu'
run: |
apt-get update -q
apt-get install -qqy dkms linux-headers-generic nasm
- name: Compute packaged kernel version
id: versions
run: |
KERNEL_VER=''
if [ "${{ matrix.distro.name }}" = alpine ] ; then
# Parse "lib/modules/5.15.53-0-lts/build"
KERNEL_VER="$(apk info --contents "linux${{ matrix.distro.variant }}-dev" | sed -n 's:^lib/modules/\([^/][^/]*\)/.*:\1:p' | head -n 1)"
elif [ "${{ matrix.distro.name }}" = archlinux ] ; then
# Parse "/usr/lib/modules/5.18.0-arch1-1/build/"
KERNEL_VER="$(pacman -Qql "linux${{ matrix.distro.variant }}-headers" | sed -n 's:^/usr/lib/modules/\([^/]\+\)/.*:\1:p' | head -n 1)"
elif [ "${{ matrix.distro.name }}" = centos ] ; then
# Parse "Source RPM : kernel-3.10.0-1160.71.1.el7.src.rpm"
KERNEL_VER="$(LANG=C rpm -qi kernel-devel | sed -n 's/^Source RPM *: kernel-\(.*\).src.rpm$/\1.x86_64/p' | tail -n 1)"
elif [ "${{ matrix.distro.name }}" = debian ] ; then
# Parse "Depends: linux-headers-5.10.0-15-amd64 (= 5.10.120-1)"
KERNEL_VER="$(LANG=C dpkg --status linux-headers-amd64 | sed -n 's/^Depends: linux-headers-\(\S*\)\( .*\)\?$/\1/p' | head -n 1)"
elif [ "${{ matrix.distro.name }}" = ubuntu ] ; then
# Parse "Depends: linux-headers-5.15.0-40-generic"
KERNEL_VER="$(LANG=C dpkg --status linux-headers-generic | sed -n 's/^Depends: linux-headers-\(\S*\)\( .*\)\?$/\1/p' | head -n 1)"
fi
if [ -z "${KERNEL_VER}" ] ; then
echo >&2 "Error: no kernel package found"
exit 1
fi
echo "Found packaged kernel ${KERNEL_VER}"
echo "KERNEL_VER=${KERNEL_VER}" >> "$GITHUB_ENV"
CHIPSEC_MODULE_VER="$(cat chipsec/VERSION)"
echo "CHIPSEC_MODULE_VER=${CHIPSEC_MODULE_VER}" >> "$GITHUB_ENV"
echo "kernel=${KERNEL_VER}" >> "$GITHUB_OUTPUT"
echo "chipsec=${CHIPSEC_MODULE_VER}" >> "$GITHUB_OUTPUT"
echo "uname_m=$(uname -m)" >> "$GITHUB_OUTPUT"
- name: Build Linux driver with DKMS for ${{ steps.versions.outputs.kernel }}
run: |
echo "Building chipsec ${CHIPSEC_MODULE_VER} for Linux kernel ${KERNEL_VER}"
dkms add drivers/linux
dkms install -m chipsec -v "${CHIPSEC_MODULE_VER}" -k "${KERNEL_VER}"
- name: Show dkms status
run: dkms status
- name: Show modinfo on the kernel module
id: modinfo
run: |
MODULE="$(ls -1 "/var/lib/dkms/chipsec/${CHIPSEC_MODULE_VER}/${KERNEL_VER}/$(uname -m)/module/chipsec.ko"* | head -n1)"
echo "module_path=${MODULE}" >> "$GITHUB_OUTPUT"
modinfo "${MODULE}"
- name: Upload Linux driver from ${{ steps.modinfo.outputs.module_path }}
uses: actions/upload-artifact@v3
with:
name: chipsec-${{ steps.versions.outputs.chipsec }}.${{ matrix.distro.name }}-${{ matrix.distro.tag }}${{ matrix.distro.variant }}-${{ steps.versions.outputs.kernel }}.${{ steps.versions.outputs.uname_m }}
path: ${{ steps.modinfo.outputs.module_path }}
if-no-files-found: error
windows-driver:
name: Windows driver
runs-on: windows-2019
strategy:
matrix:
python:
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- "3.7"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
shell: bash
run: pip install -r windows_requirements.txt
- name: Build Windows driver
shell: bash
run: python3 setup.py build_ext -i
- name: Upload Windows Main driver
uses: actions/upload-artifact@v3
with:
name: drivers_windows_x64__from_py${{ matrix.python }}
path: drivers/windows/chipsec/x64
if-no-files-found: error
- name: Upload Windows PCI Filter driver
uses: actions/upload-artifact@v3
with:
name: drivers_windows_x64__from_py${{ matrix.python }}
path: drivers/windows/pcifilter/x64
if-no-files-found: error
- name: Run Python tests
shell: bash
run: python -m unittest
ubuntu-test:
name: Test on Ubuntu
strategy:
matrix:
versions:
- {ubuntu: "22.04", python: "3.11"}
- {ubuntu: "22.04", python: "3.10"}
- {ubuntu: "22.04", python: "3.9"}
- {ubuntu: "22.04", python: "3.8"}
- {ubuntu: "22.04", python: "3.7"}
- {ubuntu: "20.04", python: "3.11"}
- {ubuntu: "20.04", python: "3.10"}
- {ubuntu: "20.04", python: "3.9"}
- {ubuntu: "20.04", python: "3.8"}
- {ubuntu: "20.04", python: "3.7"}
runs-on: ubuntu-${{ matrix.versions.ubuntu }}
steps:
- name: Set up Python ${{ matrix.versions.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.versions.python }}
- uses: actions/checkout@v3
- name: Patch chipsec_main to return true even when some module failed
run: |
sed 's/^ return modules_failed$/ return 0/' -i chipsec_main.py
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -qqy dkms nasm python3-setuptools
pip install distro
pip install -r linux_requirements.txt
sudo pip install -r linux_requirements.txt
- name: Build the driver with Python
run: python3 setup.py build_ext -i
- name: Build the driver with DKMS
run: |
KERNEL_VER="$(uname -r)"
CHIPSEC_MODULE_VER="$(cat chipsec/VERSION)"
echo "Building chipsec ${CHIPSEC_MODULE_VER} for Linux kernel ${KERNEL_VER}"
sudo dkms add drivers/linux
sudo dkms install -m chipsec -v "${CHIPSEC_MODULE_VER}" -k "${KERNEL_VER}"
- name: Run Python tests
run: |
python3 -m unittest
python3 tests/cfg_checker.py
- name: pylint pilot for modules folder
run: |
pylint chipsec/modules
- name: Install chipsec
run: sudo python3 setup.py install
- name: Run chipsec_main
run: |
PYTHONEXE="$(which python)"
CHIPSECEXIT="$($(sudo ${PYTHONEXE} chipsec_main.py -p PMC_I440FX 1>&2); echo $?)"
if echo "0 1 2 4 8" | grep -qw $CHIPSECEXIT; then $(exit 0); else $(exit $CHIPSECEXIT); fi