Commit 42e351f4 authored by Florian Hindenlang's avatar Florian Hindenlang
Browse files

cleanup for master

parent 5836b7fc
stages:
- build
- test
# ---------------------------------------------------------------------------------------------------------------------------------
# Stage "build"
# v>9 artifacts: name: "${CI_PIPELINE_ID}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
# ---------------------------------------------------------------------------------------------------------------------------------
build_debug:
stage: build
script:
- rm -rf build_debug || true
- mkdir -p build_debug
- cd ode-1 ; make clean ; make DEBUG=yes 2>../build_debug/stderr 1>../build_debug/stdout
- cd ..
- cat build_debug/stdout
- mv ode-1/rk_solve build_debug/.
artifacts:
name: "${CI_PIPELINE_ID}_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
untracked: true
expire_in: 4 weeks
when: always
paths:
- build_debug
build_release:
stage: build
script:
- rm -rf build_release || true
- mkdir -p build_release
- cd ode-1 ; make clean
- make DEBUG=no 2>../build_release/stderr 1>../build_release/stdout
- cd ..
- cat build_release/stdout
- mv ode-1/rk_solve build_release/.
artifacts:
name: "${CI_PIPELINE_ID}_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
untracked: true
expire_in: 4 weeks
when: always
paths:
- build_release
# ---------------------------------------------------------------------------------------------------------------------------------
# Stage "test"
# ---------------------------------------------------------------------------------------------------------------------------------
test_debug:
stage: test
script:
- cd testing ; python3 run_tests.py -execpath build_debug/rk_solve
artifacts:
name: "${CI_PIPELINE_ID}_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
untracked: true
expire_in: 4 weeks
when: always
paths:
- testing
test_release:
stage: test
script:
- cd testing ; python3 run_tests.py -execpath build_release/rk_solve
artifacts:
name: "${CI_PIPELINE_ID}_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
untracked: true
expire_in: 4 weeks
when: always
paths:
- testing
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import argparse
########################################################################################################
# HELPER ROUTINES (used by main program below)
########################################################################################################
# extract the error of the last line
def get_last_error(lines) :
tmp = [ line for line in lines if ("error is" in line)]
error = float(tmp[0].split(":")[1])
return error
########################################################################################################
def execute(execpath, case=0, project="default", keepdir=1, error_tol=0. , err= None ):
cwd = os.getcwd() #current working directory
print( " ")
print( "===> run ...")
testdir=("dirx_%d_%s" % (case,project) )
os.system('mkdir -p '+ testdir)
os.chdir(testdir)
cmdexec = ("../../%s" % execpath.strip() )
os.system(cmdexec+" 2>stderr 1>stdout")
stdout=open("stdout",'r').readlines()
stderr=open("stderr",'r').readlines()
success= False
for line in stdout :
if "FINISHED SUCCESSFULLY." in line :
success= True
if (not success) :
print("=============================================== ")
print(" !!!! PROBLEM WITH RUN, NOT FINISHED CORRECTLY!!!!! ")
print("=============================================== ")
print(" ")
err.extend(["caseID=%6d ,project= %s <=run" % (case,project)])
# go back to working directory and exit
os.chdir(cwd)
return success #=False
else :
print("=============================================== ")
print(" run finished sucessfully.")
print("=============================================== ")
print(" ")
print( " ")
print( "===> compare error ...")
error = get_last_error(stdout)
success = False
if(float(error) < float(error_tol)):
success = True
if (not success) :
print("=============================================== ")
print(" !!!! PROBLEM WITH ERROR COMPARISON, NOT BELOW TOLERANCE!!!!! ")
print(" %15.9e > tolerance=%15.e " %(error,error_tol))
print("=============================================== ")
print(" ")
err.extend(["caseID=%6d ,project= %s <=error" % (case,project)])
# go back to working directory and exit
os.chdir(cwd)
return success #=False
else :
print("=============================================== ")
print(" Error comparison successfull, %15.9e < %15.9e "%(error,error_tol))
print("=============================================== ")
print(" ")
# success still True, only delete sucessfull case directory if keepdir=0
os.chdir(cwd)
if(keepdir ==0) :
os.system('rm -rf '+testdir) #destroy directory
return success
########################################################################################################
# parse a str with comma separated ranges: 1,5,10-12
def parse_range(astr):
result = set()
for part in astr.split(','):
x = part.split('-')
result.update(range(int(x[0]), int(x[-1]) + 1))
return sorted(result)
########################################################################################################
# MAIN PROGRAM
########################################################################################################
parser = argparse.ArgumentParser(description='Tool to run tests')
parser.add_argument('-execpath', type=str, default='ode-1/rk_solve',help='path to executable, base is main folder,\n'
'default is "-execpath ode-1/rk-solve"')
#parser.add_argument('prm', help='path to parameter file')
parser.add_argument('-case', type=str, default='0', help="0 : DEFAULT, run all cases,\n"
"101,2-4 : list of specific cases to run (without spaces!) ")
parser.add_argument('-keepdir', type=int, default=1, help="1 : DEFAULT, keep all case directories,\n"
"0 : delete sucessfull case directories")
args = parser.parse_args()
cases = parse_range(args.case)
#list of errors in execute
collect_err= []
caseID =100
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
caseID=caseID+1
if(cases[0]==0 or (caseID in cases)) :
pname="first"
tol=0.2
print("caseID: %d name: %s" % (caseID,pname))
stat = execute(args.execpath,case=caseID,project=pname,\
keepdir=args.keepdir,error_tol=tol,err=collect_err)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
caseID=caseID+1
if(cases[0]==0 or (caseID in cases)) :
pname="second"
tol=0.1
print("caseID: %d name: %s" % (caseID,pname))
stat = execute(args.execpath,case=caseID,project=pname,\
keepdir=args.keepdir,error_tol=tol,err=collect_err)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#============================================================================
#FINAL ERROR HANDLING:
#============================================================================
if(len(collect_err) > 0 ) :
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
print("!!!!!!! WARNING, following cases failed: !!!!!!!!")
print(" ")
for line in collect_err :
print("--> "+line)
print(" ")
print("... see log.caseID_project files")
print(" and dirx_caseID_project folders.")
print(" rerun build script with -case option to run again spefic caseIDs.")
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
sys.exit(100) #exit program with >0
else :
print("/////////////////////////////////////////////////////////")
print(" ")
print(" ==> ALL CASES WERE SUCCESSFULL!")
print(" ")
print("/////////////////////////////////////////////////////////")
sys.exit(0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment