5from subprocess
import Popen, PIPE, STDOUT
9cyclus_path =
"/root/.local/include/cyclus/../../bin/cyclus"
10input_path =
"/cycamore/input"
13 files, catalogs, catalognames = get_files(input_path)
14 copy_catalogs(catalogs,cyclus_path.strip(
"cyclus"))
17 file_to_test = TestFile(cyclus_path, name, flag)
19 summ.add_to_summary(file_to_test)
20 clean_catalogs(cyclus_path.strip(
"cyclus"),catalognames)
24 """This function finds input files, runs them, and prints a summary"""
29 """This function checks the input arguments"""
33 elif len(sys.argv) == 2:
34 if re.search(
"-v*",sys.argv[1]):
39 elif len(sys.argv) == 1 :
44 """This prints the proper way to treat the command line interface"""
45 print(
""" Usage: python3 run_inputs.py\n
47 -v arg output log verbosity. \n
51 LEV_ERROR (least verbose, default), LEV_WARN,\n
53 LEV_INFO1 (through 5), and LEV_DEBUG1 (through 5).\n
57 0 (LEV_ERROR equiv) through 11 (LEV_DEBUG5 equiv)\n""")
60 """This function walks the 'path' tree and finds input files"""
64 for root, dirs, files
in os.walk(path, followlinks=
True):
68 if re.search(
"\.xml",name) :
69 if re.search(
"recipebook",name)
or \
70 re.search(
"facilitycatalog",name):
71 catalogs.append(os.path.join(root,name))
72 catalognames.append(name)
74 inputs.append(os.path.join(root, name))
77 print(
"The catalogs to be moved are:")
79 print(
"The files to be tested are:")
81 return inputs, catalogs, catalognames
83def copy_catalogs(catalogs,cyclus_path) :
84 """Copies files in the catalogs list to the cyclus executable directory"""
86 p = Popen(
"cp "+cat+
" "+cyclus_path,
87 shell=
True, stdout=PIPE, stderr=STDOUT)
89def clean_catalogs(cyclus_path, catalogs) :
90 """Removes previously copied catalogs from executable directory."""
92 p = Popen(
"rm "+ os.path.join(cyclus_path,cat),
93 shell=
True, stdout=PIPE, stderr=STDOUT)
96 """An object to hold the results of all the tests"""
102 """Adds a test file to this summary object"""
103 if test_file.passed :
104 self.
passed.append( test_file.infile )
106 self.
failed.append( test_file.infile )
109 """Prints the summary"""
110 print(
"Input files passed = " + str(len(self.
passed)))
111 print(
"Input files failed = " + str(len(self.
failed)))
112 print(
"Failed input files : ")
117 """An object representing the inputxml file to test"""
122 self.
flag =
" "+flag+
" "
125 """Runs all of the input file tests"""
133 """Returns the output from running the FileTest"""
136 shell=
True, stdout=PIPE, stderr=STDOUT)
137 io_tuple = p.communicate()
139 except subprocess.CalledProcessError
as e:
144 """returns true if there were no errors or segfaults running this TestFile"""
146 print(
"Input file " + self.
infile)
147 if re.search(
"No such file or directory",output) :
148 print(
"Cyclus executable not found in path.")
149 elif re.search(
"ERROR",output)
or re.search(
"Segmentation fault",output):
151 print(
" resulted in errors: ")
157if __name__ ==
'__main__' :
main()
int main(int argc, char *argv[])