Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #419 - memory leak. #425

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]


### Added

- Fujitsu compiler support

### Fixed

This fixes a small CMake bug which can lead to posix_predefined.x being built in the wrong build subdirectory when CMAKE_RUNTIME_OUTPUT_DIRECTORY is set*.
- Eliminated small memory leak for @disable tests. Accomplished by switching to gFTL v2 implementation of Map.
- This fixes a small CMake bug which can lead to posix_predefined.x being built in the wrong build subdirectory when CMAKE_RUNTIME_OUTPUT_DIRECTORY is set*.

### Changed

- Made annotation map a component of Test rather than using inheritance from StringTestAnnotationMap. Arguably looser coupling, and was explored as part of chasing small memory leak mentioned above.
- Updated the CI to use Intel LLVM compilers
- Removed obsolete documentation

Expand Down Expand Up @@ -54,7 +56,6 @@ This fixes a small CMake bug which can lead to posix_predefined.x being built in
### Fixed
- Increased size of buffer for reporting real values in asserts. Previous length was not quite enough for some 128 bit values, which resulted in EOR failures during execution.


## [4.7.0] - 2023-04-17

### Changed
Expand Down
6 changes: 4 additions & 2 deletions bin/funit/pFUnitParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,8 @@ def printMakeSuite(self):
self.outputFile.write(' use '+ self.wrapModuleName + '\n')
self.outputFile.write(' implicit none'+ '\n')
self.outputFile.write(' type (TestSuite) :: suite\n\n')
self.outputFile.write(' class (Test), allocatable :: t\n\n')
self.outputFile.write(' class (Test), allocatable :: t\n')
self.outputFile.write(' type(StringTestAnnotationMap), pointer :: annotations\n\n')

if not self.userModuleName:
for testMethod in self.userTestMethods:
Expand Down Expand Up @@ -842,7 +843,8 @@ def addSimpleTestMethod(self, testMethod):
self.outputFile.write(' if(allocated(t)) deallocate(t)\n')
self.outputFile.write(' allocate(t, source=' + type + '(' + args + '))\n')
if ('disable' in testMethod):
self.outputFile.write(' call t%insert(Disable%type_name(),Disable)\n')
self.outputFile.write(' annotations => t%get_annotations()\n')
self.outputFile.write(' call annotations%insert(Disable%type_name(),Disable)\n')
self.outputFile.write(' call suite%addTest(t)\n')

def addMpiTestMethod(self, testMethod):
Expand Down
2 changes: 1 addition & 1 deletion src/funit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function(funit_target_link_pfunit funit_target)
message(FATAL_ERROR "Could not find gFTL-shared. This should not happen.")
endif ()

target_link_libraries (${funit_target} PUBLIC GFTL::gftl GFTL_SHARED::gftl-shared FARGPARSE::fargparse)
target_link_libraries (${funit_target} PUBLIC GFTL::gftl GFTL::gftl-v2 GFTL_SHARED::gftl-shared FARGPARSE::fargparse)
target_include_directories(${funit_target} PUBLIC
$<BUILD_INTERFACE:${PFUNIT_SOURCE_DIR}/include>
)
Expand Down
2 changes: 2 additions & 0 deletions src/funit/core/FUnit_Core.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module FUnit_Core
use PF_SerialContext

use Pf_TestAnnotation
use pf_StringTestAnnotationMap
use Pf_DisableAnnotation
use Pf_TimeoutAnnotation

Expand Down Expand Up @@ -87,6 +88,7 @@ end function LoadTests_interface
end interface

public :: TestAnnotation
public :: StringTestAnnotationMap
public :: Disable
public :: TimeoutAnnotation

Expand Down
10 changes: 7 additions & 3 deletions src/funit/core/RemoteProxyTestCase.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module PF_RemoteProxyTestCase
use pf_Posix
use pf_File
use pf_TestAnnotation
use pf_StringTestAnnotationMap
use pf_TimeoutAnnotation
use pf_TestTimer
implicit none
Expand Down Expand Up @@ -60,10 +61,13 @@ function newRemoteProxyTestCase(a_test, f, max_time) result(proxy)
type(File), intent(in) :: f
real, intent(in) :: max_time

class(StringTestAnnotationMap), pointer :: annotations
class(TestAnnotation), pointer :: annotation
integer :: status

