From 9d1c59b65da02aa6f66b628f26ebe885807f9dff Mon Sep 17 00:00:00 2001 From: koniifer Date: Wed, 27 Nov 2024 12:41:51 +0000 Subject: [PATCH] consolidate simple tests, bug revealed --- sysdata/libraries/stn/src/lib.hb | 1 + sysdata/programs/alloc_test/README.md | 1 - sysdata/programs/alloc_test/meta.toml | 11 ---------- sysdata/programs/dt_buffer_test/README.md | 1 - sysdata/programs/dt_buffer_test/src/main.hb | 13 ------------ sysdata/programs/hash_test/meta.toml | 11 ---------- sysdata/programs/processes/meta.toml | 11 ---------- sysdata/programs/serial_driver_test/meta.toml | 11 ---------- .../programs/serial_driver_test/src/main.hb | 20 ------------------ .../{dt_buffer_test => test}/meta.toml | 4 ++-- sysdata/programs/test/src/main.hb | 7 ++++++ .../programs/test/src/tests/serial_driver.hb | 18 ++++++++++++++++ .../src/tests/stn/allocators.hb} | 6 +++--- .../tests/stn/assets}/hello_world_and_spin.hb | 0 .../stn/assets}/hello_world_and_spin.hbf | Bin sysdata/programs/test/src/tests/stn/dt.hb | 18 ++++++++++++++++ .../main.hb => test/src/tests/stn/hashers.hb} | 5 +++-- sysdata/programs/test/src/tests/stn/lib.hb | 5 +++++ .../main.hb => test/src/tests/stn/process.hb} | 7 +++--- sysdata/programs/test/src/tests/stn/sleep.hb | 8 +++++++ sysdata/programs/timer_test/meta.toml | 11 ---------- sysdata/programs/timer_test/src/main.hb | 8 ------- sysdata/system_config.toml | 10 ++------- 23 files changed, 71 insertions(+), 116 deletions(-) delete mode 100644 sysdata/programs/alloc_test/README.md delete mode 100644 sysdata/programs/alloc_test/meta.toml delete mode 100644 sysdata/programs/dt_buffer_test/README.md delete mode 100644 sysdata/programs/dt_buffer_test/src/main.hb delete mode 100644 sysdata/programs/hash_test/meta.toml delete mode 100644 sysdata/programs/processes/meta.toml delete mode 100644 sysdata/programs/serial_driver_test/meta.toml delete mode 100644 sysdata/programs/serial_driver_test/src/main.hb rename sysdata/programs/{dt_buffer_test => test}/meta.toml (73%) create mode 100644 sysdata/programs/test/src/main.hb create mode 100644 sysdata/programs/test/src/tests/serial_driver.hb rename sysdata/programs/{alloc_test/src/main.hb => test/src/tests/stn/allocators.hb} (87%) rename sysdata/programs/{processes/src => test/src/tests/stn/assets}/hello_world_and_spin.hb (100%) rename sysdata/programs/{processes/src => test/src/tests/stn/assets}/hello_world_and_spin.hbf (100%) create mode 100644 sysdata/programs/test/src/tests/stn/dt.hb rename sysdata/programs/{hash_test/src/main.hb => test/src/tests/stn/hashers.hb} (87%) create mode 100644 sysdata/programs/test/src/tests/stn/lib.hb rename sysdata/programs/{processes/src/main.hb => test/src/tests/stn/process.hb} (61%) create mode 100644 sysdata/programs/test/src/tests/stn/sleep.hb delete mode 100644 sysdata/programs/timer_test/meta.toml delete mode 100644 sysdata/programs/timer_test/src/main.hb diff --git a/sysdata/libraries/stn/src/lib.hb b/sysdata/libraries/stn/src/lib.hb index dc6494e..9391917 100644 --- a/sysdata/libraries/stn/src/lib.hb +++ b/sysdata/libraries/stn/src/lib.hb @@ -10,6 +10,7 @@ random := @use("random.hb") file := @use("file_io.hb") dt := @use("dt.hb") process := @use("process.hb") +sleep := @use("sleep.hb") panic := fn(message: ?^u8): never { log.error("Error: Panic Called, Message:\0") diff --git a/sysdata/programs/alloc_test/README.md b/sysdata/programs/alloc_test/README.md deleted file mode 100644 index 5608194..0000000 --- a/sysdata/programs/alloc_test/README.md +++ /dev/null @@ -1 +0,0 @@ -# alloc_test \ No newline at end of file diff --git a/sysdata/programs/alloc_test/meta.toml b/sysdata/programs/alloc_test/meta.toml deleted file mode 100644 index aa77119..0000000 --- a/sysdata/programs/alloc_test/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "alloc_test" -authors = [""] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/dt_buffer_test/README.md b/sysdata/programs/dt_buffer_test/README.md deleted file mode 100644 index c01a7c5..0000000 --- a/sysdata/programs/dt_buffer_test/README.md +++ /dev/null @@ -1 +0,0 @@ -# dt_buffer_test \ No newline at end of file diff --git a/sysdata/programs/dt_buffer_test/src/main.hb b/sysdata/programs/dt_buffer_test/src/main.hb deleted file mode 100644 index 7d37f6a..0000000 --- a/sysdata/programs/dt_buffer_test/src/main.hb +++ /dev/null @@ -1,13 +0,0 @@ -.{dt} := @use("../../../libraries/stn/src/lib.hb") - -main := fn(): void { - dt.get(void, "framebuffer/fb0/width\0") - dt.get(void, "cpu/cpu0/architecture\0") - - // Checking if the first detected serial port is memory mapped or port mapped - // 0 -> memory mapped - // 1 -> port mapped - dt.get(void, "serial_ports/sp0/mapping\0") - - return -} \ No newline at end of file diff --git a/sysdata/programs/hash_test/meta.toml b/sysdata/programs/hash_test/meta.toml deleted file mode 100644 index fc157f1..0000000 --- a/sysdata/programs/hash_test/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "hash_test" -authors = [""] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/processes/meta.toml b/sysdata/programs/processes/meta.toml deleted file mode 100644 index 86a4869..0000000 --- a/sysdata/programs/processes/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "processes" -authors = ["koniifer"] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/serial_driver_test/meta.toml b/sysdata/programs/serial_driver_test/meta.toml deleted file mode 100644 index f8f995c..0000000 --- a/sysdata/programs/serial_driver_test/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "serial_driver_test" -authors = ["able"] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/serial_driver_test/src/main.hb b/sysdata/programs/serial_driver_test/src/main.hb deleted file mode 100644 index 19ad6c1..0000000 --- a/sysdata/programs/serial_driver_test/src/main.hb +++ /dev/null @@ -1,20 +0,0 @@ -.{string, buffer} := @use("../../../libraries/stn/src/lib.hb") - -log_info := fn(): void { - a := buffer.search("XNumber\0") - if a == 0 { - } else { - msg := "XABC\0" - // inline is broked - // msg_length := @inline(string.length, msg) - msg_length := 5 - @as(void, @eca(3, a, msg, msg_length)) - } - - return -} - -main := fn(): int { - log_info() - return 0 -} \ No newline at end of file diff --git a/sysdata/programs/dt_buffer_test/meta.toml b/sysdata/programs/test/meta.toml similarity index 73% rename from sysdata/programs/dt_buffer_test/meta.toml rename to sysdata/programs/test/meta.toml index f25002e..93c3dd7 100644 --- a/sysdata/programs/dt_buffer_test/meta.toml +++ b/sysdata/programs/test/meta.toml @@ -1,6 +1,6 @@ [package] -name = "dt_buffer_test" -authors = ["able"] +name = "test" +authors = ["koniifer", "able"] [dependants.libraries] diff --git a/sysdata/programs/test/src/main.hb b/sysdata/programs/test/src/main.hb new file mode 100644 index 0000000..3b3bc21 --- /dev/null +++ b/sysdata/programs/test/src/main.hb @@ -0,0 +1,7 @@ +stn := @use("./tests/stn/lib.hb") +serial_driver := @use("./tests/serial_driver.hb") + +main := fn(): uint { + // return serial_driver.test() + return stn.process.test() +} \ No newline at end of file diff --git a/sysdata/programs/test/src/tests/serial_driver.hb b/sysdata/programs/test/src/tests/serial_driver.hb new file mode 100644 index 0000000..8e27b11 --- /dev/null +++ b/sysdata/programs/test/src/tests/serial_driver.hb @@ -0,0 +1,18 @@ +.{string, buffer} := @use("../../../../libraries/stn/src/lib.hb") + +log_info := fn(): void { + a := buffer.search("XNumber\0") + if a == 0 { + } else { + msg := "XABC\0" + msg_length := string.length(msg) + @eca(3, a, msg, msg_length) + } + + return +} + +test := fn(): uint { + log_info() + return 0 +} \ No newline at end of file diff --git a/sysdata/programs/alloc_test/src/main.hb b/sysdata/programs/test/src/tests/stn/allocators.hb similarity index 87% rename from sysdata/programs/alloc_test/src/main.hb rename to sysdata/programs/test/src/tests/stn/allocators.hb index 250ecea..8b194b7 100644 --- a/sysdata/programs/alloc_test/src/main.hb +++ b/sysdata/programs/test/src/tests/stn/allocators.hb @@ -1,11 +1,11 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("../../../../../libraries/stn/src/lib.hb"); .{allocators, panic, log} := stn AStruct := struct { a_field: u8, } -main := fn(): void { +test := fn(): uint { // alloc := allocators.FakeAlloc.init() // astruct := alloc.alloc(AStruct, 2) // if astruct.ptr != null{ @@ -26,5 +26,5 @@ main := fn(): void { // log.info("Allocator functioned.\0") // } // balloc.dealloc(bstruct_ptr, AStruct, 2) - return + return 0 } \ No newline at end of file diff --git a/sysdata/programs/processes/src/hello_world_and_spin.hb b/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hb similarity index 100% rename from sysdata/programs/processes/src/hello_world_and_spin.hb rename to sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hb diff --git a/sysdata/programs/processes/src/hello_world_and_spin.hbf b/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hbf similarity index 100% rename from sysdata/programs/processes/src/hello_world_and_spin.hbf rename to sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hbf diff --git a/sysdata/programs/test/src/tests/stn/dt.hb b/sysdata/programs/test/src/tests/stn/dt.hb new file mode 100644 index 0000000..e331f33 --- /dev/null +++ b/sysdata/programs/test/src/tests/stn/dt.hb @@ -0,0 +1,18 @@ +.{dt, memory, string, log} := @use("../../../../../libraries/stn/src/lib.hb") + +test := fn(): uint { + buffer := memory.request_page(1) + + log.info(string.display_int(dt.get(int, "framebuffer/fb0/width\0"), buffer, 10)) + string.clear(buffer) + + log.info(string.display_int(dt.get(int, "cpu/cpu0/architecture\0"), buffer, 10)) + string.clear(buffer) + + // 0 -> memory mapped + // 1 -> port mapped + + log.info(string.display_int(dt.get(int, "serial_ports/sp0/mapping\0"), buffer, 10)) + + return 0 +} \ No newline at end of file diff --git a/sysdata/programs/hash_test/src/main.hb b/sysdata/programs/test/src/tests/stn/hashers.hb similarity index 87% rename from sysdata/programs/hash_test/src/main.hb rename to sysdata/programs/test/src/tests/stn/hashers.hb index 0840541..a1052d6 100644 --- a/sysdata/programs/hash_test/src/main.hb +++ b/sysdata/programs/test/src/tests/stn/hashers.hb @@ -1,6 +1,6 @@ -.{hashers, log, memory, string} := @use("../../../libraries/stn/src/lib.hb") +.{hashers, log, memory, string} := @use("../../../../../libraries/stn/src/lib.hb") -main := fn(): void { +test := fn(): uint { buffer := memory.request_page(1) target := "abcdefghijklmnop\0" strings := [^u8].("abcdefshijklmnop\0", "abcdefghijklnnop\0", "abcdefshijklmnop\0", "abcdefghijklmnop\0", "abcdefghijflmnop\0", "dbcdefghijklmnop\0", "abcdefghijklmnop\0") @@ -28,4 +28,5 @@ main := fn(): void { log.debug(string.display_int(@bitcast(d), buffer, 16)) string.clear(buffer) } + return 0 } \ No newline at end of file diff --git a/sysdata/programs/test/src/tests/stn/lib.hb b/sysdata/programs/test/src/tests/stn/lib.hb new file mode 100644 index 0000000..da08b77 --- /dev/null +++ b/sysdata/programs/test/src/tests/stn/lib.hb @@ -0,0 +1,5 @@ +hashers := @use("./hashers.hb") +allocators := @use("./allocators.hb") +sleep := @use("./sleep.hb") +dt := @use("./dt.hb") +process := @use("./process.hb") \ No newline at end of file diff --git a/sysdata/programs/processes/src/main.hb b/sysdata/programs/test/src/tests/stn/process.hb similarity index 61% rename from sysdata/programs/processes/src/main.hb rename to sysdata/programs/test/src/tests/stn/process.hb index 06b4ade..493e36a 100644 --- a/sysdata/programs/processes/src/main.hb +++ b/sysdata/programs/test/src/tests/stn/process.hb @@ -1,8 +1,8 @@ -.{process, log, string, memory} := @use("../../../libraries/stn/src/lib.hb") +.{process, log, string, memory} := @use("../../../../../libraries/stn/src/lib.hb") -exe := @embed("./hello_world_and_spin.hbf") +exe := @embed("./assets/hello_world_and_spin.hbf") -main := fn(): void { +test := fn(): uint { buf := "\0\0\0\0\0\0\0" loop { log.info( @@ -16,4 +16,5 @@ main := fn(): void { i := 0 loop if i == 1000000 break else i += 1 } + return 0 } \ No newline at end of file diff --git a/sysdata/programs/test/src/tests/stn/sleep.hb b/sysdata/programs/test/src/tests/stn/sleep.hb new file mode 100644 index 0000000..9eaeb31 --- /dev/null +++ b/sysdata/programs/test/src/tests/stn/sleep.hb @@ -0,0 +1,8 @@ +.{sleep, log} := @use("../../../../../libraries/stn/src/lib.hb") + +test := fn(): uint { + log.info("BEFORE\0") + sleep.sleep_until_interrupt(32) + log.info("AFTER\0") + return 0 +} \ No newline at end of file diff --git a/sysdata/programs/timer_test/meta.toml b/sysdata/programs/timer_test/meta.toml deleted file mode 100644 index c05908d..0000000 --- a/sysdata/programs/timer_test/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "timer_test" -authors = ["Talha Qamar"] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/timer_test/src/main.hb b/sysdata/programs/timer_test/src/main.hb deleted file mode 100644 index a491de4..0000000 --- a/sysdata/programs/timer_test/src/main.hb +++ /dev/null @@ -1,8 +0,0 @@ -sleep := @use("../../../libraries/stn/src/sleep.hb") -log := @use("../../../libraries/stn/src/log.hb") - -main := fn(): void { - log.info("BEFORE\0") - sleep.sleep_until_interrupt(32) - log.info("AFTER\0") -} \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 34ab790..72445ba 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -34,9 +34,6 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf" -[boot.limine.ableos.modules.timer_test] -path = "boot:///timer_test.hbf" - # [boot.limine.ableos.modules.sunset_client] # path = "boot:///sunset_client.hbf" # @@ -52,8 +49,5 @@ path = "boot:///timer_test.hbf" # [boot.limine.ableos.modules.pcspkr] # path = "boot:///pcspkr.hbf" -# [boot.limine.ableos.modules.alloc_test] -# path = "boot:///alloc_test.hbf" - -# [boot.limine.ableos.modules.hash_test] -# path = "boot:///hash_test.hbf" +[boot.limine.ableos.modules.test] +path = "boot:///test.hbf"