aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/kfuzztest/testdata/2/prog.c
blob: 908ccd2710160178c34c2d87e1358b49dcaaf51d (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
37
38
39
// Copyright 2025 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
#include "../common.h"

#include <stdlib.h>

struct bar {
	int a;
	int b;
};

struct foo {
	struct bar* b;
	const char* str;
	const char* data;
	size_t datalen;
	uint64_t* numbers;
};

DEFINE_FUZZ_TARGET(some_target, struct foo);
/* Expect foo.bar != NULL. */
DEFINE_CONSTRAINT(foo, bar, NULL, NULL, EXPECT_NE);
/* Expect foo.str != NULL. */
DEFINE_CONSTRAINT(foo, str, NULL, NULL, EXPECT_NE);
/* Annotate foo.str as a string. */
DEFINE_ANNOTATION(foo, str, , ATTRIBUTE_STRING);
/* Expect foo.data != NULL. */
DEFINE_CONSTRAINT(foo, data, NULL, NULL, EXPECT_NE);
/* Annotate foo.data as an array. */
DEFINE_ANNOTATION(foo, data, , ATTRIBUTE_ARRAY);
/* Annotate foo.datalen == len(foo.data). */
DEFINE_ANNOTATION(foo, datalen, data, ATTRIBUTE_LEN);
/* Annotate foo.numbers as an array. */
DEFINE_ANNOTATION(foo, numbers, , ATTRIBUTE_ARRAY);

/* Define a main function, otherwise the compiler complains. */
int main(void)
{
}