Mark Dykes | e0ef181 | 2025-06-11 14:14:37 -0500 | [diff] [blame^] | 1 | # !/usr/bin/env python |
| 2 | # |
| 3 | # Copyright (c) 2025 Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | |
| 9 | #python3 gen_smc_fuzz_tests.py -n <number of tests> |
| 10 | #This script generates the tftf config and group files for fuzzing |
| 11 | import argparse |
| 12 | import random |
| 13 | |
| 14 | parser = argparse.ArgumentParser( |
| 15 | prog='gen_smc_fuzz_tests.py', |
| 16 | description='Generates the tftf config and group files for fuzzing tests in CI', |
| 17 | epilog='one argument input') |
| 18 | |
| 19 | parser.add_argument('-n', '--numtests',help="number of tests") |
| 20 | |
| 21 | args = parser.parse_args() |
| 22 | |
| 23 | print("starting fuzzing generation of tests for CI") |
| 24 | |
| 25 | gitadd = "git add " |
| 26 | |
| 27 | for i in range(int(args.numtests)): |
| 28 | rnum = str(hex(random.randint(1, 100000000))) |
| 29 | tftfconfilename = "fvp-smcfuzzing_" + rnum |
| 30 | tftfconfilenamepath = "../tftf_config/" + tftfconfilename |
| 31 | configfile = open(tftfconfilenamepath, "w") |
| 32 | cline = "CROSS_COMPILE=aarch64-none-elf-\n" |
| 33 | cline += "PLAT=fvp\n" |
| 34 | cline += "TESTS=smcfuzzing\n" |
| 35 | cline += "SMC_FUZZING=1\n" |
| 36 | cline += "SMC_FUZZ_DTS=smc_fuzz/dts/sdei_coverage.dts\n" |
| 37 | cline += "SMC_FUZZER_DEBUG=1\n" |
| 38 | cline += "SMC_FUZZ_SANITY_LEVEL=3\n" |
| 39 | cline += "SMC_FUZZ_CALLS_PER_INSTANCE=10000\n" |
| 40 | cline += "SMC_FUZZ_DEFFILE=sdei_and_vendor_smc_calls.txt\n" |
| 41 | cline += "SMC_FUZZ_SEEDS=" + rnum |
| 42 | configfile.write(cline) |
| 43 | configfile.close() |
| 44 | groupfile = "fvp-aarch64-sdei," + tftfconfilename + ":fvp-tftf-fip.tftf-aemv8a-tftf.fuzz" |
| 45 | groupfilepath = "../group/tf-l3-fuzzing/" + groupfile |
| 46 | gfile = open(groupfilepath, "w") |
| 47 | gline = "#\n" |
| 48 | gline += "# Copyright (c) 2025, Arm Limited. All rights reserved.\n" |
| 49 | gline += "#\n" |
| 50 | gline += "# SPDX-License-Identifier: BSD-3-Clause\n" |
| 51 | gline += "#\n" |
| 52 | gfile.write(gline) |
| 53 | gfile.close() |
| 54 | gitadd += "./tftf_config/" + tftfconfilename + " " |
| 55 | gitadd += "./group/tf-l3-fuzzing/" + groupfile + " " |
| 56 | gaddcom = open("../gitadd", "w") |
| 57 | gaddcom.write(gitadd) |
| 58 | gaddcom.close() |