1import angr
2
3import logging
4l = logging.getLogger("angr.tests")
5
6import os
7test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'binaries', 'tests')
8
9target_arches = {
10    #'i386',
11    'x86_64',
12    #'ppc',
13    #'armel',
14    #'mips',
15}
16
17def run_echo_haha(arch):
18    p = angr.Project(os.path.join(test_location, arch, 'echo'), use_sim_procedures=False)
19    s = p.factory.full_init_state(mode='symbolic_approximating', args=['echo', 'haha'], add_options={angr.options.STRICT_PAGE_ACCESS})
20    pg = p.factory.simulation_manager(s)
21    pg.run(until=lambda lpg: len(lpg.active) != 1)
22
23    assert len(pg.deadended) == 1
24    assert len(pg.active) == 0
25    # Need to dump by path because the program closes stdout
26    assert pg.deadended[0].posix.stdout.concretize() == [b'haha\n']
27
28def test_echo_haha():
29    for arch in target_arches:
30        yield run_echo_haha, arch
31
32if __name__ == "__main__":
33    for r,a in test_echo_haha():
34        r(a)
35