Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit 7c1014e

Browse files
committed
[doc] simplify the command and improved oscomp related README
1 parent 5603008 commit 7c1014e

File tree

4 files changed

+182
-28
lines changed

4 files changed

+182
-28
lines changed

Makefile

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ else
3333
$(error ARCH must be one of x86_64, aarch64, riscv64, loongarch64)
3434
endif
3535

36-
all:
37-
# Build for os competition
38-
RUSTUP_TOOLCHAIN=nightly-2025-01-18 $(MAKE) test_build ARCH=riscv64 AX_TESTCASE=oscomp BUS=mmio FEATURES=lwext4_rs
39-
RUSTUP_TOOLCHAIN=nightly-2025-01-18 $(MAKE) test_build ARCH=loongarch64 AX_TESTCASE=oscomp FEATURES=lwext4_rs
36+
include scripts/make/oscomp.mk
37+
38+
all: oscomp_build
4039

4140
# export dummy config for clippy
4241
clippy: defconfig
@@ -55,21 +54,9 @@ user_apps:
5554
fi
5655
@mv ./disk.img $(AX_ROOT)/disk.img
5756

58-
test:
57+
test: defconfig
5958
@./scripts/app_test.sh
6059

61-
oscomp_test:
62-
@./scripts/oscomp_test.sh
63-
64-
test_build: ax_root defconfig
65-
@cp -r $(PWD)/bin/* /root/.cargo/bin
66-
@make -C $(AX_ROOT) A=$(PWD) EXTRA_CONFIG=$(EXTRA_CONFIG) build
67-
@if [ "$(ARCH)" = "riscv64" ]; then \
68-
cp $(OUT_BIN) kernel-rv; \
69-
else \
70-
cp $(OUT_ELF) kernel-la; \
71-
fi
72-
7360
defconfig build run justrun debug disasm: ax_root
7461
@make -C $(AX_ROOT) A=$(PWD) EXTRA_CONFIG=$(EXTRA_CONFIG) $@
7562

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,26 @@ Note: Arguments like `NET`, `BLK`, and `GRAPHIC` enable devices in QEMU, which t
142142

143143
## Test for oscomp testcases
144144

145-
We can run [testcases of the OS competition](https://github.com/oscomp/testsuits-for-oskernel/tree/pre-2025) with StarryOS. Guidence can be found in [Starry-Tutorial](https://azure-stars.github.io/Starry-Tutorial-Book/ch01-04.html#在-os-比赛上测试-starry).
145+
We can run [testcases of the OS competition](https://github.com/oscomp/testsuits-for-oskernel/tree/pre-2025) with StarryOS. Guidence can be found in [Starry-Tutorial](https://azure-stars.github.io/Starry-Tutorial-Book/ch03-02.html).
146+
147+
148+
And you can run the testcases with the following commands:
149+
150+
```bash
151+
# Clone the base repository
152+
./scripts/get_deps.sh
153+
154+
# run the testcases of oscomp on x86_64
155+
$ make oscomp_run ARCH=x86_64 # If it reports an error: -accel kvm: failed to initialize kvm: Permission denied, please add `ACCEL=n` argument.
156+
157+
# run the testcases of oscomp on riscv64
158+
$ make oscomp_run ARCH=riscv64
159+
160+
# run the testcases of oscomp on aarch64
161+
$ make oscomp_run ARCH=aarch64
162+
163+
# run the testcases of oscomp on loongarch64
164+
$ make oscomp_run ARCH=loongarch64
165+
```
166+
167+
To run more testcases from oscomp, you can refer to the [oscomp README](./apps/oscomp/README.md).

apps/oscomp/README.md

Lines changed: 120 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,131 @@ musl/basic/exit
1414
Then Starry will find `musl/basic/brk` from the sdcard images.And the working directory in the sdcard is default `/`.
1515

1616
## Judge scripts
17+
1718
Files like `judge_**.py` are the scripts that judge whether the output of the kernel is correct or not. The format ot the scripts can be seen at [judge](https://github.com/Azure-stars/oskernel-testsuits-cooperation/tree/master/judge).
1819

1920
When run `make oscomp_test` in the root directory, the testcases in the `testcase_list` will be run and the result will be shown in the terminal. And these scripts will be run to judge whether the output is correct or not.
2021

2122
## How to add new testcases
2223

23-
1. Enable testcases in the `judge_**.py` script. You can find `TODO` fields in the script and add the new testcases in the corresponding place. The format of the command can be seen in [judge](https://github.com/Azure-stars/oskernel-testsuits-cooperation/tree/master/judge).
24+
### Add basic testcases
25+
26+
If we want to add `write` testcase, then we need:
27+
28+
1. Enable testcases in the [judge_basic.py](./judge_basic.py)。An example is that if the `target_testcase` in [judge_basic.py](./judge_basic.py) is below:
29+
30+
```sh
31+
target_testcases = [
32+
"test_brk",
33+
"test_chdir",
34+
"test_execve",
35+
"test_pipe",
36+
]
37+
```
38+
39+
Then we need to enable `write` testcase by rewriting it as
40+
41+
```sh
42+
target_testcases = [
43+
"test_brk",
44+
"test_chdir",
45+
"test_execve",
46+
"test_pipe",
47+
"test_write",
48+
]
49+
```
50+
51+
2. Add the testcase in the [oscomp_test.sh](../../scripts/oscomp_test.sh)。An example is that if the `basic_testlist` in [oscomp_test.sh](../../scripts/oscomp_test.sh) is below:
52+
53+
```sh
54+
# TODO: add more basic testcases
55+
basic_testlist=(
56+
"/$LIBC/basic/brk"
57+
"/$LIBC/basic/chdir"
58+
"/$LIBC/basic/clone" # add the new testcase here
59+
)
60+
```
61+
62+
Then we need to enable `write` testcase by rewriting it as
63+
64+
```sh
65+
# TODO: add more basic testcases
66+
basic_testlist=(
67+
"/$LIBC/basic/brk"
68+
"/$LIBC/basic/chdir"
69+
"/$LIBC/basic/clone"
70+
"/$LIBC/basic/write"
71+
)
72+
```
73+
74+
### Add libc testcases
75+
76+
The standard of the [judge_libctest.py](./judge_libctest.py) can be seen at [judge-std](https://github.com/Azure-stars/oskernel-testsuits-cooperation/tree/master/judge/judge_libctest.py).
77+
78+
If we want to add `entry-static.exe basename` testcase, and the `libctest_baseline` in the [judge_libctest.py](./judge_libctest.py) is as below:
79+
80+
```python
81+
libctest_baseline = """
82+
========== START entry-static.exe argv ==========
83+
Pass!
84+
========== END entry-static.exe argv ==========
85+
"""
86+
```
87+
88+
Then we need to enable `entry-static.exe basename` testcase by rewriting it as
89+
90+
```python
91+
libctest_baseline = """
92+
========== START entry-static.exe argv ==========
93+
Pass!
94+
========== END entry-static.exe argv ==========
95+
========== START entry-static.exe basename ==========
96+
Pass!
97+
========== END entry-static.exe basename ==========
98+
"""
99+
```
100+
101+
That is, we **append the instructions or results used in the evaluation** to the script.
102+
103+
### Add busybox testcases
104+
105+
The standard of the [judge_busybox.py](./judge_busybox.py) can be seen at [judge-std](https://github.com/Azure-stars/oskernel-testsuits-cooperation/tree/master/judge/judge_busybox.py).
106+
107+
If we want to add `echo "#### independent command test"` testcase, and the `busybox_baseline` in the [judge_busybox.py](./judge_busybox.py) is as below:
108+
109+
```python
110+
cmd = """"""
111+
```
112+
113+
Then we need to enable `echo "#### independent command test"` testcase by rewriting it as
114+
115+
```python
116+
cmd = """
117+
echo "#### independent command test"
118+
"""
119+
```
120+
121+
### Add lua testcases
122+
123+
The standard of the [judge_lua.py](./judge_lua.py) can be seen at [judge-std](https://github.com/Azure-stars/oskernel-testsuits-cooperation/tree/master/judge/judge_lua.py).
124+
125+
If we want to add `max_min.lua` testcase, and the `cmd` in the [judge_lua.py](./judge_lua.py) is as below:
126+
127+
```python
128+
cmds = """"""
129+
```
130+
131+
Then we need to enable `max_min.lua` testcase by rewriting it as
132+
133+
```python
134+
cmds = """
135+
max_min.lua
136+
"""
137+
```
138+
139+
140+
### About iozone testcases
24141

25-
2. If the testcase belongs to `basic`, you need to add it in the `./scripts/oscomp_test.sh`. You can find `TODO` fields in the script and add the new testcases in the corresponding place. An example to add `clone` testcases are shown below:
142+
IOZONE is a special testcase, and the standard of the [judge_iozone.py](./judge_iozone.py) can be seen at [judge-std](https://github.com/Azure-stars/oskernel-testsuits-cooperation/tree/master/judge/judge_iozone.py).It measures both correctness and performance.
26143

27-
```shell
28-
# TODO: add more basic testcases
29-
basic_testlist=(
30-
"/$LIBC/basic/brk"
31-
"/$LIBC/basic/chdir"
32-
"/$LIBC/basic/clone" # add the new testcase here
33-
)
34-
```
144+
So we will directly enable all its subtest cases by rewriting `iozone_baseline` in the [judge_iozone.py](./judge_iozone.py) to that in the [judge-std](https://github.com/Azure-stars/oskernel-testsuits-cooperation/tree/master/judge/judge_iozone.py).

scripts/make/oscomp.mk

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Command to build and run testcases for oscomp
2+
3+
oscomp_binary: ax_root defconfig
4+
@cp -r $(PWD)/bin/* /root/.cargo/bin
5+
@make -C $(AX_ROOT) A=$(PWD) EXTRA_CONFIG=$(EXTRA_CONFIG) build
6+
@if [ "$(ARCH)" = "riscv64" ]; then \
7+
cp $(OUT_BIN) kernel-rv; \
8+
else \
9+
cp $(OUT_ELF) kernel-la; \
10+
fi
11+
12+
oscomp_build:
13+
# Build for os competition
14+
RUSTUP_TOOLCHAIN=nightly-2025-01-18 $(MAKE) oscomp_binary ARCH=riscv64 AX_TESTCASE=oscomp BUS=mmio FEATURES=lwext4_rs
15+
RUSTUP_TOOLCHAIN=nightly-2025-01-18 $(MAKE) oscomp_binary ARCH=loongarch64 AX_TESTCASE=oscomp FEATURES=lwext4_rs
16+
17+
oscomp_test: defconfig
18+
# Test for os competition online
19+
@./scripts/oscomp_test.sh
20+
21+
IMG_URL := https://github.com/Azure-stars/testsuits-for-oskernel/releases/download/v0.1/sdcard-$(ARCH).img.gz
22+
23+
define load_img
24+
@if [ ! -f $(PWD)/sdcard-$(ARCH).img ]; then \
25+
wget $(IMG_URL); \
26+
gunzip $(PWD)/sdcard-$(ARCH).img.gz; \
27+
fi
28+
cp $(PWD)/sdcard-$(ARCH).img $(AX_ROOT)/disk.img
29+
endef
30+
31+
oscomp_run: ax_root defconfig
32+
$(call load_img)
33+
$(MAKE) ARCH=$(ARCH) EXTRA_CONFIG=$(EXTRA_CONFIG) AX_TESTCASE=oscomp BLK=y NET=y FEATURES=fp_simd,lwext4_rs LOG=off run
34+
35+
.PHONY: oscomp_binary oscomp_build oscomp_test oscomp_run

0 commit comments

Comments
 (0)