if (a_test%count('Timeout') == 1) then
annotation => a_test%at('Timeout')
annotations => a_test%get_annotations()
if (annotations%count('Timeout') == 1) then
annotation => annotations%at('Timeout', rc=status)
! cast
select type (annotation)
class is (TimeoutAnnotation)
Expand All @@ -77,7 +81,7 @@ function newRemoteProxyTestCase(a_test, f, max_time) result(proxy)
call proxy%setName(a_test%getName())

if(a_test%is_disabled()) then
call proxy%insert(Disable%type_name(),Disable)
call annotations%insert(Disable%type_name(),Disable)
end if

end function newRemoteProxyTestCase
Expand Down
15 changes: 13 additions & 2 deletions src/funit/core/Test.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ module PF_Test
public :: Test

! Abstract class from which other Test classes inherit
type, abstract, extends(StringTestAnnotationMap) :: Test
type, abstract :: Test
private
type(StringTestAnnotationMap) :: annotations
integer :: placeholder
contains
procedure(countTestCases), deferred :: countTestCases
Expand All @@ -39,6 +41,7 @@ module PF_Test
procedure :: setName

procedure :: is_disabled
procedure :: get_annotations
end type Test

abstract interface
Expand Down Expand Up @@ -80,8 +83,16 @@ end subroutine setName
logical function is_disabled(this)
class (Test), intent(in) :: this

is_disabled = (this%count(Disable%type_name()) == 1)
is_disabled = (this%annotations%count(Disable%type_name()) == 1)

end function is_disabled


function get_annotations(this) result(annotations)
type(StringTestAnnotationMap), pointer :: annotations
class(Test), target, intent(in) :: this

annotations => this%annotations
end function get_annotations

end module PF_Test
23 changes: 15 additions & 8 deletions src/funit/core/TestAnnotation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ end module pf_TestAnnotation
module pf_StringTestAnnotationMap
use pf_TestAnnotation

#define _map StringTestAnnotationMap
#define _iterator StringTestAnnotationMapIterator
#define _pair StringTestAnnotationPair
#include "types/key_deferredLengthString.inc"
#define _value_allocatable
#define _value class(TestAnnotation)
#define _alt
#include "templates/map.inc"
#define Key __CHARACTER_DEFERRED
#define T TestAnnotation
#define T_polymorphic
#define Map StringTestAnnotationMap
#define MapIterator StringTestAnnotationMapIterator
#define Pair StringTestAnnotationPair

#include "map/template.inc"

#undef Pair
#undef MapIterator
#undef Map
#undef T
#undef T_polymorphic
#undef Key

end module pf_StringTestAnnotationMap
13 changes: 10 additions & 3 deletions tests/funit-core/Test_DisableTest.pf
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ contains
type (TestSuite) :: s
type (TestRunner) :: r
type (TestResult) :: rslt
class (Test), allocatable :: t
class (Test), target, allocatable :: t
integer :: unit
type(StringTestAnnotationMap), pointer :: annotations

s = TestSuite()
t = TestMethod('test_is_disabled',test_is_disabled)
call t%insert(Disable%type_name(), Disable)
print*,__FILE__,__LINE__
allocate(t, source= TestMethod('test_is_disabled',test_is_disabled))
print*,__FILE__,__LINE__
annotations => t%get_annotations()
print*,__FILE__,__LINE__
call annotations%insert(Disable%type_name(), Disable)
print*,__FILE__,__LINE__
call s%addTest(t)
print*,__FILE__,__LINE__

t = TestMethod('test_is_not_igored',test_is_not_disabled)
call s%addTest(t)
Expand Down
6 changes: 4 additions & 2 deletions tests/funit-core/robustTestSuite.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ function suite()
use PF_TestMethod, only: TestMethod
type (TestSuite) :: suite

class (Test), allocatable :: t
class (Test), target, allocatable :: t
type(TimeoutAnnotation) :: timeout
type(StringTestAnnotationMap), pointer :: annotations

suite = TestSuite('robustTestSuite')

Expand All @@ -45,7 +46,8 @@ function suite()

t = TestMethod('testRunHangs', testRunHangs)
timeout = TimeoutAnnotation(0.1)
call t%insert(timeout%type_name(), timeout)
annotations => t%get_annotations()
call annotations%insert(timeout%type_name(), timeout)
call suite%addTest( t )

call suite%addTest( TestMethod('testRunStops', testRunStops) )
Expand Down
Loading