From c2f5c7481548d5ed122fc8bb4d57c30b7191b348 Mon Sep 17 00:00:00 2001 From: abv Date: Sun, 9 Dec 2012 19:03:08 +0400 Subject: [PATCH] Corrections for tests after integration of 2012-12-07 1. Fixed tests bugs caf bug350 and bug352 failing in Debug mode due to errors in QA code (removing items from the map during iteration). 2. Debug output messages are ignored in parse.rules in heal and bugs group to avoid false failures in Debug mode after changes made for #23609 and last integration of new tests. 3. Test bugs moddata buc60654 removed as duplicate of bug143. 4. Test bugs moddata bug143 fixed to compare real values properly. New command checkreal added for comparing reals with tolerance. 6. Test bugs caf bug114 is fixed to avoid use of OS-specific commands (command meminfo is used instead). Command checktrend is used to check for possible memory leak. --- .../QANewBRepNaming_ImportShape.cxx | 8 ++- .../QANewModTopOpe_Glue_SDFaces.cxx | 12 ++-- tests/bugs/begin | 10 ++++ tests/bugs/caf/bug114 | 58 ++++--------------- tests/bugs/moddata/buc60654 | 21 ------- tests/bugs/moddata/bug143 | 6 +- tests/bugs/parse.rules | 1 + tests/heal/parse.rules | 4 +- 8 files changed, 40 insertions(+), 80 deletions(-) delete mode 100755 tests/bugs/moddata/buc60654 diff --git a/src/QANewBRepNaming/QANewBRepNaming_ImportShape.cxx b/src/QANewBRepNaming/QANewBRepNaming_ImportShape.cxx index 4be9469479..9be4ee70ef 100755 --- a/src/QANewBRepNaming/QANewBRepNaming_ImportShape.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming_ImportShape.cxx @@ -245,6 +245,8 @@ void QANewBRepNaming_ImportShape::LoadC0Edges(const TopoDS_Shape& S, Standard_Boolean aC0 = Standard_False; TopoDS_Shape anEdge1 = anEx.Current(); if (edgeNaborFaces.IsBound(anEdge1)) { + TopTools_ListOfShape aEdgesToRemove; // record items to be removed from the map (should be done after iteration) + aEdgesToRemove.Append (anEdge1); const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1); TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces); for (; itr.More(); itr.Next()) { @@ -261,11 +263,13 @@ void QANewBRepNaming_ImportShape::LoadC0Edges(const TopoDS_Shape& S, aC0=Standard_True; TNaming_Builder bC0Edge(Tagger->NewChild()); bC0Edge.Generated(anEdge2); - edgeNaborFaces.UnBind(anEdge2); + aEdgesToRemove.Append (anEdge2); } } } - edgeNaborFaces.UnBind(anEdge1); + // remove items from the data map + for(TopTools_ListIteratorOfListOfShape anIt(aEdgesToRemove); anIt.More(); anIt.Next()) + edgeNaborFaces.UnBind(anIt.Value()); } if (aC0) { TNaming_Builder bC0Edge(Tagger->NewChild()); diff --git a/src/QANewModTopOpe/QANewModTopOpe_Glue_SDFaces.cxx b/src/QANewModTopOpe/QANewModTopOpe_Glue_SDFaces.cxx index 9280bcafa4..9c477416be 100755 --- a/src/QANewModTopOpe/QANewModTopOpe_Glue_SDFaces.cxx +++ b/src/QANewModTopOpe/QANewModTopOpe_Glue_SDFaces.cxx @@ -532,7 +532,6 @@ QANewModTopOpe_Glue::PerformSDFaces() } } - anIter.Initialize(myMapModif); TopTools_MapOfShape aComVerMap; TopTools_MapOfShape aLocVerMap; @@ -541,6 +540,8 @@ QANewModTopOpe_Glue::PerformSDFaces() anExp1.Init(myS2, TopAbs_VERTEX); for(; anExp1.More(); anExp1.Next()) aComVerMap.Add(anExp1.Current()); + TopTools_ListOfShape aShapesToRemove; // record items to be removed from the map (should be done after iteration) + anIter.Initialize(myMapModif); for(; anIter.More(); anIter.Next()) { const TopoDS_Shape& aS = anIter.Key(); if(aS.ShapeType() == TopAbs_EDGE) { @@ -574,18 +575,19 @@ QANewModTopOpe_Glue::PerformSDFaces() myMapModif(aS).Remove(anI1); } else { - myMapModif.UnBind(aS); + aShapesToRemove.Append (aS); } } } if(!anI1.More()) break; } } - -// if(anIter.Value().Extent() == 0) myMapModif.UnBind(aS); - } + // remove items from the data map + for(TopTools_ListIteratorOfListOfShape anIt(aShapesToRemove); anIt.More(); anIt.Next()) + myMapModif.UnBind(anIt.Value()); + // Deleted vertices anExp1.Init(myShape, TopAbs_VERTEX); for(; anExp1.More(); anExp1.Next()) { diff --git a/tests/bugs/begin b/tests/bugs/begin index 7285857398..aac6c0d3b4 100755 --- a/tests/bugs/begin +++ b/tests/bugs/begin @@ -25,6 +25,16 @@ if { [info exists test_image] == 0 } { set test_image photo } +# Procedure to check equality of two reals with tolerance (relative and absolute) +proc checkreal {name value expected tol_abs tol_rel} { + if { abs ($value - $expected) > $tol_abs + $tol_rel * abs ($expected) } { + puts "Error: $name = $value is not equal to expected $expected" + } else { + puts "Check of $name OK: value = $value, expected = $expected" + } + return +} + # Procedure to check if sequence of values in listval follows linear trend # adding the same delta on each step. # diff --git a/tests/bugs/caf/bug114 b/tests/bugs/caf/bug114 index 23e7e155ed..c82cef86e3 100755 --- a/tests/bugs/caf/bug114 +++ b/tests/bugs/caf/bug114 @@ -2,62 +2,26 @@ puts "===========" puts "OCC114" puts "===========" -#-------------------------------------------------------------------- -####### Setting value of memory leakage in percents of memory allocated by shape -set percent_max 10 -puts "Max memory leakage is $percent_max%" -####### Setting amount of iterations for computing leackage +# Max number of iterations for computing memory leackage set i_max 20 puts "Amount of iterations is $i_max" -#-------------------------------------------------------------------- - -if ![string compare $tcl_platform(platform) "windows"] { - proc VMem { memory } { - upvar $memory mem - regsub "^.*PeakVirtualSize: *\(\[0-9\]*\) KB.*$" \ - [exec tlist [pid]] "\\1" mem - } -} else { - proc VMem { memory } { - upvar $memory mem - set mem [lindex [exec ps -o vsz -p [pid]] 1] - } -} NewDocument D MDTV-Standard UndoLimit D 10 -VMem Mem0 restore [locate_data_file OCC114.brep] s -VMem Mem1 -#puts "... The peak memory consumed: [expr $Mem1 - $Mem0] KB" - -set MemoryLeakage 0 +set listmem {} for {set i 1} {${i} <= ${i_max}} {incr i} { - OpenCommand D - SetShape D 0:1 s - AbortCommand D + OpenCommand D + SetShape D 0:1 s + AbortCommand D - VMem Mem2 - set Delta [expr $Mem2 - $Mem1] - set MemoryLeakage [expr $MemoryLeakage + $Delta] -# puts " $i delta memory consumed: $Delta KB" + # check memory usage (with tolerance equal to half page size) + lappend listmem [expr [meminfo w] / 1024] + if { [checktrend $listmem 0 1 "Memory leak detected"] } { + puts "No memory leak, $i iterations" + break + } } - - -if { $MemoryLeakage != 0 } then { - set percent [expr ${MemoryLeakage} / (double(${i_max}) * (${Mem1} - ${Mem0})) * 100.] -} else { - set percent 0 -} -puts "Current memory leakage in percents = ${percent}" - -if {${percent} > ${percent_max}} { - puts "OCC114: Error" -} else { - puts "OCC114: OK" -} - - diff --git a/tests/bugs/moddata/buc60654 b/tests/bugs/moddata/buc60654 deleted file mode 100755 index 8e7008e246..0000000000 --- a/tests/bugs/moddata/buc60654 +++ /dev/null @@ -1,21 +0,0 @@ -puts "==================================" -puts "BUC60654" -puts "==================================" -puts "" -########################################################## -## Raises exception in GCPnts_AbscissaPoint on a Geom2d_OffsetCurve -########################################################## - -set len_ch 4.0000000000000001e+100 - -line line_2d 0 0 1 1 - -offset result line_2d 10 1 0 - -set info [length $result] -regexp {The length result is +([-0-9.+eE]+)} $info full len - -if { ${len} != ${len_ch} } { - puts "Error : length is invalid" -} - diff --git a/tests/bugs/moddata/bug143 b/tests/bugs/moddata/bug143 index ee27c86060..a76fd4a84e 100755 --- a/tests/bugs/moddata/bug143 +++ b/tests/bugs/moddata/bug143 @@ -7,7 +7,7 @@ puts "" ## Raises exception "Standard_NotImplemented3" in GCPnts_AbscissaPoint on a Geom2d_OffsetCurve ###################################################################### -set len_ch 4.0000000000000001e+100 +set len_expected 4.e100 line line_2d 0 0 1 1 offset result line_2d 10 1 0 @@ -15,6 +15,4 @@ offset result line_2d 10 1 0 set info [length $result] regexp {The length result is +([-0-9.+eE]+)} $info full len -if { ${len} != ${len_ch} } { - puts "Error : Length is invalid" -} +checkreal "Length" $len $len_expected 0. 1e-10 diff --git a/tests/bugs/parse.rules b/tests/bugs/parse.rules index 8f729a9291..6f6569ccd1 100755 --- a/tests/bugs/parse.rules +++ b/tests/bugs/parse.rules @@ -1,4 +1,5 @@ FAILED /\bFaulty\b/ bad shape +IGNORE /^Error [23]d = [\d.-]+/ debug output of blend command diff --git a/tests/heal/parse.rules b/tests/heal/parse.rules index fdebf39410..ecb7c874b7 100644 --- a/tests/heal/parse.rules +++ b/tests/heal/parse.rules @@ -1,4 +1,6 @@ FAILED /\bFaulty\b/ bad shape IGNORE /Error: Number of intervals are not equal for 2d 3d. Ignored./ Debug mode message from DT_ShapeDivide IGNORE /Warning: GeomConvert_ApproxSurface Exception: try to decrease continuity/ DEbug mode message from DT_ToBspl -IGNORE /Error: ShapeFix_ComposeShell::MakeFacesOnPatch: can[']t dispatch wires/ Debug mode output \ No newline at end of file +IGNORE /Error: ShapeFix_ComposeShell::MakeFacesOnPatch: can[']t dispatch wires/ Debug mode output +IGNORE /Warning: ShapeFix_WireSegment::DefineI[UV]M[ia][nx]: indexation error/ debug mode output on bad geometries +IGNORE /error = [0-9eE.+-]+\s+spans = [0-9]+/ debug output of surface approximator \ No newline at end of file