1# Copyright (c) 2023 Arm Limited
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import argparse
16from utils import CATEGORIES, parse_yaml_file
17
18
19def validate_output(test_stats, skip_size, fih_level):
20    if (test_stats[CATEGORIES['BOOT']] > 0
21       and skip_size == "2,4,6" and fih_level == "MEDIUM"):
22        raise ValueError("The number of sucessful boots was more than zero")
23
24
25def main():
26    parser = argparse.ArgumentParser(description='''Process a FIH test output yaml file,
27     and validate no sucessfull boots have happened''')
28    parser.add_argument('filename', help='yaml file to process')
29    parser.add_argument('skip_size', help='instruction skip size')
30    parser.add_argument('fih_level', nargs="?",
31                        help='fault injection hardening level')
32
33    args = parser.parse_args()
34    test_stats = parse_yaml_file(args.filename)[0]
35    validate_output(test_stats, args.skip_size, args.fih_level)
36
37
38if __name__ == "__main__":
39    main()
40