コード例 #1
0
def test_pyObjectManager_List_setitem():
    b = ast_parse.parse(test1).body
    p = Path(b, source=test1)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1

    l = pg.completed[0].state.getVar('l')

    s = pg.completed[0].state

    # Base check
    assert l[1].count == 0
    assert type(l[1]) == Real

    # Assign an Int
    l[1] = Int(varName='x', ctx=0, state=s)
    assert l[1].count == 1
    assert type(l[1]) == Int

    # Assign back to Real
    l[1] = Real(varName='x', ctx=0, state=s)
    assert l[1].count == 2
    assert type(l[1]) == Real

    # Assign to BitVec
    l[1] = BitVec(varName='x', ctx=0, size=32, state=s)
    assert l[1].count == 3
    assert type(l[1]) == BitVec

    # Assign List
    l[1] = List(varName='x', ctx=0, state=s)
    #assert l[1].count == 4
    assert type(l[1]) == List
コード例 #2
0
def test_function_String_rstrip_symbolicStrip():
    b = ast_parse.parse(test3).body
    p = Path(b,source=test3)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 5
    o = [p.state.any_str('x') for p in pg.completed]
    o.sort()
    # 3 cases. 1) both chars miss, 2) one char hit's "t" and the other misses. 3) one hits
    # "t" and the other hits "s"
    assert o == ['te', 'te', 'tes', 'tes', 'testt']

    b = ast_parse.parse(test4).body
    p = Path(b,source=test4)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 9

    # TODO: This is a brittle match..
    o = [p.state.any_str('s') for p in pg.completed]
    o.sort()
    assert not o[0].endswith("x")
    for x in range(1,8):
        assert o[x].endswith("x"*x)
コード例 #3
0
ファイル: test_pyState_If.py プロジェクト: njues/pySym
def test_pySym_If_StateSplit():
    b = ast_parse.parse(test3).body
    p = Path(b,source=test3)
    pg = PathGroup(p)

    pg.explore()
    
    # Splits into 8 possibilities and then if splits again
    assert len(pg.completed) == 8
    assert len(pg.deadended) == 8

    # Two of those states should hit the y+=1
    assert sum([p.state.any_int('y') for p in pg.completed]) == 2

    b = ast_parse.parse(test4).body
    p = Path(b,source=test4)
    pg = PathGroup(p)

    pg.explore()
    
    # Splits into 8 possibilities and then if splits again
    assert len(pg.completed) == 8
    assert len(pg.deadended) == 8

    # Two of those states should hit the y+=1
    assert sum([p.state.any_int('z') for p in pg.completed]) == 1
コード例 #4
0
ファイル: test_pyState_Call.py プロジェクト: njues/pySym
def test_pySym_functionNestingTwo():
    # More intense nesting
    b = ast_parse.parse(test7).body
    p = Path(b, source=test7)
    pg = PathGroup(p)
    pg.explore()
    assert pg.completed[0].state.any_int('x') == 7
コード例 #5
0
ファイル: test_one.py プロジェクト: njues/pySym
def test_longer_one():
    b = ast_parse.parse(test).body
    p = Path(b, source=test)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1

    assert pg.completed[0].state.any_list('CRC_POLY') == [
        1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0,
        0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0,
        0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1
    ]

    assert pg.completed[0].state.any_list('INNER') == [
        0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0,
        0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0,
        0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0
    ]

    assert pg.completed[0].state.any_list('PLAIN_1_BITS') == [
        0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0,
        0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0,
        0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0,
        0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0
    ]
コード例 #6
0
def test_getZ3Object():
    b = ast_parse.parse("x = 12").body
    p = Path(b, source="x = 12")
    pg = PathGroup(p)
    pg.explore()
    assert len(pg.completed) == 1
    x = pg.completed[0].state.getVar('x')
    assert type(x) is Int
コード例 #7
0
def test_pyState_GeneratorExp_General():
    b = ast_parse.parse(test1).body
    p = Path(b,source=test1)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_str('x') == "".join(str(i) for i in range(5))
コード例 #8
0
def test_function_String_rstrip_Char():
    b = ast_parse.parse(test5).body
    p = Path(b,source=test5)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 2
    assert set([p.state.any_str('x') for p in pg.completed]) == {"m","mee"}
コード例 #9
0
ファイル: test_pyState_For.py プロジェクト: njues/pySym
def test_pySym_nestedFor():
    b = ast_parse.parse(test2).body
    p = Path(b, source=test2)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_int('out') == 290
コード例 #10
0
ファイル: test_pyState_ListComp.py プロジェクト: njues/pySym
def test_pyState_ListComp_outputModifier():
    b = ast_parse.parse(test6).body
    p = Path(b, source=test6)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_list('l') == [x**2 for x in range(5)]
