Beispiel #1
0
/**
 * Output the message to a file...
 */
int tprintf(const char *format, ...) {
    va_list vl;
    va_start(vl, format);
    tvprintf(format, vl);
    va_end(vl);

    return 0;
}
Beispiel #2
0
int
test_nameserv_lib(void)
{
    test_start("nameserv lib");
    nameserv_state_t ns;
    nameserv_init(&ns, test_nameserv_callback_freecap);
    int error;

    error = nameserv_add(&ns, "hello_test", 0x12345);
    test_assert(error == ESUCCESS);
    error = nameserv_add(&ns, "kitty_test", 0x12345);
    test_assert(error == ESUCCESS);
    error = nameserv_add(&ns, "foo_test", 0x12345);
    test_assert(error == ESUCCESS);

    int n;
    seL4_CPtr anonCap = 0;

    /* Test path end case. */
    n = nameserv_resolve(&ns, "hello.txt", NULL);
    test_assert(n == REFOS_NAMESERV_RESOLVED);
    anonCap = 0;

    /* Test path resolve cases. */

    n = nameserv_resolve(&ns, "hello_test/hello.txt", &anonCap);
    tvprintf("nameserv_resolve n0 %d\n", n);
    test_assert(n == 10);
    test_assert(anonCap == 0x12345);

    anonCap = 0;
    n = nameserv_resolve(&ns, "hello_test/hi/bye/hello_foo.txt", &anonCap);
    tvprintf("nameserv_resolve n1 %d\n", n);
    test_assert(n == 10);
    test_assert(anonCap == 0x12345);

    anonCap = 0;
    n = nameserv_resolve(&ns, "/kitty_test/hi/bye/hello_foo.txt", &anonCap);
    tvprintf("nameserv_resolve n2 %d\n", n);
    test_assert(n == 11);
    test_assert(anonCap == 0x12345);

    /* Test no resolvation cases. */
    n = nameserv_resolve(&ns, "food_test/bye/foo.txt", NULL);
    test_assert(n == 0);
    n = nameserv_resolve(&ns, "", NULL);
    test_assert(n == 0);
    n = nameserv_resolve(&ns, NULL, NULL);
    test_assert(n == 0);

    /* Test deletion. */
    nameserv_delete(&ns, "asd_bogus");
    nameserv_delete(&ns, "foo_test");
    nameserv_delete(&ns, "hello_test");

    /* Test that we cannot find the deleted names any more. */
    n = nameserv_resolve(&ns, "hello_test/hello.txt", NULL);
    test_assert(n == 0);
    n = nameserv_resolve(&ns, "foo_test/", NULL);
    test_assert(n == 0);
    anonCap = 0;

    /* Test that we can still get the undeleted name. */
    n = nameserv_resolve(&ns, "kitty_test/hi/bye/hello_foo.txt", &anonCap);
    test_assert(n == 10);
    test_assert(anonCap == 0x12345);

    nameserv_release(&ns);
    return test_success();
}
Beispiel #3
0
int
test_vspace_mapping(void)
{
    test_start("vspace mapping");

    /* Create a vspace for testing mapping. */
    struct vs_vspace vs;
    int error = vs_initialise(&vs, 31337);
    test_assert(error == ESUCCESS);
    test_assert(vs.magic == REFOS_VSPACE_MAGIC);

    /* Create a memory segment window. */
    const vaddr_t window = 0x10000;
    const vaddr_t windowSize = 0x8000;
    int windowID;
    error = vs_create_window(&vs, window, windowSize, W_PERMISSION_WRITE | W_PERMISSION_READ,
            true, &windowID);
    test_assert(error == ESUCCESS);
    test_assert(windowID != W_INVALID_WINID);

    /* Allocate a frame to map. */
    vka_object_t frame;
    error = vka_alloc_frame(&procServ.vka, seL4_PageBits, &frame);
    test_assert(error == ESUCCESS);
    test_assert(frame.cptr != 0);

    /* Try to map in some invalid spots. */
    tvprintf("trying mapping into invalid spots...\n");
    error = vs_map(&vs, 0x9A0, &frame.cptr, 1);
    test_assert(error == EINVALIDWINDOW);
    error = vs_map(&vs, window - 0x9A0, &frame.cptr, 1);
    test_assert(error == EINVALIDWINDOW);
    error = vs_map(&vs, window + windowSize + 0x1, &frame.cptr, 1);
    test_assert(error == EINVALIDWINDOW);
    error = vs_map(&vs, window + windowSize + 0x5123, &frame.cptr, 1);
    test_assert(error == EINVALIDWINDOW);

    /* Try to unmap from some invalid spots. */
    tvprintf("trying unmapping from invalid spots...\n");
    error = vs_unmap(&vs, window - 0x9A0, 1);
    test_assert(error == EINVALIDWINDOW);
    error = vs_unmap(&vs, window + windowSize + 0x423, 5);
    test_assert(error == EINVALIDWINDOW);
    error = vs_unmap(&vs, window, windowSize + 1);
    test_assert(error == EINVALIDWINDOW);

    /* Map the frame many times in all the valid spots. */
    for (vaddr_t waddr = window; waddr < window + windowSize; waddr += (1 << seL4_PageBits)) {
        tvprintf("trying mapping into valid spot 0x%x...\n", (uint32_t) waddr);
        /* Map the frame. */
        error = vs_map(&vs, waddr, &frame.cptr, 1);
        test_assert(error == ESUCCESS);
        /* Try to map frame here again. Should complain. */
        error = vs_map(&vs, waddr, &frame.cptr, 1);
        test_assert(error == EUNMAPFIRST);
    }

    /* Unmap and remap the frame many times in all the valid spots. */
    for (vaddr_t waddr = window; waddr < window + windowSize; waddr += (1 << seL4_PageBits)) {
        tvprintf("trying remapping into valid spot 0x%x...\n", (uint32_t) waddr);
        /* Unmap the frame. */
        error = vs_unmap(&vs, waddr, 1);
        test_assert(error == ESUCCESS);
        /* Remap the frame. */
        error = vs_map(&vs, waddr, &frame.cptr, 1);
        test_assert(error == ESUCCESS);
    }

    /* Clean up. Note that deleting the vspace should delete the created window. */
    tvprintf("cleaning up everything in vspace...\n");
    vs_unref(&vs);
    test_assert(vs.magic != REFOS_VSPACE_MAGIC);
    vka_free_object(&procServ.vka, &frame);

    return test_success();
}