当前位置: 首页>>代码示例>>C++>>正文


C++ MockRepository::OnCall方法代码示例

本文整理汇总了C++中MockRepository::OnCall方法的典型用法代码示例。如果您正苦于以下问题:C++ MockRepository::OnCall方法的具体用法?C++ MockRepository::OnCall怎么用?C++ MockRepository::OnCall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MockRepository的用法示例。


在下文中一共展示了MockRepository::OnCall方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: vmxon

void
vmxon_ut::test_stop_vmxoff_check_failure()
{
    MockRepository mocks;
    auto in = bfn::mock_shared<intrinsics_intel_x64>(mocks);
    auto intrinsics = in.get();
    auto l_mm = bfn::mock_shared<memory_manager>(mocks);
    mm = l_mm.get();

    // execute_vmxoff
    mocks.OnCall(intrinsics, intrinsics_intel_x64::vmxoff).Return(true);

    // disable_vmx_operation
    Call &cr4_0 = mocks.ExpectCall(intrinsics, intrinsics_intel_x64::read_cr4).Return(0);
    mocks.OnCall(intrinsics, intrinsics_intel_x64::write_cr4).Do(stubbed_write_cr4);

    // is_vmx_operation_enabled
    mocks.ExpectCall(intrinsics, intrinsics_intel_x64::read_cr4).After(cr4_0).Return(CR4_VMXE_VMX_ENABLE_BIT);

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        vmxon_intel_x64 vmxon(in);

        EXPECT_EXCEPTION(vmxon.stop(), bfn::vmxon_failure_error);
    });
}
开发者ID:kallolpar,项目名称:hypervisor,代码行数:26,代码来源:test_vmxon_intel_x64.cpp

示例2:

void
entry_ut::test_stop_vmm_success()
{
    MockRepository mocks;
    auto vcm = mocks.Mock<vcpu_manager>();
    mocks.OnCallFunc(vcpu_manager::instance).Return(vcm);

    mocks.OnCall(vcm, vcpu_manager::hlt_vcpu);
    mocks.OnCall(vcm, vcpu_manager::delete_vcpu);

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        EXPECT_NO_EXCEPTION(stop_vmm(0));
    });
}
开发者ID:kallolpar,项目名称:hypervisor,代码行数:15,代码来源:test_entry.cpp

示例3: vmm

void
vmm_ut::test_verify_ia32_vmx_cr4_fixed_msr_success()
{
    MockRepository mocks;
    intrinsics_intel_x64 *intrinsics = mocks.Mock<intrinsics_intel_x64>();

    vmm_intel_x64 vmm(intrinsics);

    mocks.OnCall(intrinsics, intrinsics_intel_x64::read_cr4).Return(0x1);
    mocks.OnCall(intrinsics, intrinsics_intel_x64::read_msr).With(IA32_VMX_CR4_FIXED0_MSR).Return(0x1);
    mocks.OnCall(intrinsics, intrinsics_intel_x64::read_msr).With(IA32_VMX_CR4_FIXED1_MSR).Return(0xFFFFFFFFFFFFFFF7);

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        EXPECT_TRUE(vmm.verify_ia32_vmx_cr4_fixed_msr() == vmm_error::success);
    });
}
开发者ID:ainfosec,项目名称:hypervisor,代码行数:17,代码来源:test_vmm_intel_x64.cpp

示例4:

static auto
setup_mm(MockRepository &mocks)
{
    auto descriptor_list =
    {
        memory_descriptor{0x12345000, 0x54321000, MEMORY_TYPE_R | MEMORY_TYPE_W},
        memory_descriptor{0x12346000, 0x54322000, MEMORY_TYPE_R | MEMORY_TYPE_E},
        memory_descriptor{0xDEADBEEF, 0xDEADBEEF, 0}
    };

    auto mm = mocks.Mock<memory_manager_x64>();
    mocks.OnCallFunc(memory_manager_x64::instance).Return(mm);

    mocks.OnCall(mm, memory_manager_x64::descriptors).Return(descriptor_list);
    mocks.OnCall(mm, memory_manager_x64::virtptr_to_physint).Return(0x0000000ABCDEF0000);
    mocks.OnCall(mm, memory_manager_x64::add_md);
    mocks.OnCall(mm, memory_manager_x64::remove_md);

    return mm;
}
开发者ID:rianquinn,项目名称:hypervisor,代码行数:20,代码来源:test_root_page_table_x64.cpp

示例5:

void
entry_ut::test_init_vmm_throws_standard_exception()
{
    MockRepository mocks;
    auto vcm = mocks.Mock<vcpu_manager>();
    mocks.OnCallFunc(vcpu_manager::instance).Return(vcm);

    mocks.OnCall(vcm, vcpu_manager::init).Throw(std::exception());

    RUN_UNITTEST_WITH_MOCKS(mocks, [&]
    {
        EXPECT_NO_EXCEPTION(init_vmm(0));
    });
}
开发者ID:shlomif,项目名称:hypervisor,代码行数:14,代码来源:test_entry.cpp


注:本文中的MockRepository::OnCall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。