コード例 #11
0
ファイル: test_pyState_Subscript.py プロジェクト: njues/pySym
def test_pyState_Subscript_MultiDimentional():
    b = ast_parse.parse(test3).body
    p = Path(b, source=test3)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_int('x') == 4
コード例 #12
0
ファイル: test_pyState_Subscript.py プロジェクト: njues/pySym
def test_pyState_nestedSlice():
    b = ast_parse.parse(test11).body
    p = Path(b, source=test11)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_int('x') == 3
コード例 #13
0
def test_pySym_AugAssign_BitStuff():
    b = ast_parse.parse(test3).body
    p = Path(b, source=test3)
    pg = PathGroup(p)
    pg.explore()

    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_int('e') == 38776701190144
コード例 #14
0
def test_pySym_BinOp_Xor():
    b = ast_parse.parse(test4).body
    p = Path(b,source=test4)
    pg = PathGroup(p)
    pg.explore()
    
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_int('d') == 13
コード例 #15
0
def test_pySym_BinOp_BitStuff():
    b = ast_parse.parse(test5).body
    p = Path(b,source=test5)
    pg = PathGroup(p)
    pg.explore()
    
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_int('e') == 57065549561856
コード例 #16
0
def test_pySym_BinOp_ListConcat():
    b = ast_parse.parse(test11).body
    p = Path(b,source=test11)
    pg = PathGroup(p)
    pg.explore()

    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_list('l') == [1,2,3] + [4,5,6]
コード例 #17
0
def test_pySym_BinOp_StringMult():
    b = ast_parse.parse(test14).body
    p = Path(b,source=test14)
    pg = PathGroup(p)
    pg.explore()

    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_str('x') == "A" * 4
コード例 #18
0
ファイル: test_pyState_ListComp.py プロジェクト: njues/pySym
def test_pyState_ListComp_MoreFunctions():
    b = ast_parse.parse(test8).body
    p = Path(b, source=test8)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_list('l') == [str(i) for i in range(10)]
コード例 #19
0
ファイル: test_pyState_ListComp.py プロジェクト: njues/pySym
def test_pyState_ListComp_StringCmp():
    b = ast_parse.parse(test7).body
    p = Path(b, source=test7)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_list('l') == ["b"]
コード例 #20
0
def test_fnuction_len_statesplit():
    b = ast_parse.parse(test2).body
    p = Path(b, source=test2)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 8
    assert set([p.state.any_int('x') for p in pg.completed]) == set(range(8))
コード例 #21
0
ファイル: test_pyState_Subscript.py プロジェクト: njues/pySym
def test_pyState_Subscript_AssignToVar():
    b = ast_parse.parse(test1).body
    p = Path(b, source=test1)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_int('x') == 2
コード例 #22
0
ファイル: test_pyState_For.py プロジェクト: njues/pySym
def test_pySym_variableSlice():
    b = ast_parse.parse(test4).body
    p = Path(b, source=test4)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_int('out') == 104
コード例 #23
0
def test_function_List_append():
    b = ast_parse.parse(test1).body
    p = Path(b, source=test1)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_list('l') == [1, 2.3, [1, 2.2, 3]]
コード例 #24
0
def test_pyObjectManager_List_NestedList():
    b = ast_parse.parse(test2).body
    p = Path(b, source=test2)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_list('l') == [1, 2.2, [3, [4, 5], 6]]
コード例 #25
0
def test_pyObjectManager_List_BasicAssign():
    b = ast_parse.parse(test1).body
    p = Path(b, source=test1)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_list('l') == [1, 2.2, 3]
コード例 #26
0
def test_pyObjectManager_List_FunctionCalls():
    b = ast_parse.parse(test10).body
    p = Path(b, source=test10)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1
    assert pg.completed[0].state.any_list('l') == [1, 12, [24]]
コード例 #27
0
def test_pyObjectManager_List_StateSplit():
    b = ast_parse.parse(test12).body
    p = Path(b, source=test12)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 8
    assert set([p.state.any_list('l')[1]
                for p in pg.completed]) == set(range(8))
コード例 #28
0
def test_pySym_Compare_Symbolic_String():
    b = ast_parse.parse(compare4).body
    p = Path(b, source=compare4)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 2

    assert pg.completed[1].state.any_str('s')[2] == "t"
コード例 #29
0
def test_pyObjectManager_String_Assign():
    b = ast_parse.parse(test1).body
    p = Path(b, source=test1)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1

    assert pg.completed[0].state.any_str('s') == "Test"
コード例 #30
0
def test_pyObjectManager_String_ListComp():
    b = ast_parse.parse(test2).body
    p = Path(b, source=test2)
    pg = PathGroup(p)

    pg.explore()
    assert len(pg.completed) == 1

    assert pg.completed[0].state.any_list('l') == [x for x in "Test"]