Unix make test does not test embedded zip configuration
This parallels b6f7cee65 for Win nmake which has been fixed. Didn't realize Unix has the same issue.
The make test target sets TCL_LIBRARY before invoking tcltest even when --enable-zipfs has been configured. Consequently it is not actually testing the build configuration and is loading Tcl scripts from the source directory instead of from the embedded zip.
This can be confirmed by adding
puts $tcl_library
puts [zipfs mount]
to any test script.
Anyone fixing this, please also reword the help message for --enable-zipfs or even change the option name. Both the option and the help imply disabling will remove zipfs support. That is not the case. zipfs support is always included in the build. The option only controls whether the Tcl library is embedded within the executable. Commands like zipfs mount etc. will continue to work irrespective of the option setting.
127fc5ae5dMerge [b82abeca2e7bd583]: "Bug [894e11d7f7] - fix broken test configuration for zipfs builds - nmake version" and "Minor nmake tweaks, remove obsolete target". check-in2024-08-22 19:00:563747465377New ticket [2a0966cdc9] [encoding dirs] default values. ticket2023-10-23 19:39:43ef07c271adBug [894e11d7f7] - fix broken test configuration for zipfs builds - nmake version check-in2023-10-11 03:57:00843fa79403Bug [894e11d7f7] - fix broken test configuration for zipfs builds - nmake version check-in2023-10-10 15:01:28effd49d19fBug [894e11d7f7]. Fix Unix test runs to use embedded Tcl zipfs scripts and not external ones from the library directory. check-in2023-10-09 11:32:43
The issue, for both Windows and Unix, turned out to be deeper. The make/nmake test targets do not bind the zipfs to the executable at all so even if TCL_LIBRARY is not defined the init "guesses" tcl_library to be in the source root/library path.
Thus test runs have not really tested whether the created Tcl library archive is in fact usable.
(Note the zipfs.test tests are mostly unaffected as they explicitly load archives. The above refers to Tcl's reading of its script libraries)
Unix builds fixed in [effd49d19f]. Windows work ongoing.
Checkin [effd49d19f] creates new test failure:
==== encoding-28.0 all encodings load FAILED
==== Contents of test case:
set string hello
foreach name [encoding names] {
if {$name ne "unicode"} {
incr count
}
encoding convertto -profile tcl8 $name $string
# discard the cached internal representation of Tcl_Encoding
# Unfortunately, without this, encoding 2-1 fails.
llength $name
}
return $count
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: invalid encoding file "tis-620"
while executing
"encoding convertto -profile tcl8 $name $string"
("foreach" body line 5)
invoked from within
"foreach name [encoding names] {
if {$name ne "unicode"} {
incr count
}
encoding convertto -profile tcl8 $name $string
# discard the cac..."
("uplevel" body line 3)
invoked from within
"uplevel 1 $script"
---- errorCode: TCL LOOKUP ENCODING tis-620
==== encoding-28.0 FAILED
Creates several more as well (in cmdAH.test), but I think they are all in common.
In case it matters, the test failure is with a build configuration $ ./configure --disable-shared ... $ make test-tcl TESTFLAGS="-file encoding.test" <see last comment>
I had tested that config before commit. Retried with but not able to reproduce these failures with core-8-branch, trunk or with effd49d19f. See (edited) test logs below. Both encoding and cmdAH tests pass. Last time the difference in our environments was the presence of the threads package. Tested with that as well with no failures (there are no thread constraints in any case).
This was on Ubuntu. If you are on a Mac, it's quite possible there is a bug in there somewhere as is currently ticketed for password based zips on Mac. OTOH, github tests on MacOS pass without issues.
It would be a useful data point if you can manually reproduce the bug with that commit and then try it with the prior commit ensuring that the build actually embedded tcl_library within the executable and TCL_LIBRARY was not set. The problem with test runs prior to effd49d19f was that they set TCL_LIBRARY and thus did not actually test whether encoding files were readable from the zip. That commit purportedly fixed that and potentially exposed existing issues. A manual test would help provide some clue.
Anyways, my test runs
[apn@tcltk build]$ make -s test-tcl TESTFLAGS="-file encoding.test"
Warning: tclStubInit.c may be out of date.
Developers may want to run "make genstubs" to regenerate.
This warning can be safely ignored, do not report as a bug!
Warning: tclOOScript.h may be out of date.
Developers may want to run "make genscript" to regenerate.
This warning can be safely ignored, do not report as a bug!
creating libtcl.vfs/tcl_library (prepare compression)
creating libtcl8.7a6.zip from libtcl.vfs/tcl_library
cd libtcl.vfs && /usr/bin/zip -rq ../libtcl8.7a6.zip *
Zip entry offsets appear off by 2057920 bytes - correcting...
Zip entry offsets appear off by 2184472 bytes - correcting...
Tests running in interp: /data/home/apn/src/wip/tcl/unix/build/tcltest
Tests located in: /data/home/apn/src/wip/tcl/tests
Tests running in: /data/home/apn/src/wip/tcl/unix/build
Temporary files stored in /data/home/apn/src/wip/tcl/unix/build
Test files run in separate interpreters
Running tests that match: *
Skipping test files that match: l.*.test
Only running test files that match: encoding.test
Tests began at Wed Oct 11 17:21:28 CEST 2023
encoding.test
Tests ended at Wed Oct 11 17:21:29 CEST 2023
all.tcl: Total 212 Passed 212 Skipped 0 Failed 0
Sourced 1 Test Files.
[apn@tcltk build]$ ls -l tcltest
-rwxr-xr-x 1 apn apn 3368234 Oct 11 17:21 tcltest
Tcl 9
[apn@tcltk build]$ make -s test-tcl TESTFLAGS="-file encoding.test"
Warning: tclStubInit.c may be out of date.
Developers may want to run "make genstubs" to regenerate.
This warning can be safely ignored, do not report as a bug!
Warning: tclOOScript.h may be out of date.
Developers may want to run "make genscript" to regenerate.
This warning can be safely ignored, do not report as a bug!
creating libtcl.vfs/tcl_library (prepare compression)
creating libtcl9.0a4.zip from libtcl.vfs/tcl_library
cd libtcl.vfs && /usr/bin/zip -rq ../libtcl9.0a4.zip *
Zip entry offsets appear off by 2075072 bytes - correcting...
Zip entry offsets appear off by 2211368 bytes - correcting...
Tests running in interp: /data/home/apn/src/wip/tcl/unix/build/tcltest
Tests located in: /data/home/apn/src/wip/tcl/tests
Tests running in: /data/home/apn/src/wip/tcl/unix/build
Temporary files stored in /data/home/apn/src/wip/tcl/unix/build
Test files run in separate interpreters
Running tests that match: *
Skipping test files that match: l.*.test
Only running test files that match: encoding.test
Tests began at Wed Oct 11 18:03:26 CEST 2023
encoding.test
Tests ended at Wed Oct 11 18:03:27 CEST 2023
all.tcl: Total 216 Passed 212 Skipped 4 Failed 0
Sourced 1 Test Files.
Number of tests skipped for each constraint:
4 perf
[apn@tcltk build]$ ls -l tcltest
-rwxr-xr-x 1 apn apn 3390738 Oct 11 18:03 tcltest
[apn@tcltk build]$ ls -l tcltest
-rwxr-xr-x 1 apn apn 3390738 Oct 11 18:03 tcltest
[apn@tcltk build]$ make -s test-tcl TESTFLAGS="-file cmdAH.test"
Warning: tclStubInit.c may be out of date.
Developers may want to run "make genstubs" to regenerate.
This warning can be safely ignored, do not report as a bug!
Warning: tclOOScript.h may be out of date.
Developers may want to run "make genscript" to regenerate.
This warning can be safely ignored, do not report as a bug!
Tests running in interp: /data/home/apn/src/wip/tcl/unix/build/tcltest
Tests located in: /data/home/apn/src/wip/tcl/tests
Tests running in: /data/home/apn/src/wip/tcl/unix/build
Temporary files stored in /data/home/apn/src/wip/tcl/unix/build
Test files run in separate interpreters
Running tests that match: *
Skipping test files that match: l.*.test
Only running test files that match: cmdAH.test
Tests began at Wed Oct 11 18:05:24 CEST 2023
cmdAH.test
Tests ended at Wed Oct 11 18:05:30 CEST 2023
all.tcl: Total 16617 Passed 16587 Skipped 30 Failed 0
Sourced 1 Test Files.
Number of tests skipped for each constraint:
1 knownBug
8 nonPortable
21 win
[apn@tcltk build]$ fossil checkout effd49d19f
[apn@tcltk build]$ make -s test-tcl TESTFLAGS="-file encoding.test"
Warning: tclStubInit.c may be out of date.
Developers may want to run "make genstubs" to regenerate.
This warning can be safely ignored, do not report as a bug!
Warning: tclOOScript.h may be out of date.
Developers may want to run "make genscript" to regenerate.
This warning can be safely ignored, do not report as a bug!
creating libtcl.vfs/tcl_library (prepare compression)
creating libtcl8.7a6.zip from libtcl.vfs/tcl_library
cd libtcl.vfs && /usr/bin/zip -rq ../libtcl8.7a6.zip *
Zip entry offsets appear off by 2057960 bytes - correcting...
Zip entry offsets appear off by 2184512 bytes - correcting...
Tests running in interp: /data/home/apn/src/wip/tcl/unix/build/tcltest
Tests located in: /data/home/apn/src/wip/tcl/tests
Tests running in: /data/home/apn/src/wip/tcl/unix/build
Temporary files stored in /data/home/apn/src/wip/tcl/unix/build
Test files run in separate interpreters
Running tests that match: *
Skipping test files that match: l.*.test
Only running test files that match: encoding.test
Tests began at Wed Oct 11 18:09:29 CEST 2023
encoding.test
Tests ended at Wed Oct 11 18:09:30 CEST 2023
all.tcl: Total 212 Passed 212 Skipped 0 Failed 0
[apn@tcltk build]$ make -s test-tcl TESTFLAGS="-file cmdAH.test"
Warning: tclStubInit.c may be out of date.
Developers may want to run "make genstubs" to regenerate.
This warning can be safely ignored, do not report as a bug!
Warning: tclOOScript.h may be out of date.
Developers may want to run "make genscript" to regenerate.
This warning can be safely ignored, do not report as a bug!
Tests running in interp: /data/home/apn/src/wip/tcl/unix/build/tcltest
Tests located in: /data/home/apn/src/wip/tcl/tests
Tests running in: /data/home/apn/src/wip/tcl/unix/build
Temporary files stored in /data/home/apn/src/wip/tcl/unix/build
Test files run in separate interpreters
Running tests that match: *
Skipping test files that match: l.*.test
Only running test files that match: cmdAH.test
Tests began at Wed Oct 11 18:10:51 CEST 2023
cmdAH.test
Tests ended at Wed Oct 11 18:10:58 CEST 2023
all.tcl: Total 16746 Passed 16715 Skipped 31 Failed 0
Sourced 1 Test Files.
Number of tests skipped for each constraint:
1 knownBug
8 nonPortable
22 win
I am on a CentOS 7 system and my compiler is gcc 4.8.5 Every variant I try on what executable to run and how to launch it shows the same failures. I notice that the purportedly failing encoding file is tis-620.enc . Can you confirm your testing is including it?
A simple start at some debugging reveals that the failure comes in LoadTableEncoding() where Tcl_ReadChars() reports that 1042 chars were read, while LoadTableEncoding() has calculated that it expects to see 1043. There are other singlebyte table encoding files apparently working fine.
The final trailing newline is not appearing in the channel input buffers. I'm guessing the trouble must be somewhere in the zipfs drivers. Slow going.
Thanks, that at least gives me some direction to look at. I checked I have tis-620, both by printing in the test case as well as manually executing encoding convert{to,from}.
I presume doing
encoding convertto [encoding convertfrom tis-620 \xA1]
in tclsh also fails for you?
I see the following data if I read the file. Could you verify you see the same?
% file size //zipfs:/app/tcl_library/encoding/tis-620.enc
1092
% set tis //zipfs:/app/tcl_library/encoding/tis-620.enc
//zipfs:/app/tcl_library/encoding/tis-620.enc
% set fd [ open $tis rb]; set data [read $fd]; close $fd; string length $data
1092
% puts $data
# Encoding file: tis-620, single-byte
S
003F 0 1
00
0000000100020003000400050006000700080009000A000B000C000D000E000F
0010001100120013001400150016001700180019001A001B001C001D001E001F
0020002100220023002400250026002700280029002A002B002C002D002E002F
0030003100320033003400350036003700380039003A003B003C003D003E003F
0040004100420043004400450046004700480049004A004B004C004D004E004F
0050005100520053005400550056005700580059005A005B005C005D005E005F
0060006100620063006400650066006700680069006A006B006C006D006E006F
0070007100720073007400750076007700780079007A007B007C007D007E007F
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000E010E020E030E040E050E060E070E080E090E0A0E0B0E0C0E0D0E0E0E0F
0E100E110E120E130E140E150E160E170E180E190E1A0E1B0E1C0E1D0E1E0E1F
0E200E210E220E230E240E250E260E270E280E290E2A0E2B0E2C0E2D0E2E0E2F
0E300E310E320E330E340E350E360E370E380E390E3A00000000000000000E3F
0E400E410E420E430E440E450E460E470E480E490E4A0E4B0E4C0E4D0E4E0E4F
0E500E510E520E530E540E550E560E570E580E590E5A0E5B0000000000000000
%
(Note the blank line at the end)
I will dig in more later today
Also, are you working with current core-8-branch or the original commit? Some bugs are likely to have been fixed since then though probably not related. Just to make sure not chasing down fixed issues.
I have traced through and do not see anything suspicious about the read data or counts. After tclsh is at the command prompt, set a break point at ZipChannelOpen and ZipChannelRead. Then ran the command
encoding convertfrom tis-620 \xa1
ZipChannel{Open,Read} called multiple times for different files (tclIndex etc.).
Eventually invoked for tis-620.enc, the read request (ZipChannelRead.toRead) is for 4096 bytes. ZipChannelRead then returns the entire 1092 bytes of the file.
After processing the header lines, LoadTableEncoding calls Tcl_Read(toRead=1043)->DoReadChars(toRead=1043)->ReadChars. This returns 1043 bytes as expected.
The first thing then is if to check if file size //zipfs:/app/tcl_library/encoding/tis-620.enc returns 1092 or not. If not, that would point to either the zipping or unzipping code. If it does return the correct size, then the channel related code needs to be looked at.
Also, since I cannot reproduce the failure, I suggest you upload your libtcl*.zip file somewhere that I can download (let me know which branch or commit). Just in case, I'll be able to reproduce the failure with that.
Does CentOS 7 have a smaller buffer-size? Like 512 or 1024 in stead of 4096. That would explain why the data is not read in one go.
I don't think it is a OS issue. The 4096 comes from CHANNELBUFFER_DEFAULT_SIZE; it's the buffer size at the Tcl Channel API level.
This may be a false alarm. % encoding dirs /home/dgp/x86_64/linuxoldld/lib/tcl8.7/encoding //zipfs:/app/tcl_library/encoding Whether or not that should be the search path for encodings in this build configuration might still be an open question. But.... accepting that search path, there was a tis-620.enc file there in the installed area, and I don't know when or how or why or why it's never caused trouble before the recent checkin..... ...but that file was indeed missing its final newline.
As a lesson from this experience, let me suggest that the error message invalid encoding file "tis-620" ought to report the full path of the invalid file.
After repairing the corrupt installed tis-620.enc file, the test file encoding.test is now reporting no failures. The cmdAH.test failures are still present. I imagine they are due to one of the other installed files being out of date. Exploring now.
Twenty-nine of the installed *.enc files are different from the corresponding files on the core-8-branch. A 'make install' apparently no longer installs *.enc files (because they're in the zipfs!) so the outdated broken files never get overwritten and live forever. Until recently, `make test` used a TCL_LIBRARY to force use of the *.enc files from the sandbox, so the broken files were never detected. So this is a scenario where installers of old 8.7 alphas might have the problem. My local fix is to remove the directory full of outdated files.
After preventing the use of broken, outdated *.enc files, I get a clean `make test-tcl` result on core-8-branch. When I then try `make test-tcl TESTFLAGS='-singleproc 1'` I get a huge number of errors and failures. This also seems to be peculiar to my system. Working on locating the problem(s).
Closing as fixed. The request to include full path in error message not done as it will take refactoring that I'm loath to do at this point. (Only the encoding name is available at the point the error is detected.)