blob: 1837ee93e9afea420ed0a69e53d3fe922a19da9e [file] [log] [blame]
Mark Dykes9f5c50b2020-06-03 15:46:55 -05001#
2# Copyright (c) 2020, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
johpow0128e1a2b2021-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))
37
Mark Dykes9f5c50b2020-06-03 15:46:55 -050038TESTS_SOURCES += \
39 $(addprefix smc_fuzz/src/, \
40 randsmcmod.c \
41 smcmalloc.c \
42 fifo3d.c \
43 )