Skip to content

Commit 8ab9760

Browse files
committed
Update examples and ci
1 parent db8a646 commit 8ab9760

File tree

6 files changed

+31
-2
lines changed

6 files changed

+31
-2
lines changed

.github/workflows/ci.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ jobs:
156156
# Run
157157
- run: ${{ env.BUILD_DIR }}usr/gen_init_cpio .github/workflows/qemu-initramfs.desc > qemu-initramfs.img
158158

159-
- run: qemu-system-${{ env.QEMU_ARCH }} -kernel ${{ env.BUILD_DIR }}${{ env.IMAGE_PATH }} -initrd qemu-initramfs.img -M ${{ env.QEMU_MACHINE }} -cpu ${{ env.QEMU_CPU }} -smp 2 -nographic -no-reboot -append '${{ env.QEMU_APPEND }} rust_example.my_i32=123321 rust_example.my_str=🦀mod rust_example_2.my_i32=234432' | tee qemu-stdout.log
159+
- run: qemu-system-${{ env.QEMU_ARCH }} -kernel ${{ env.BUILD_DIR }}${{ env.IMAGE_PATH }} -initrd qemu-initramfs.img -M ${{ env.QEMU_MACHINE }} -cpu ${{ env.QEMU_CPU }} -smp 2 -nographic -no-reboot -append '${{ env.QEMU_APPEND }} rust_example.my_i32=123321 rust_example.my_str=🦀mod rust_example_2.my_i32=234432 rust_example_2.my_array=1,2,3' | tee qemu-stdout.log
160160

161161
# Check
162162
- run: grep -F '] Rust Example (init)' qemu-stdout.log
@@ -179,6 +179,11 @@ jobs:
179179
- run: "grep '\\] \\[3\\] my_str: 🦀mod\\s*$' qemu-stdout.log"
180180
- run: "grep '\\] \\[4\\] my_str: default str val\\s*$' qemu-stdout.log"
181181

182+
- run: "grep -F '] my_array: [0, 1]' qemu-stdout.log"
183+
- run: "grep -F '] [2] my_array: [1, 2, 3]' qemu-stdout.log"
184+
- run: "grep -F '] [3] my_array: [0, 1]' qemu-stdout.log"
185+
- run: "grep -F '] [4] my_array: [1, 2, 3]' qemu-stdout.log"
186+
182187
- run: grep -F '] [3] Rust Example (exit)' qemu-stdout.log
183188
- run: grep -F '] [4] Rust Example (exit)' qemu-stdout.log
184189

.github/workflows/qemu-init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
busybox insmod rust_example_3.ko my_i32=345543 my_str=🦀mod
4-
busybox insmod rust_example_4.ko my_i32=456654 my_usize=84
4+
busybox insmod rust_example_4.ko my_i32=456654 my_usize=84 my_array=1,2,3
55
busybox rmmod rust_example_3.ko
66
busybox rmmod rust_example_4.ko
77

drivers/char/rust_example.rs

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ module! {
4343
permissions: 0o644,
4444
description: b"Example of usize",
4545
},
46+
my_array: ArrayParam<i32, 3> {
47+
default: [0, 1],
48+
permissions: 0,
49+
description: b"Example of array",
50+
},
4651
},
4752
}
4853

@@ -77,6 +82,7 @@ impl KernelModule for RustExample {
7782
core::str::from_utf8(my_str.read(&lock))?
7883
);
7984
println!(" my_usize: {}", my_usize.read(&lock));
85+
println!(" my_array: {:?}", my_array.read());
8086
}
8187

8288
// Test mutexes.

drivers/char/rust_example_2.rs

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ module! {
3333
permissions: 0o644,
3434
description: b"Example of usize",
3535
},
36+
my_array: ArrayParam<i32, 3> {
37+
default: [0, 1],
38+
permissions: 0,
39+
description: b"Example of array",
40+
},
3641
},
3742
}
3843

@@ -54,6 +59,7 @@ impl KernelModule for RustExample2 {
5459
core::str::from_utf8(my_str.read(&lock))?
5560
);
5661
println!("[2] my_usize: {}", my_usize.read(&lock));
62+
println!("[2] my_array: {:?}", my_array.read());
5763
}
5864

5965
// Including this large variable on the stack will trigger

drivers/char/rust_example_3.rs

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ module! {
3333
permissions: 0o644,
3434
description: b"Example of usize",
3535
},
36+
my_array: ArrayParam<i32, 3> {
37+
default: [0, 1],
38+
permissions: 0,
39+
description: b"Example of array",
40+
},
3641
},
3742
}
3843

@@ -54,6 +59,7 @@ impl KernelModule for RustExample3 {
5459
core::str::from_utf8(my_str.read(&lock))?
5560
);
5661
println!("[3] my_usize: {}", my_usize.read(&lock));
62+
println!("[3] my_array: {:?}", my_array.read());
5763
}
5864

5965
// Including this large variable on the stack will trigger

drivers/char/rust_example_4.rs

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ module! {
3333
permissions: 0o644,
3434
description: b"Example of usize",
3535
},
36+
my_array: ArrayParam<i32, 3> {
37+
default: [0, 1],
38+
permissions: 0,
39+
description: b"Example of array",
40+
},
3641
},
3742
}
3843

@@ -54,6 +59,7 @@ impl KernelModule for RustExample4 {
5459
core::str::from_utf8(my_str.read(&lock))?
5560
);
5661
println!("[4] my_usize: {}", my_usize.read(&lock));
62+
println!("[4] my_array: {:?}", my_array.read());
5763
}
5864

5965
// Including this large variable on the stack will trigger

0 commit comments

Comments
 (0)