blob: a10ea50a8a3742ba25e1fbbe4059aa272af760cf [file] [log] [blame]
Mark Dykese7810b52020-06-03 15:46:55 -05001#
Mark Dykes50297972024-03-15 12:49:22 -05002# Copyright (c) 2024, Arm Limited. All rights reserved.
Mark Dykese7810b52020-06-03 15:46:55 -05003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
johpow01d5c79cc2021-06-23 16:10:22 -05007# Generate random fuzzing seeds
8# If no instance count is provided, default to 1 instance
9# If no seeds are provided, generate them randomly
10# The number of seeds provided must match the instance count
11SMC_FUZZ_INSTANCE_COUNT ?= 1
12SMC_FUZZ_SEEDS ?= $(shell python -c "from random import randint; seeds = [randint(0, 4294967295) for i in range($(SMC_FUZZ_INSTANCE_COUNT))];print(\",\".join(str(x) for x in seeds));")
13SMC_FUZZ_CALLS_PER_INSTANCE ?= 100
14
15# Validate SMC fuzzer parameters
16
17# Instance count must not be zero
18ifeq ($(SMC_FUZZ_INSTANCE_COUNT),0)
19$(error SMC_FUZZ_INSTANCE_COUNT must not be zero!)
20endif
21
22# Calls per instance must not be zero
23ifeq ($(SMC_FUZZ_CALLS_PER_INSTANCE),0)
24$(error SMC_FUZZ_CALLS_PER_INSTANCE must not be zero!)
25endif
26
27# Make sure seed count and instance count match
28TEST_SEED_COUNT = $(shell python -c "print(len(\"$(SMC_FUZZ_SEEDS)\".split(\",\")))")
29ifneq ($(TEST_SEED_COUNT), $(SMC_FUZZ_INSTANCE_COUNT))
30$(error Number of seeds does not match SMC_FUZZ_INSTANCE_COUNT!)
31endif
32
33# Add definitions to TFTF_DEFINES so they can be used in the code
34$(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_SEEDS))
35$(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_INSTANCE_COUNT))
36$(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_CALLS_PER_INSTANCE))
Mark Dykes50297972024-03-15 12:49:22 -050037ifeq ($(SMC_FUZZER_DEBUG),1)
38$(eval $(call add_define,TFTF_DEFINES,SMC_FUZZER_DEBUG))
39endif
mardyk01c14e4ad2023-10-11 16:50:19 -050040ifeq ($(MULTI_CPU_SMC_FUZZER),1)
41$(eval $(call add_define,TFTF_DEFINES,MULTI_CPU_SMC_FUZZER))
42endif
Mark Dykes50297972024-03-15 12:49:22 -050043$(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_SANITY_LEVEL))
johpow01d5c79cc2021-06-23 16:10:22 -050044
Mark Dykese7810b52020-06-03 15:46:55 -050045TESTS_SOURCES += \
46 $(addprefix smc_fuzz/src/, \
47 randsmcmod.c \
48 smcmalloc.c \
49 fifo3d.c \
mardyk01c14e4ad2023-10-11 16:50:19 -050050 runtestfunction_helpers.c \
mardyk01f5b46352023-10-24 16:23:23 -050051 sdei_fuzz_helper.c \
52 tsp_fuzz_helper.c \
mardyk017b51dbe2024-01-17 15:25:36 -060053 nfifo.c \
Mark Dykes50297972024-03-15 12:49:22 -050054 constraint.c \
Mark Dykese7810b52020-06-03 15:46:55 -050055 )