-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGLibcStartMainContractTest.cs
51 lines (43 loc) · 1.5 KB
/
GLibcStartMainContractTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// This file is part of bugreport.
// Copyright (c) 2006-2009 The bugreport Developers.
// See AUTHORS.txt for details.
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
using System;
using NUnit.Framework;
namespace bugreport
{
[TestFixture]
public class GLibcStartMainContractTest
{
#region Setup/Teardown
[SetUp]
public void SetUp()
{
var registers = new RegisterCollection();
registers[RegisterName.ESP] = new AbstractValue(AbstractValue.GetNewBuffer(1));
state = new MachineState(registers);
contract = new GLibcStartMainContract();
}
#endregion
private GLibcStartMainContract contract;
private MachineState state;
[Test]
public void Execute()
{
var address = new AbstractValue(0xdeadbabe);
state = state.PushOntoStack(address);
state = contract.Execute(state);
Assert.AreEqual(address.Value, state.InstructionPointer);
}
[Test]
public void IsSatisified()
{
var code = new Byte[] {0xe8, 0xb7, 0xff, 0xff, 0xff};
state = new MachineState {InstructionPointer = 0x80482fc};
Assert.IsTrue(contract.IsSatisfiedBy(state, code));
state.InstructionPointer = 0xdeadbeef;
Assert.IsFalse(contract.IsSatisfiedBy(state, code));
}
}
}