Use the base name of the generating script, not the full path

Otherwise the generation is sensitive to trivial differences such as
running `tests/scripts/generate_psa_tests.py` vs
`./tests/scripts/generate_psa_tests.py` vs an absolute path.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-01-27 18:30:40 +01:00
parent af1728442d
commit 505cc641de

View File

@ -17,6 +17,7 @@
# limitations under the License.
import binascii
import os
import sys
from typing import Any, Iterable, List, Optional
import typing_extensions #pylint: disable=import-error
@ -98,7 +99,7 @@ def write_data_file(filename: str,
If the file already exists, it is overwritten.
"""
if caller is None:
caller = sys.argv[0]
caller = os.path.basename(sys.argv[0])
with open(filename, 'w') as out:
out.write('# Automatically generated by {}. Do not edit!\n'
.format(caller))