Skip to content

Commit

Permalink
Add memory leak hunter to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chpock committed May 29, 2024
1 parent 4589c3f commit f5c5af5
Show file tree
Hide file tree
Showing 16 changed files with 438 additions and 53 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2024-05-29 Konstantin Kushnir <[email protected]>
* Fix a regression when register volume and unregister with vfs::unmount
* Add memory leak hunter to tests

2024-05-28 Konstantin Kushnir <[email protected]>
* Add cppcheck
Expand Down
2 changes: 1 addition & 1 deletion tests/all.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if {[info tclversion] == "8.5"} {
source [file join [tcltest::testsDirectory] common.tcl]

if {[info exists ::env(MEMDEBUG)]} {
source [file join [tcltest::testsDirectory] memdebug.tcl]
source [file join [tcltest::testsDirectory] memleakhunter.tcl]
}

set constraints [tcltest::configure -constraints]
Expand Down
21 changes: 15 additions & 6 deletions tests/common.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ proc testIfEqual {a b} {
return "1"
}

set testcompresscount 0
set testdecompresscount 0
set testasynccompresscount 0
proc testcompresscleanup {} {
unset -nocomplain ::testcompresscount ::testdecompresscount
}

proc testcompress {d {count 1}} {
incr ::testcompresscount $count
Expand All @@ -222,6 +222,15 @@ proc testdecompress {d {count 1}} {
return $rc
}

proc testasynccleanup {} {
unset -nocomplain ::testasynccompressqueue ::testasynccompressqueuesize ::testasynccompressfinalized
unset -nocomplain ::testasyncdecompressqueue ::testasyncdecompressqueuesize ::testasyncdecompressfinalized
unset -nocomplain ::testasynccompresscount ::testasyncdecompresscount
unset -nocomplain ::testasyncdecompresswaitcount
unset -nocomplain ::testasyncdecompressprocesscount
testcompresscleanup
}

proc testasynccompress {cmd idx arg} {
set rc {}
if {[catch {
Expand Down Expand Up @@ -305,8 +314,9 @@ proc testasyncdecompressrandom {cmd idx arg} {
return $rc
}

set testcompresscountraw 0
set testdecompresscountraw 0
proc testrawcleanup {} {
unset -nocomplain ::testcompresscountraw ::testdecompresscountraw
}

proc testcompressraw {d} {
incr ::testcompresscountraw
Expand All @@ -318,4 +328,3 @@ proc testdecompressraw {d} {
set rc [binary format H* [string range $d 8 end]]
return $rc
}

4 changes: 4 additions & 0 deletions tests/compression.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ foreach { cid } { none zlib bz2 xz } {
} -result 1 -cleanup {
catch { vfs::unmount $file }
file delete -force $file $dir
unset -nocomplain ok file dir
}

tcltest::test "${test_title}-2" {store uncompressed small data} -constraints $constraint -setup {
Expand All @@ -52,6 +53,7 @@ foreach { cid } { none zlib bz2 xz } {
catch { vfs::unmount $file }
catch { $pg delete }
file delete -force $file $dir
unset -nocomplain pg page_size ok file dir
}

tcltest::test "${test_title}-3" {store uncompressed large data} -constraints $constraint -setup {
Expand Down Expand Up @@ -86,6 +88,7 @@ foreach { cid } { none zlib bz2 xz } {
catch { vfs::unmount $file }
catch { $pg delete }
file delete -force $file $dir
unset -nocomplain pg page_size ok file file1 dir fp data
}

tcltest::test "${test_title}-4" {store compressed} -constraints $constraint -setup {
Expand Down Expand Up @@ -119,6 +122,7 @@ foreach { cid } { none zlib bz2 xz } {
catch { vfs::unmount $file }
catch { $pg delete }
file delete -force $file $dir
unset -nocomplain pg page_size ok file dir
}

}
3 changes: 3 additions & 0 deletions tests/cookfswriter.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ tcltest::test cookfsWriter-1.1 "Create empty archive" -constraints runCookfsWrit
} -cleanup {
catch {vfs::unmount $file}
catch {file delete -force $file}
unset -nocomplain file
} -returnCodes {ok}

tcltest::test cookfsWriter-1.2 "Create empty archive with bootstrap" -constraints runCookfsWriter -setup {
Expand All @@ -22,6 +23,7 @@ tcltest::test cookfsWriter-1.2 "Create empty archive with bootstrap" -constraint
} -cleanup {
catch {vfs::unmount $file}
catch {file delete -force $file}
unset -nocomplain file p fsid
} -returnCodes {ok}

tcltest::test cookfsWriter-1.3 "Create non-empty archive with bootstrap" -constraints runCookfsWriter -setup {
Expand Down Expand Up @@ -53,4 +55,5 @@ tcltest::test cookfsWriter-1.3 "Create non-empty archive with bootstrap" -constr
catch {close $fh}
catch {vfs::unmount $file}
catch {file delete -force $file}
unset -nocomplain file files fsid p fh
} -returnCodes {ok}
4 changes: 4 additions & 0 deletions tests/dedup.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tcltest::test cookfsDedup-1.1 "Large file deduplication" -setup {
} -cleanup {
catch {vfs::unmount $file}
tcltest::removeFile $file
unset -nocomplain file datas c i fh fs d
} -result 1

tcltest::test cookfsDedup-1.2 "Small file deduplication for same resulting pages" -setup {
Expand All @@ -38,6 +39,7 @@ tcltest::test cookfsDedup-1.2 "Small file deduplication for same resulting pages
} -cleanup {
catch {vfs::unmount $file}
tcltest::removeFile $file
unset -nocomplain file datas c i fh fs d
} -result 1

tcltest::test cookfsDedup-1.3 "Small file deduplication for different resulting pages" -setup {
Expand Down Expand Up @@ -79,6 +81,7 @@ tcltest::test cookfsDedup-1.3 "Small file deduplication for different resulting
} -cleanup {
catch {vfs::unmount $file}
tcltest::removeFile $file
unset -nocomplain file datas c files f d fh fs result
} -match glob -result {1
file1 * 2048 {0 0 2048} 1
file2 * 2048 {0 2048 2048} 1
Expand Down Expand Up @@ -134,6 +137,7 @@ tcltest::test cookfsDedup-1.4 "Small file deduplication for different resulting
} -cleanup {
catch {vfs::unmount $file}
tcltest::removeFile $file
unset -nocomplain file datas c files f d fh fs result
} -match glob -result {1
file1 * 2048 {0 0 2048} 1
file2 * 2048 {0 2048 2048} 1
Expand Down
Loading

0 comments on commit f5c5af5

Please sign in to comment.