-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add graphical shell module with integration tests and dependencies
- Loading branch information
1 parent
0e896b4
commit 692b151
Showing
7 changed files
with
201 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "Graphical_shell" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
Graphics = { path = "../../../Graphics" } | ||
File_system = { path = "../../../File_system" } | ||
Virtual_file_system = { path = "../../../Virtual_file_system" } | ||
Executable = { path = "../../../Executable" } | ||
Task = { path = "../../../Task" } | ||
Users = { path = "../../../Users" } | ||
|
||
[dev-dependencies] | ||
Drivers = { path = "../../../Drivers" } | ||
Time = { path = "../../../Time" } | ||
LittleFS = { path = "../../../LittleFS" } | ||
|
||
[[test]] | ||
name = "Integration_test" | ||
path = "Tests/Integration_test.rs" |
94 changes: 94 additions & 0 deletions
94
Modules/Executables/Shell/Graphical/Tests/Integration_test.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_snake_case)] | ||
#![allow(non_upper_case_globals)] | ||
|
||
use Executable::Standard_type; | ||
use File_system::{Create_device, Create_file_system, Memory_device_type, Mode_type}; | ||
use Graphical_shell::Shell_executable_type; | ||
|
||
#[cfg(target_os = "linux")] | ||
#[ignore] | ||
#[test] | ||
fn main() { | ||
use Drivers::Native::Window_screen; | ||
use Graphics::{Get_recommended_buffer_size, Point_type}; | ||
|
||
// - Initialize the task manager. | ||
let Task_instance = Task::Initialize().unwrap(); | ||
|
||
// - Initialize the user manager. | ||
let _ = Users::Initialize(); | ||
|
||
// - Initialize the time manager. | ||
let _ = Time::Initialize(Create_device!(Drivers::Native::Time_driver_type::New())); | ||
|
||
// - Initialize the graphics manager. | ||
|
||
const Resolution: Point_type = Point_type::New(800, 480); | ||
|
||
let (Screen_device, Pointer_device) = Window_screen::New(Resolution).unwrap(); | ||
|
||
const Buffer_size: usize = Get_recommended_buffer_size(&Resolution); | ||
|
||
Graphics::Initialize(Screen_device, Pointer_device, Buffer_size, true); | ||
|
||
// - Initialize the virtual file system. | ||
let Memory_device = Create_device!(Memory_device_type::<512>::New(1024 * 512)); | ||
|
||
LittleFS::File_system_type::Format(Memory_device.clone(), 256).unwrap(); | ||
|
||
let File_system = LittleFS::File_system_type::New(Memory_device, 256).unwrap(); | ||
|
||
Virtual_file_system::Initialize(Create_file_system!(File_system)).unwrap(); | ||
|
||
let Task = Task_instance.Get_current_task_identifier().unwrap(); | ||
|
||
Virtual_file_system::Get_instance() | ||
.Mount_static_device(Task, &"/Shell", Create_device!(Shell_executable_type)) | ||
.unwrap(); | ||
|
||
Virtual_file_system::Get_instance() | ||
.Create_directory(&"/Devices", Task) | ||
.unwrap(); | ||
|
||
Drivers::Native::Console::Mount_devices(Task, Virtual_file_system::Get_instance()).unwrap(); | ||
|
||
let Standard_in = Virtual_file_system::Get_instance() | ||
.Open(&"/Devices/Standard_in", Mode_type::Read_only.into(), Task) | ||
.unwrap(); | ||
|
||
let Standard_out = Virtual_file_system::Get_instance() | ||
.Open(&"/Devices/Standard_out", Mode_type::Write_only.into(), Task) | ||
.unwrap(); | ||
|
||
let Standard_error = Virtual_file_system::Get_instance() | ||
.Open( | ||
&"/Devices/Standard_error", | ||
Mode_type::Write_only.into(), | ||
Task, | ||
) | ||
.unwrap(); | ||
|
||
let Standard = Standard_type::New( | ||
Standard_in, | ||
Standard_out, | ||
Standard_error, | ||
Task, | ||
Virtual_file_system::Get_instance(), | ||
); | ||
|
||
Task_instance | ||
.Set_environment_variable(Task, "Paths", "/") | ||
.unwrap(); | ||
|
||
Task_instance | ||
.Set_environment_variable(Task, "Host", "xila") | ||
.unwrap(); | ||
|
||
let Result = Executable::Execute("/Shell", "".to_string(), Standard) | ||
.unwrap() | ||
.Join() | ||
.unwrap(); | ||
|
||
assert!(Result == 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use Executable::Read_data_type; | ||
use File_system::Device_trait; | ||
|
||
use crate::Main::Main; | ||
|
||
pub struct Shell_executable_type; | ||
|
||
impl Device_trait for Shell_executable_type { | ||
fn Read(&self, Buffer: &mut [u8]) -> File_system::Result_type<File_system::Size_type> { | ||
let Read_data: &mut Read_data_type = Buffer | ||
.try_into() | ||
.map_err(|_| File_system::Error_type::Invalid_parameter)?; | ||
|
||
*Read_data = Read_data_type::New(Main, 1024 * 32); | ||
|
||
Ok(size_of::<Read_data_type>().into()) | ||
} | ||
|
||
fn Write(&self, _: &[u8]) -> File_system::Result_type<File_system::Size_type> { | ||
Err(File_system::Error_type::Unsupported_operation) | ||
} | ||
|
||
fn Get_size(&self) -> File_system::Result_type<File_system::Size_type> { | ||
Err(File_system::Error_type::Unsupported_operation) | ||
} | ||
|
||
fn Set_position( | ||
&self, | ||
_: &File_system::Position_type, | ||
) -> File_system::Result_type<File_system::Size_type> { | ||
Err(File_system::Error_type::Unsupported_operation) | ||
} | ||
|
||
fn Flush(&self) -> File_system::Result_type<()> { | ||
Err(File_system::Error_type::Unsupported_operation) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use core::num::NonZeroUsize; | ||
|
||
use Executable::Standard_type; | ||
|
||
use crate::Shell_type; | ||
|
||
pub fn Main(Standard: Standard_type, Arguments: String) -> Result<(), NonZeroUsize> { | ||
Shell_type::New(Standard).Main(Arguments) | ||
} | ||
|
||
impl Shell_type { | ||
pub fn New(Standard: Standard_type) -> Self { | ||
let User: String = "".to_string(); | ||
|
||
Self { | ||
Standard, | ||
User, | ||
Running: true, | ||
} | ||
} | ||
|
||
pub fn Main(&mut self, Arguments: String) -> Result<(), NonZeroUsize> { | ||
self.Standard.Print_line("Hello, World!"); | ||
|
||
let Window = Graphics::Get_instance().Create_window(); | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_snake_case)] | ||
#![allow(non_upper_case_globals)] | ||
|
||
use Executable::Standard_type; | ||
|
||
mod Desk; | ||
mod Device; | ||
mod Main; | ||
|
||
pub use Device::*; | ||
|
||
pub struct Shell_type { | ||
Standard: Standard_type, | ||
User: String, | ||
Running: bool, | ||
} |