aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/src/main.cpp57
1 files changed, 33 insertions, 24 deletions
diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp
index 1043c81..3ba240d 100644
--- a/kernel/src/main.cpp
+++ b/kernel/src/main.cpp
@@ -19,7 +19,6 @@
#include <algorithm>
#include <cstddef>
-#include <cstdint>
auto test_device_names() -> void
{
@@ -51,17 +50,8 @@ auto test_file_description_manually() -> void
kstd::vector<std::byte> buffer{2};
auto number_of_read_bytes = fd->read(buffer.data(), buffer.size());
-
- for (size_t i = 0; i < number_of_read_bytes; ++i)
- {
- kstd::print("{:02x} ", static_cast<uint8_t>(buffer[i]));
-
- if ((i + 1) % 16 == 0)
- {
- kstd::println("");
- }
- }
- kstd::println("---");
+ kstd::println("read bytes: {}", number_of_read_bytes);
+ kstd::println("buffer: {::#04x}", buffer);
// write half of the file new
auto const value1 = std::byte{0xAA};
@@ -85,17 +75,8 @@ auto test_file_description_manually() -> void
kstd::vector<std::byte> buffer1{4};
number_of_read_bytes = fd1->read(buffer1.data(), buffer1.size());
-
- for (size_t i = 0; i < number_of_read_bytes; ++i)
- {
- kstd::print("{:02x} ", static_cast<uint8_t>(buffer1[i]));
-
- if ((i + 1) % 16 == 0)
- {
- kstd::println("");
- }
- }
- kstd::println("---");
+ kstd::println("read bytes: {}", number_of_read_bytes);
+ kstd::println("buffer: {::#04x}", buffer1);
}
auto test_device_with_vfs() -> void
@@ -103,14 +84,41 @@ auto test_device_with_vfs() -> void
// TODO BA-FS26
auto vfs = filesystem::vfs::get();
- vfs.open("/");
+ auto ofd = vfs.open("/dev/ram0");
+ if (!ofd)
+ {
+ kstd::os::panic("test code failed");
+ }
+
+ auto fd_table = filesystem::file_descriptor_table::get();
+ auto fd = fd_table.add_file(ofd);
+ kstd::vector<std::byte> buffer{2};
+ auto file = fd_table.get_file(fd);
+ if (!file)
+ {
+ kstd::os::panic("test code failed");
+ }
+
+ auto number_of_read_bytes = file->read(buffer.data(), buffer.size());
+ kstd::println("read bytes: {}", number_of_read_bytes);
+ kstd::println("buffer: {::#04x}", buffer);
}
auto run_test_code() -> void
{
+ kstd::println("[TEST] Running test code...");
+
+ kstd::println("[TEST] device names");
test_device_names();
+ kstd::println("---------------------------------");
+
+ kstd::println("[TEST] file description manually");
test_file_description_manually();
+ kstd::println("---------------------------------");
+
+ kstd::println("[TEST] device with VFS");
test_device_with_vfs();
+ kstd::println("---------------------------------");
}
auto main() -> int
@@ -136,6 +144,7 @@ auto main() -> int
kstd::println("[OS] Virtual filesystem initialized.");
run_test_code();
+ kstd::println("[TEST] All tests completed.");
kapi::system::panic("Returning from kernel main!");
}