summaryrefslogtreecommitdiffstats
path: root/tests/fuzztest/SConscript
blob: 35b697f962d09c7beb500be1ca2919558b601d50 (plain)
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
# Run a fuzz test to verify robustness against corrupted/malicious data.

Import("env", "malloc_env")

# We want both pointer and static versions of the AllTypes message
# Prefix them with package name.
env.Command("alltypes_static.proto", "#alltypes/alltypes.proto",
            lambda target, source, env:
                open(str(target[0]), 'w').write("package alltypes_static;\n"
                                                + open(str(source[0])).read()))
env.Command("alltypes_pointer.proto", "#alltypes/alltypes.proto",
            lambda target, source, env:
                open(str(target[0]), 'w').write("package alltypes_pointer;\n"
                                                + open(str(source[0])).read()))

p1 = env.NanopbProto(["alltypes_pointer", "alltypes_pointer.options"])
p2 = env.NanopbProto(["alltypes_static", "alltypes_static.options"])
fuzz = malloc_env.Program(["fuzztest.c",
                    "alltypes_pointer.pb.c",
                    "alltypes_static.pb.c",
                    "$COMMON/pb_encode_with_malloc.o",
                    "$COMMON/pb_decode_with_malloc.o",
                    "$COMMON/pb_common_with_malloc.o",
                    "$COMMON/malloc_wrappers.o"])

env.RunTest(fuzz)

fuzzstub = malloc_env.Program(["fuzzstub.c",
                    "alltypes_pointer.pb.c",
                    "alltypes_static.pb.c",
                    "$COMMON/pb_encode_with_malloc.o",
                    "$COMMON/pb_decode_with_malloc.o",
                    "$COMMON/pb_common_with_malloc.o",
                    "$COMMON/malloc_wrappers.o"])