예제 #1
0
void
driver_entry_ut::test_common_load_fail_due_to_no_modules_added()
{
    this->expect_true(common_load_vmm() == BF_ERROR_NO_MODULES_ADDED);
    this->expect_true(common_vmm_status() == VMM_UNLOADED);
    this->expect_true(common_fini() == BF_SUCCESS);
    this->expect_true(common_vmm_status() == VMM_UNLOADED);
}
예제 #2
0
void
driver_entry_ut::test_common_load_fail_due_to_relocation_error()
{
    this->expect_true(common_add_module(m_dummy_start_vmm_success.get(), m_dummy_start_vmm_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_stop_vmm_success.get(), m_dummy_stop_vmm_success_length) == BF_SUCCESS);
    this->expect_true(common_load_vmm() == BFELF_ERROR_NO_SUCH_SYMBOL);
    this->expect_true(common_vmm_status() == VMM_UNLOADED);
    this->expect_true(common_fini() == BF_SUCCESS);
    this->expect_true(common_vmm_status() == VMM_UNLOADED);
}
예제 #3
0
void
driver_entry_ut::test_common_load_successful_load()
{
    this->expect_true(common_add_module(m_dummy_start_vmm_success.get(), m_dummy_start_vmm_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_stop_vmm_success.get(), m_dummy_stop_vmm_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_add_md_success.get(), m_dummy_add_md_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_misc.get(), m_dummy_misc_length) == BF_SUCCESS);
    this->expect_true(common_load_vmm() == BF_SUCCESS);
    this->expect_true(common_vmm_status() == VMM_LOADED);
    this->expect_true(common_fini() == BF_SUCCESS);
    this->expect_true(common_vmm_status() == VMM_UNLOADED);
}
예제 #4
0
void
driver_entry_ut::test_common_load_load_when_already_running()
{
    this->expect_true(common_add_module(m_dummy_start_vmm_success.get(), m_dummy_start_vmm_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_stop_vmm_success.get(), m_dummy_stop_vmm_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_add_md_success.get(), m_dummy_add_md_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_misc.get(), m_dummy_misc_length) == BF_SUCCESS);
    this->expect_true(common_load_vmm() == BF_SUCCESS);
    this->expect_true(common_start_vmm() == BF_SUCCESS);
    this->expect_true(common_load_vmm() == BF_ERROR_VMM_INVALID_STATE);
    this->expect_true(common_vmm_status() == VMM_RUNNING);
    this->expect_true(common_fini() == BF_SUCCESS);
    this->expect_true(common_vmm_status() == VMM_UNLOADED);
}
void
driver_entry_ut::test_common_add_module_add_when_already_loaded()
{
    EXPECT_TRUE(common_add_module(m_dummy_add_mdl_success, m_dummy_add_mdl_success_length) == BF_SUCCESS);
    EXPECT_TRUE(common_add_module(m_dummy_misc, m_dummy_misc_length) == BF_SUCCESS);
    EXPECT_TRUE(common_load_vmm() == BF_SUCCESS);
    EXPECT_TRUE(common_vmm_status() == VMM_LOADED);
    EXPECT_TRUE(common_add_module(m_dummy_get_drr_success, m_dummy_get_drr_success_length) == BF_ERROR_VMM_INVALID_STATE);
    EXPECT_TRUE(common_fini() == BF_SUCCESS);
}
예제 #6
0
static long
ioctl_vmm_status(int64_t *status)
{
    if (status == 0)
    {
        ALERT("IOCTL_VMM_STATUS: failed with status == NULL\n");
        return BF_IOCTL_FAILURE;
    }

    *status = common_vmm_status();

    DEBUG("IOCTL_VMM_STATUS: succeeded\n");
    return BF_IOCTL_SUCCESS;
}
예제 #7
0
void
driver_entry_ut::test_common_unload_unload_when_corrupt()
{
    EXPECT_TRUE(common_add_module(m_dummy_start_vmm_success, m_dummy_start_vmm_success_length) == BF_SUCCESS);
    EXPECT_TRUE(common_add_module(m_dummy_stop_vmm_failure, m_dummy_stop_vmm_failure_length) == BF_SUCCESS);
    EXPECT_TRUE(common_add_module(m_dummy_add_md_success, m_dummy_add_md_success_length) == BF_SUCCESS);
    EXPECT_TRUE(common_add_module(m_dummy_misc, m_dummy_misc_length) == BF_SUCCESS);
    EXPECT_TRUE(common_load_vmm() == BF_SUCCESS);
    EXPECT_TRUE(common_start_vmm() == BF_SUCCESS);
    EXPECT_TRUE(common_fini() == BF_ERROR_VMM_CORRUPTED);
    EXPECT_TRUE(common_vmm_status() == VMM_CORRUPT);
    EXPECT_TRUE(common_unload_vmm() == BF_ERROR_VMM_CORRUPTED);

    common_reset();
}
예제 #8
0
void
driver_entry_ut::test_common_start_start_when_corrupt()
{
    this->expect_true(common_add_module(m_dummy_start_vmm_success.get(), m_dummy_start_vmm_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_stop_vmm_failure.get(), m_dummy_stop_vmm_failure_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_add_md_success.get(), m_dummy_add_md_success_length) == BF_SUCCESS);
    this->expect_true(common_add_module(m_dummy_misc.get(), m_dummy_misc_length) == BF_SUCCESS);
    this->expect_true(common_load_vmm() == BF_SUCCESS);
    this->expect_true(common_start_vmm() == BF_SUCCESS);
    this->expect_true(common_stop_vmm() == ENTRY_ERROR_VMM_STOP_FAILED);
    this->expect_true(common_start_vmm() == BF_ERROR_VMM_CORRUPTED);
    this->expect_true(common_vmm_status() == VMM_CORRUPT);

    common_reset();
}
예제 #9
0
static int64_t
ioctl_vmm_status(int64_t *status)
{
    int64_t vmm_status = common_vmm_status();

    if (status == 0)
    {
        ALERT("IOCTL_VMM_STATUS: common_vmm_status failed: NULL\n");
        return BF_IOCTL_FAILURE;
    }

    *status = vmm_status;

    DEBUG("IOCTL_VMM_STATUS: succeeded\n");
    return BF_IOCTL_SUCCESS;
}
예제 #10
0
static long
ioctl_vmm_status(int64_t *status)
{
    int64_t ret;
    int64_t vmm_status = common_vmm_status();

    if (status == 0)
    {
        ALERT("IOCTL_VMM_STATUS: common_vmm_status failed: NULL\n");
        return BF_IOCTL_FAILURE;
    }

    ret = copy_to_user(status, &vmm_status, sizeof(int64_t));
    if (ret != 0)
    {
        ALERT("IOCTL_VMM_STATUS: failed to copy memory from userspace\n");
        return BF_IOCTL_FAILURE;
    }

    DEBUG("IOCTL_VMM_STATUS: succeeded\n");
    return BF_IOCTL_SUCCESS;
}