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

Commit 1541c98

Browse files
author
cyh21
committed
replace '\n' '\r' to ' ' in judge_libctest
1 parent cfecec2 commit 1541c98

6 files changed

Lines changed: 33 additions & 38 deletions

File tree

api/src/imp/task/thread.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use axtask::{current, yield_now, TaskExtMut, TaskExtRef};
66
use macro_rules_attribute::apply;
77
use num_enum::TryFromPrimitive;
88
use starry_core::{
9-
ctypes::{WaitFlags, WaitStatus},
9+
ctypes::{WaitFlags, WaitStatus, RLimit, RLIMIT_AS, RLIMIT_NOFILE, RLIMIT_STACK},
1010
task::{exec, wait_pid},
1111
};
1212

@@ -148,12 +148,7 @@ pub fn sys_wait4(pid: i32, exit_code_ptr: UserPtr<i32>, option: u32) -> LinuxRes
148148
let exit_code_ptr = exit_code_ptr.nullable(UserPtr::get)?;
149149
info!("wait4: pid: {}, exit_code_ptr: {:?}, option: {}", pid, exit_code_ptr, option);
150150
loop {
151-
<<<<<<< HEAD:src/syscall_imp/task/thread.rs
152-
let answer = wait_pid(pid, exit_code_ptr.unwrap_or_else(ptr::null_mut));
153-
info!("wait4: answer: {:?}", answer);
154-
=======
155151
let answer = unsafe { wait_pid(pid, exit_code_ptr.unwrap_or_else(ptr::null_mut)) };
156-
>>>>>>> main:api/src/imp/task/thread.rs
157152
match answer {
158153
Ok(pid) => {
159154
return Ok(pid as isize);
@@ -292,28 +287,3 @@ pub fn sys_prlimit64(
292287
pub fn sys_gettid() -> LinuxResult<isize> {
293288
Ok(current().id().as_u64() as isize)
294289
}
295-
296-
#[apply(syscall_instrument)]
297-
pub fn sys_fork() -> LinuxResult<isize> {
298-
info!("fork");
299-
info!("transfer to clone");
300-
// let flags = 17;
301-
// let user_stack = 0;
302-
// let ptid = 0;
303-
// let arg3 = 0;
304-
// let arg4 = 0;
305-
// sys_clone(flags, user_stack, ptid, arg3, arg4)
306-
let stack = None;
307-
308-
let curr_task = current();
309-
310-
if let Ok(new_task_id) = curr_task
311-
.task_ext()
312-
.clone_task(17, stack, 0, 0, 0)
313-
{
314-
info!("fork: new_task_id: {}", new_task_id);
315-
Ok(new_task_id as isize)
316-
} else {
317-
Err(LinuxError::ENOMEM)
318-
}
319-
}

apps/oscomp/judge_libctest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
# TODO: Add more commands to test here
55
libctest_baseline = """
6+
========== START entry-static.exe argv ==========
7+
Pass!
8+
========== END entry-static.exe argv ==========
69
========== START entry-static.exe qsort ==========
710
Pass!
811
========== END entry-static.exe qsort ==========
@@ -12,11 +15,12 @@ def parse_libctest(output):
1215
ans = {}
1316
key = ""
1417
for line in output.split("\n"):
18+
line = line.replace('\n', '').replace('\r', '')
1519
if "START entry-static.exe" in line:
1620
key = "libctest static " + line.split(" ")[3]
1721
elif "START entry-dynamic.exe" in line:
1822
key = "libctest dynamic " + line.split(" ")[3]
19-
if (line == "Pass!" or line == "Pass!\r") and key != "":
23+
if (line == "Pass!") and key != "":
2024
ans[key] = 1
2125
return ans
2226

apps/oscomp/testcase_list

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/musl/basic/fork
1+
/musl/runtest.exe -w entry-static.exe argv
2+
/musl/runtest.exe -w entry-static.exe qsort

core/src/task.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ impl TaskExt {
106106
current().id_name(),
107107
axconfig::plat::KERNEL_STACK_SIZE,
108108
);
109-
109+
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
110+
unsafe {
111+
new_task.ctx_mut().set_tls(axhal::arch::read_thread_pointer().into());
112+
}
110113
let current_task = current();
111114
let mut current_aspace = current_task.task_ext().aspace.lock();
112115
let mut new_aspace = current_aspace.clone_or_err()?;
@@ -205,11 +208,11 @@ impl TaskExt {
205208
self.heap_top.store(top, Ordering::Release)
206209
}
207210

208-
pub(crate) fn get_stack_size(&self) -> u64 {
211+
pub fn get_stack_size(&self) -> u64 {
209212
self.stack_size.load(Ordering::Acquire)
210213
}
211214

212-
pub(crate) fn set_stack_size(&self, size: u64) {
215+
pub fn set_stack_size(&self, size: u64) {
213216
self.stack_size.store(size, Ordering::Release)
214217
}
215218
}

scripts/oscomp_test.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,24 @@ busybox_testlist=("/$LIBC/busybox sh /$LIBC/busybox_testcode.sh")
6969
iozone_testlist=("/$LIBC/busybox sh /$LIBC/iozone_testcode.sh")
7070
lua_testlist=("/$LIBC/busybox sh /$LIBC/lua_testcode.sh")
7171
# libctest_testlist=("/$LIBC/busybox sh /$LIBC/libctest_testcode.sh")
72-
libctest_testlist=("/musl/runtest.exe -w entry-static.exe qsort")
72+
libctest_testlist=(
73+
"/$LIBC/runtest.exe -w entry-static.exe argv"
74+
"/$LIBC/runtest.exe -w entry-static.exe qsort"
75+
# "/$LIBC/runtest.exe -w entry-static.exe memmem_oob_read"
76+
# "/$LIBC/runtest.exe -w entry-static.exe string_strchr"
77+
# "/$LIBC/runtest.exe -w entry-static.exe ungetc"
78+
# "/$LIBC/runtest.exe -w entry-static.exe statvfs_syscall_list"
79+
# "/$LIBC/runtest.exe -w entry-static.exe strtod"
80+
# "/$LIBC/runtest.exe -w entry-static.exe wcsncpy_read_overflow_syscall_list"
81+
# "/$LIBC/runtest.exe -w entry-static.exe regex_backref_0_syscall_list"
82+
# "/$LIBC/runtest.exe -w entry-static.exe sigprocmask_internal_syscall_list"
83+
# "/$LIBC/runtest.exe -w entry-static.exe setvbuf_unget_syscall_list"
84+
# "/$LIBC/runtest.exe -w entry-static.exe iswspace_null"
85+
# "/$LIBC/runtest.exe -w entry-static.exe scanf_nullbyte_char_syscall_list"
86+
# "/$LIBC/runtest.exe -w entry-static.exe memmem_oob"
87+
# "/$LIBC/runtest.exe -w entry-static.exe malloc_0"
88+
# "/$LIBC/runtest.exe -w entry-static.exe wcsstr_false_negative_syscall_list"
89+
)
7390

7491
testcases_type=(
7592
"basic"

src/syscall.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn handle_syscall(tf: &TrapFrame, syscall_num: usize) -> isize {
130130
tf.arg3().into(),
131131
),
132132
#[cfg(target_arch = "x86_64")]
133-
Sysno::fork => sys_fork(),
133+
Sysno::fork => sys_clone(17, 0, 0, 0, 0),
134134
_ => {
135135
warn!("Unimplemented syscall: {}", syscall_num);
136136
axtask::exit(LinuxError::ENOSYS as _)

0 commit comments

Comments
 (0)