aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/ktests/region2/test.c11
-rw-r--r--src/tests/utests/fs1/test.c3
2 files changed, 12 insertions, 2 deletions
diff --git a/src/tests/ktests/region2/test.c b/src/tests/ktests/region2/test.c
index 24908b0..232bd12 100644
--- a/src/tests/ktests/region2/test.c
+++ b/src/tests/ktests/region2/test.c
@@ -1,10 +1,19 @@
+void pf_allocate_on_demand(pagedir_t *pd, struct region_info *r, void* addr) {
+ ASSERT(pd_get_frame(addr) == 0); // if error is of another type (RO, protected), we don't do anyting
+
+ uint32_t f = frame_alloc(1);
+ if (f == 0) PANIC("Out Of Memory");
+ bool map_ok = pd_map_page(addr, f, 1);
+ if (!map_ok) PANIC("Could not map frame (OOM)");
+}
+
void test_region_2() {
BEGIN_TEST("region-test-2");
// allocate a big region and try to write into it
const size_t n = 200;
- void* p0 = region_alloc(n * PAGE_SIZE, "Test big region", default_allocator_pf_handler);
+ void* p0 = region_alloc(n * PAGE_SIZE, "Test big region", pf_allocate_on_demand);
for (size_t i = 0; i < n; i++) {
uint32_t *x = (uint32_t*)(p0 + i * PAGE_SIZE);
x[0] = 12;
diff --git a/src/tests/utests/fs1/test.c b/src/tests/utests/fs1/test.c
index 7d6afd6..bab4d07 100644
--- a/src/tests/utests/fs1/test.c
+++ b/src/tests/utests/fs1/test.c
@@ -12,7 +12,8 @@ int main(int argc, char **argv) {
dbg_printf("openned /: %d\n", f);
ASSERT(f != 0);
dirent_t x;
- while (readdir(f, &x)) {
+ size_t ent_no = 0;
+ while (readdir(f, ent_no++, &x)) {
dbg_printf("- '%s' %p %d\n", x.name, x.st.type, x.st.size);
if (x.st.type == FT_REGULAR) {
char buf[256];