user_defined_function.py 789 Bytes
Newer Older
German Leon's avatar
German Leon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
[THIS FUNCTION CAN BE EDITED IF DESIRED]
User defined function
this function must return an empty or not.
The string will be appended in the last column of summary CSV file
the column will have  'user_defined' as header
if there isn't a return value the column will be None,
otherwise it will contain the returned values for each injection
"""
import re


def user_defined_function(injection_output_path):
    # This is a temporary example for carol-fi-codes suite
    # it will search for a LOGFILENAME int the benchmark output if it finds
    # then the desired pattern will be returned

    with open(injection_output_path, "r") as fp:
        for line in fp.readlines():
            m = re.match(r'LOGFILENAME:.*/(\S+).*', line)
            if m:
                return m.group(1)