コード例 #1
0
TEST(inst_suite, MOV_with_bracket)
{
     // Found MOV_with_bracket
     nask_utility::Instructions inst;

     std::istringstream input_stream0("[BITS 32]            \r\n");
     std::istringstream input_stream1("[INSTRSET \"i486p\"] \r\n");
     std::istringstream input_stream2("ECX,[ESP+4]          \r\n");
     std::istringstream input_stream3("AL,[ESP+8]           \r\n");
     TParaTokenizer tokenizer0(input_stream0, &inst.token_table);
     TParaTokenizer tokenizer1(input_stream1, &inst.token_table);
     TParaTokenizer tokenizer2(input_stream2, &inst.token_table);
     TParaTokenizer tokenizer3(input_stream3, &inst.token_table);

     std::vector<uint8_t> test;
     std::vector<uint8_t> answer = { 0x8b, 0x4c, 0x24, 0x04, 0x8a, 0x44, 0x24, 0x08 };

     inst.process_token_BRACKET(tokenizer0, test);
     inst.process_token_BRACKET(tokenizer1, test);
     inst.process_token_MOV(tokenizer2, test);
     inst.process_token_MOV(tokenizer3, test);

     logger->info("output bin: {}", nask_utility::string_to_hex(std::string(test.begin(), test.end())));

     // static member data "support" causes memory leak :<
     EXPECT_N_LEAKS(12);
     CHECK(test == answer);
}
コード例 #2
0
TEST(DeviceOpenTest, open_initializes_hardware)
{
    struct file fil;
    struct inode inode;
    int read_wait_loop;
    u32 expected_control_write_addr = tddmodule_registers_p->control;
    u32 expected_control_read_addr = tddmodule_registers_p->status;
    u32 expected_control_reset_value = TDDMODULE_DEV_CONTROL_RESET;

    EXPECT_N_LEAKS(1);

    mock(fs_mock_namespace).ignoreOtherCalls();

    initialize_module();

    mock(iomem_mock_namespace).expectOneCall("writel")
        .withParameterOfType("unsigned", "value",
            &expected_control_reset_value)
        .withParameter("addr", (void*) &tddmodule_registers_p->control);
    mock(iomem_mock_namespace).expectOneCall("mb");
    // force device to not be ready for N reads
    mock(iomem_mock_namespace).expectNCalls(5, "readl")
        .withParameter("addr", (void*) &tddmodule_registers_p->status)
        .andReturnValue(0);
    mock(iomem_mock_namespace).expectOneCall("readl")
        .withParameter("addr", (void*) &tddmodule_registers_p->status)
        .andReturnValue(1);
    tddmodule_dev_open( &inode, &fil);
}