ocf/tests/ut/add_new_test_file.py
Robert Baldyga a8e1ce8cc5 Initial commit
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
2018-11-29 15:14:21 +01:00

31 lines
884 B
Python
Executable File

#!/usr/bin/env python2
#
# Copyright(c) 2012-2018 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
import commands
import sys
import os
args = ' '.join(sys.argv[1:])
script_path = os.path.dirname(os.path.realpath(__file__))
framework_script_path = script_path + os.sep + "../ut-framework/add_new_test_file.py"
framework_script_path = os.path.normpath(framework_script_path)
status, output = commands.getstatusoutput(framework_script_path + " " + args)
print output
if status == 0:
path = output.split(" ", 1)[0]
with open(script_path + os.sep + "header.c", "r") as header_file:
with open(path, "r+") as source_file:
source = source_file.readlines()
source_file.seek(0, os.SEEK_SET)
source_file.truncate()
source_file.writelines(header_file.readlines())
source_file.writelines(source)