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

Commit 63b7182

Browse files
committed
Fix up tests
1 parent 2629ab9 commit 63b7182

File tree

2 files changed

+18
-168
lines changed

2 files changed

+18
-168
lines changed

kernel/tests/s06_rackscale_tests.rs

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,6 @@ fn s06_rackscale_shmem_request_core_remote_test() {
562562
output += p
563563
.exp_string("Client finished processing core work request")?
564564
.as_str();
565-
output += p.exp_string("Client received no work.")?.as_str();
566-
output += p.exp_string("Client received no work.")?.as_str();
567-
output += p.exp_string("Client received no work.")?.as_str();
568565
p.process.exit()
569566
};
570567

@@ -604,130 +601,3 @@ fn s06_rackscale_shmem_request_core_remote_test() {
604601

605602
let _ignore = remove_file(SHMEM_PATH);
606603
}
607-
608-
#[cfg(not(feature = "baremetal"))]
609-
#[test]
610-
fn s06_rackscale_spawn_test() {
611-
use std::fs::remove_file;
612-
use std::sync::Arc;
613-
use std::thread::sleep;
614-
use std::time::Duration;
615-
616-
// Setup ivshmem file
617-
setup_shmem(SHMEM_PATH, SHMEM_SIZE);
618-
619-
setup_network(3);
620-
let timeout = 30_000;
621-
622-
const TOTAL_CLIENT_CORES: usize = 3;
623-
624-
// Create build for both controller and client
625-
let build = Arc::new(
626-
BuildArgs::default()
627-
.module("init")
628-
.user_feature("test-scheduler-smp")
629-
.kernel_feature("shmem")
630-
.kernel_feature("ethernet")
631-
.kernel_feature("rackscale")
632-
.release()
633-
.build(),
634-
);
635-
636-
// Run DCM and controller in separate thread
637-
let controller_build = build.clone();
638-
let controller = std::thread::spawn(move || {
639-
let cmdline_controller = RunnerArgs::new_with_build("userspace-smp", &controller_build)
640-
.timeout(timeout)
641-
.cmd("mode=controller transport=shmem")
642-
.shmem_size(SHMEM_SIZE as usize)
643-
.shmem_path(SHMEM_PATH)
644-
.tap("tap0")
645-
.no_network_setup()
646-
.workers(3)
647-
.use_vmxnet3();
648-
649-
let mut output = String::new();
650-
let mut qemu_run = || -> Result<WaitStatus> {
651-
let mut dcm = spawn_dcm(1, timeout)?;
652-
let mut p = spawn_nrk(&cmdline_controller)?;
653-
654-
output += p.exp_eof()?.as_str();
655-
656-
dcm.send_control('c')?;
657-
p.process.exit()
658-
};
659-
660-
let _ignore = qemu_run();
661-
});
662-
663-
sleep(Duration::from_millis(5_000));
664-
665-
// Run client in separate thead. Wait a bit to make sure DCM and controller started
666-
let client1_build = build.clone();
667-
let client = std::thread::spawn(move || {
668-
let cmdline_client = RunnerArgs::new_with_build("userspace-smp", &client1_build)
669-
.timeout(timeout)
670-
.cmd("mode=client transport=shmem")
671-
.shmem_size(SHMEM_SIZE as usize)
672-
.shmem_path(SHMEM_PATH)
673-
.tap("tap2")
674-
.no_network_setup()
675-
.workers(3)
676-
.cores(2)
677-
.memory(4096)
678-
.use_vmxnet3();
679-
680-
let mut output = String::new();
681-
let mut qemu_run = || -> Result<WaitStatus> {
682-
let mut p = spawn_nrk(&cmdline_client)?;
683-
684-
// should get two requests for two cores
685-
output += p
686-
.exp_string("Client finished processing core work request")?
687-
.as_str();
688-
output += p
689-
.exp_string("Client finished processing core work request")?
690-
.as_str();
691-
692-
p.process.exit()
693-
};
694-
sleep(Duration::from_millis(10_000));
695-
696-
let _ignore = qemu_run();
697-
});
698-
699-
// Run client in separate thead. Wait a bit to make sure DCM and controller started
700-
let client2_build = build.clone();
701-
let client2 = std::thread::spawn(move || {
702-
let cmdline_client = RunnerArgs::new_with_build("userspace-smp", &client2_build)
703-
.timeout(timeout)
704-
.cmd("mode=client transport=shmem")
705-
.shmem_size(SHMEM_SIZE as usize)
706-
.shmem_path(SHMEM_PATH)
707-
.tap("tap4")
708-
.no_network_setup()
709-
.workers(3)
710-
.nobuild() // Use build from previous client for consistency
711-
.use_vmxnet3();
712-
713-
let mut output = String::new();
714-
let mut qemu_run = || -> Result<WaitStatus> {
715-
let mut p = spawn_nrk(&cmdline_client)?;
716-
717-
for _i in 0..TOTAL_CLIENT_CORES {
718-
let r = p.exp_regex(r#"init: Hello from core (\d+)"#)?;
719-
output += r.0.as_str();
720-
output += r.1.as_str();
721-
}
722-
p.process.kill(SIGTERM)
723-
};
724-
725-
check_for_successful_exit(&cmdline_client, qemu_run(), output);
726-
});
727-
728-
controller.join().unwrap();
729-
client.join().unwrap();
730-
client2.join().unwrap();
731-
732-
let _ignore = remove_file(SHMEM_PATH);
733-
}

usr/init/src/init.rs

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -150,54 +150,34 @@ fn request_core_remote_test() {
150150
let s = &vibrio::upcalls::PROCESS_SCHEDULER;
151151

152152
let threads = vibrio::syscalls::System::threads().expect("Can't get system topology");
153-
info!("Threads are: {:?}", threads);
154153

155-
/*
156-
for thread in threads.iter() {
157-
if thread.id != 0 {
158-
let r = vibrio::syscalls::Process::request_core(
159-
thread.id,
160-
VAddr::from(vibrio::upcalls::upcall_while_enabled as *const fn() as u64),
161-
);
162-
match r {
163-
Ok(ctoken) => {
164-
info!("Spawned core on {:?} <-> {}", ctoken, thread.id);
165-
}
166-
Err(_e) => {
167-
panic!("Failed to spawn to core {}", thread.id);
168-
}
154+
// Only ask for more cores on the machine with only 1 core
155+
if threads.len() == 1 {
156+
let HW_THREAD_ID = 1;
157+
match vibrio::syscalls::Process::request_core(
158+
HW_THREAD_ID,
159+
VAddr::from(vibrio::upcalls::upcall_while_enabled as *const fn() as u64),
160+
) {
161+
Ok(_) => {
162+
info!("request_core_remote_test OK");
163+
}
164+
Err(e) => {
165+
error!("Can't spawn on {:?}: {:?}", HW_THREAD_ID, e);
169166
}
170167
}
168+
} else {
169+
// Run scheduler on core 0
170+
let scb: SchedulerControlBlock = SchedulerControlBlock::new(0);
171+
loop {
172+
s.run(&scb);
173+
}
171174
}
172-
173-
for thread in threads {
174-
s.spawn(
175-
32 * 4096,
176-
move |_| {
177-
info!(
178-
"Hello from core {}",
179-
lineup::tls2::Environment::scheduler().core_id
180-
);
181-
},
182-
ptr::null_mut(),
183-
thread.id,
184-
None,
185-
);
186-
}
187-
188-
// Run scheduler on core 0
189-
let scb: SchedulerControlBlock = SchedulerControlBlock::new(0);
190-
loop {
191-
s.run(&scb);
192-
}
193-
*/
194175
}
195176

196177
fn scheduler_smp_test() {
197178
let s = &vibrio::upcalls::PROCESS_SCHEDULER;
198179

199180
let threads = vibrio::syscalls::System::threads().expect("Can't get system topology");
200-
info!("Threads are: {:?}", threads);
201181

202182
for thread in threads.iter() {
203183
if thread.id != 0 {

0 commit comments

Comments
 (0)