Skip to content

Commit 5fe663d

Browse files
committed
chore(ci): migrate to cross-platform-actions for *BSD targets
1 parent 03fd93c commit 5fe663d

File tree

3 files changed

+34
-66
lines changed

3 files changed

+34
-66
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353

5454
steps:
5555
- name: Checkout
56-
uses: actions/checkout@v2
56+
uses: actions/checkout@v4
5757

5858
- name: Install toolchain
5959
uses: actions-rs/toolchain@v1
@@ -77,80 +77,41 @@ jobs:
7777

7878
test-qemu:
7979
name: Test (${{ matrix.target }})
80-
runs-on: ubuntu-20.04
81-
env: { SSHPASS: 12345 }
80+
runs-on: ubuntu-latest
8281
strategy:
8382
matrix:
8483
include:
8584
- target: x86_64-unknown-freebsd
86-
image: https://gitlab.com/kit-ty-kate/qemu-base-images/-/raw/master/FreeBSD-13.2-RELEASE-amd64.qcow2?inline=false
87-
md5: 33b6bc89cdc675f5cbaf92e71ae648f8
88-
args: -net nic
85+
os: freebsd
86+
os-version: '14.0'
8987
- target: x86_64-unknown-openbsd
90-
image: https://gitlab.com/kit-ty-kate/qemu-base-images/-/raw/master/OpenBSD-7.4-amd64.qcow2?inline=false
91-
md5: 1b7f3867c72f1dac3901b4a08257f580
92-
args: -net nic
88+
os: openbsd
89+
os-version: '7.4'
90+
install: sudo pkg_add rust
91+
- target: x86_64-unknown-netbsd
92+
os: netbsd
93+
os-version: '9.3'
94+
prepare:
95+
sudo pkgin -y install mozilla-rootcerts-openssl
9396
fail-fast: false
9497

9598
steps:
9699
- name: Checkout
97-
uses: actions/checkout@v2
98-
99-
- name: Install QEMU
100-
run: sudo apt-get update && sudo apt-get install -y qemu-system-x86
100+
uses: actions/checkout@v4
101101

102-
- name: Lookup image
103-
id: lookup-image
104-
uses: actions/cache@v2
102+
- name: Run tests (cargo)
103+
uses: cross-platform-actions/[email protected]
105104
with:
106-
path: ~/image.qcow2
107-
key: ${{ matrix.target }}-image
108-
109-
- name: Download image
110-
if: steps.lookup-image.outputs.cache-hit != 'true'
111-
run: |
112-
wget -O - --progress=dot:mega "${{ matrix.image }}" \
113-
| tee ~/image.qcow2 \
114-
| md5sum -c <(echo "${{ matrix.md5 }} -")
115-
116-
- name: Boot image
117-
run: |
118-
qemu-system-x86_64 -m 2048 -display none -snapshot -daemonize \
119-
-drive if=ide,media=disk,file=$HOME/image.qcow2 \
120-
-net user,hostfwd=tcp::1025-:22 \
121-
${{ matrix.args }}
122-
123-
- name: Configure SSH
124-
run: |
125-
ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa
126-
cat > ~/.ssh/config <<EOF
127-
Host qemu
128-
User root
129-
HostName localhost
130-
Port 1025
131-
EOF
132-
chmod og-rw ~
133-
parallel -t --retries 20 --delay 5 ::: 'sshpass -e ssh-copy-id -o StrictHostKeyChecking=no qemu'
134-
135-
- name: Install toolchain (rustup)
136-
if: ${{ contains(matrix.target, 'freebsd') }}
137-
run: |
138-
ssh qemu <<'EOF'
139-
pkg install -y curl
140-
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
141-
ln -s ~/.cargo/bin ~/bin
142-
EOF
143-
144-
- name: Install toolchain (pkg)
145-
if: ${{ contains(matrix.target, 'openbsd') }}
146-
run: ssh qemu "pkg_add rust"
147-
148-
- name: Copy crate
149-
run: scp -r $PWD qemu:crate
150-
151-
# TODO: Respect RUST_TEST_THREADS
152-
- name: Run tests
153-
run: ssh qemu "cd crate && cargo test"
105+
operating_system: ${{ matrix.os }}
106+
architecture: ${{ matrix.architecture || 'x86-64' }}
107+
version: ${{ matrix.os-version }}
108+
run: |
109+
${{ matrix.prepare }}
110+
${{ matrix.install || '
111+
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
112+
source "$HOME/.cargo/env"
113+
'}}
114+
cargo test
154115
155116
check:
156117
name: Check (${{ matrix.target }})

src/alloc.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,17 @@ impl Drop for Allocation {
8585
/// will be returned.
8686
/// - If size is zero, [`Error::InvalidParameter`] will be returned.
8787
///
88+
/// # OS-Specific Behavior
89+
///
90+
/// On NetBSD pages will be allocated without PaX memory protection restrictions
91+
/// (i.e. pages will be allowed to be modified to any combination of `RWX`).
92+
///
8893
/// # Examples
8994
///
9095
/// ```
9196
/// # fn main() -> region::Result<()> {
92-
/// # if cfg!(any(target_arch = "x86", target_arch = "x86_64")) && !cfg!(target_os = "openbsd") {
97+
/// # if cfg!(any(target_arch = "x86", target_arch = "x86_64"))
98+
/// # && !cfg!(any(target_os = "openbsd", target_os = "netbsd")) {
9399
/// use region::Protection;
94100
/// let ret5 = [0xB8, 0x05, 0x00, 0x00, 0x00, 0xC3u8];
95101
///

src/protect.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ use crate::{os, util, Protection, QueryIter, Region, Result};
3535
///
3636
/// ```
3737
/// # fn main() -> region::Result<()> {
38-
/// # if cfg!(any(target_arch = "x86", target_arch = "x86_64")) && !cfg!(target_os = "openbsd") {
38+
/// # if cfg!(any(target_arch = "x86", target_arch = "x86_64"))
39+
/// # && !cfg!(any(target_os = "openbsd", target_os = "netbsd")) {
3940
/// use region::Protection;
4041
/// let ret5 = [0xB8, 0x05, 0x00, 0x00, 0x00, 0xC3u8];
4142
///

0 commit comments

Comments
 (0)