blob: 5e1c2ed233e0284d006963e83bbab88d692e99fe [file] [log] [blame]
Mark Dykese0ef1812025-06-11 14:14:37 -05001# !/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
11import argparse
12import random
13
14parser = 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
19parser.add_argument('-n', '--numtests',help="number of tests")
20
21args = parser.parse_args()
22
23print("starting fuzzing generation of tests for CI")
24
25gitadd = "git add "
26
27for 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 + " "
56gaddcom = open("../gitadd", "w")
57gaddcom.write(gitadd)
58gaddcom.close()