Fix tests.

This commit is contained in:
4lDO2
2023-12-25 11:37:02 +01:00
parent 771fffbfd6
commit 92d45336ff
4 changed files with 14 additions and 9 deletions
+2 -1
View File
@@ -22,4 +22,5 @@ test:redox:
event
main
unnamed
#TODO: shm
shm_demo
# FIXME: shm is currently broken
+2 -2
View File
@@ -31,7 +31,7 @@ fn main() -> io::Result<()> {
event_file.read(&mut event)?;
if event.data == 0 {
println!("Listener recevied flags: {}", event.flags);
println!("Listener recevied flags: {:?}", event.flags);
if event.flags & syscall::EVENT_WRITE == syscall::EVENT_WRITE {
loop {
let stream = match syscall::dup(server.as_raw_fd() as usize, b"listen").map_err(from_syscall_error) {
@@ -52,7 +52,7 @@ fn main() -> io::Result<()> {
}
}
} else {
println!("Client #{} received flags: {}", event.data, event.flags);
println!("Client #{} received flags: {:?}", event.data, event.flags);
let client = clients.get_mut(&event.data).unwrap();
if event.flags & syscall::EVENT_READ == syscall::EVENT_READ {
+6 -2
View File
@@ -17,17 +17,21 @@ fn main() -> Result<(), io::Error> {
syscall::fmap(file1.as_raw_fd() as usize, &syscall::Map {
offset: 0,
size: 128,
flags: syscall::PROT_READ | syscall::PROT_WRITE
flags: syscall::PROT_READ | syscall::PROT_WRITE | syscall::MAP_SHARED,
address: 0,
}).map_err(from_syscall_error)? as *mut u8,
128
)
};
// FIXME: While the length can be unaligned, the offset cannot. This test is incorrectly
// written.
let two = unsafe {
slice::from_raw_parts_mut(
syscall::fmap(file2.as_raw_fd() as usize, &syscall::Map {
offset: 64,
size: 64,
flags: syscall::PROT_READ | syscall::PROT_WRITE
flags: syscall::PROT_READ | syscall::PROT_WRITE | syscall::MAP_SHARED,
address: 0,
}).map_err(from_syscall_error)? as *mut u8,
64
)
+4 -4
View File
@@ -16,15 +16,15 @@ fn main() -> Result<(), io::Error> {
let counter = unsafe {
&mut *(syscall::fmap(file.as_raw_fd() as usize, &syscall::Map {
offset: 0,
address: 0,
size: mem::size_of::<usize>(),
flags: syscall::PROT_READ | syscall::PROT_WRITE
flags: syscall::PROT_READ | syscall::PROT_WRITE | syscall::MAP_SHARED,
}).map_err(from_syscall_error)? as *mut usize)
};
println!("Read value {}", counter);
*counter += 1;
println!("Increased value to {}", counter);
loop {
thread::sleep(Duration::from_secs(std::u64::MAX));
}
thread::sleep(Duration::from_secs(1));
Ok(())
}