Mark Dykes | 9f5c50b | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2020, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
johpow01 | 28e1a2b | 2021-06-23 16:10:22 -0500 | [diff] [blame] | 7 | # 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 |
| 11 | SMC_FUZZ_INSTANCE_COUNT ?= 1 |
| 12 | SMC_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));") |
| 13 | SMC_FUZZ_CALLS_PER_INSTANCE ?= 100 |
| 14 | |
| 15 | # Validate SMC fuzzer parameters |
| 16 | |
| 17 | # Instance count must not be zero |
| 18 | ifeq ($(SMC_FUZZ_INSTANCE_COUNT),0) |
| 19 | $(error SMC_FUZZ_INSTANCE_COUNT must not be zero!) |
| 20 | endif |
| 21 | |
| 22 | # Calls per instance must not be zero |
| 23 | ifeq ($(SMC_FUZZ_CALLS_PER_INSTANCE),0) |
| 24 | $(error SMC_FUZZ_CALLS_PER_INSTANCE must not be zero!) |
| 25 | endif |
| 26 | |
| 27 | # Make sure seed count and instance count match |
| 28 | TEST_SEED_COUNT = $(shell python -c "print(len(\"$(SMC_FUZZ_SEEDS)\".split(\",\")))") |
| 29 | ifneq ($(TEST_SEED_COUNT), $(SMC_FUZZ_INSTANCE_COUNT)) |
| 30 | $(error Number of seeds does not match SMC_FUZZ_INSTANCE_COUNT!) |
| 31 | endif |
| 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 Dykes | 9f5c50b | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 38 | TESTS_SOURCES += \ |
| 39 | $(addprefix smc_fuzz/src/, \ |
| 40 | randsmcmod.c \ |
| 41 | smcmalloc.c \ |
| 42 | fifo3d.c \ |
| 43 | ) |