summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-09-26 05:03:28 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-09-26 05:03:28 (GMT)
commitb19cf92301ef772bd85dafa484d8271bd046f917 (patch)
tree43d5ad90226b885e1a09da8d3db2eefdfa69584f
parent3dce0b31fc75ae153d7e698c1adde5de6fd7dec3 (diff)
downloadtcl-b19cf92301ef772bd85dafa484d8271bd046f917.zip
tcl-b19cf92301ef772bd85dafa484d8271bd046f917.tar.gz
tcl-b19cf92301ef772bd85dafa484d8271bd046f917.tar.bz2
Add tests
-rw-r--r--generic/tclZipfs.c4
-rw-r--r--tests/zipfs.test33
2 files changed, 30 insertions, 7 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index ceccd9e..63392b8 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -4343,9 +4343,7 @@ ZipChannelWrite(
return -1;
}
if (toWrite > info->maxWrite - info->numRead) {
- toWrite = info->maxWrite - info->numRead;
- }
- if (toWrite == 0) {
+ /* Don't do partial writes in error case. Or should we? */
*errloc = EFBIG;
return -1;
}
diff --git a/tests/zipfs.test b/tests/zipfs.test
index 2c4775f..cb45b05 100644
--- a/tests/zipfs.test
+++ b/tests/zipfs.test
@@ -1073,7 +1073,7 @@ namespace eval test_ns_zipfs {
set result
} -result [list newtext test\n]
- test zipfs-write-size-limit-0 "Writes have a size limit" -setup {
+ test zipfs-write-size-limit-0 "Writes more than size limit with flush" -setup {
set origlimit $::tcl::zipfs::wrmax
mount [zippath test.zip]
} -cleanup {
@@ -1083,10 +1083,35 @@ namespace eval test_ns_zipfs {
} -body {
set ::tcl::zipfs::wrmax 10
set fd [open [file join $defaultMountPoint test] w]
- puts -nonewline $fd [string repeat x 11]
- } -result {} -returnCodes error -constraints bug-d5d03207ca
+ puts $fd [string repeat x 11]
+ flush $fd
+ } -result {error flushing *: file too large} -match glob -returnCodes error
- test zipfs-write-size-limit-1 "Writes disallowed" -setup {
+ test zipfs-write-size-limit-1 "Writes size limit on close" -setup {
+ set origlimit $::tcl::zipfs::wrmax
+ mount [zippath test.zip]
+ } -cleanup {
+ set ::tcl::zipfs::wrmax $origlimit
+ cleanup
+ } -body {
+ set ::tcl::zipfs::wrmax 10
+ set fd [open [file join $defaultMountPoint test] w]
+ puts $fd [string repeat x 11]
+ close $fd
+ } -result {file too large} -match glob -returnCodes error
+
+ test zipfs-write-size-limit-2 "Writes max size" -setup {
+ mount [zippath test.zip]
+ } -cleanup {
+ cleanup
+ } -body {
+ set fd [open [file join $defaultMountPoint test] w]
+ puts -nonewline $fd [string repeat x $::tcl::zipfs::wrmax]
+ close $fd
+ file size [file join $defaultMountPoint test]
+ } -result $::tcl::zipfs::wrmax
+
+ test zipfs-write-size-limit-3 "Writes disallowed" -setup {
set origlimit $::tcl::zipfs::wrmax
mount [zippath test.zip]
} -cleanup {