mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-29 16:10:58 +00:00
36f641c54e
Add the basic infrastructure for declaring fuzz tests and a command to invoke them. Signed-off-by: Andrew Scull <ascull@google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* Copyright (c) 2022 Google, Inc.
|
|
* Written by Andrew Scull <ascull@google.com>
|
|
*/
|
|
|
|
#ifndef __TEST_FUZZ_H
|
|
#define __TEST_FUZZ_H
|
|
|
|
#include <linker_lists.h>
|
|
#include <linux/types.h>
|
|
|
|
/**
|
|
* struct fuzz_test - Information about a fuzz test
|
|
*
|
|
* @name: Name of fuzz test
|
|
* @func: Function to call to perform fuzz test on an input
|
|
* @flags: Flags indicate pre-conditions for fuzz test
|
|
*/
|
|
struct fuzz_test {
|
|
const char *name;
|
|
int (*func)(const uint8_t * data, size_t size);
|
|
int flags;
|
|
};
|
|
|
|
/**
|
|
* FUZZ_TEST() - register a fuzz test
|
|
*
|
|
* The fuzz test function must return 0 as other values are reserved for future
|
|
* use.
|
|
*
|
|
* @_name: the name of the fuzz test function
|
|
* @_flags: an integer field that can be evaluated by the fuzzer
|
|
* implementation
|
|
*/
|
|
#define FUZZ_TEST(_name, _flags) \
|
|
ll_entry_declare(struct fuzz_test, _name, fuzz_tests) = { \
|
|
.name = #_name, \
|
|
.func = _name, \
|
|
.flags = _flags, \
|
|
}
|
|
|
|
/** Get the start of the list of fuzz tests */
|
|
#define FUZZ_TEST_START() \
|
|
ll_entry_start(struct fuzz_test, fuzz_tests)
|
|
|
|
/** Get the number of elements in the list of fuzz tests */
|
|
#define FUZZ_TEST_COUNT() \
|
|
ll_entry_count(struct fuzz_test, fuzz_tests)
|
|
|
|
#endif /* __TEST_FUZZ_H */
|