SQLite Forum

testsuite: apply explicit check if symlinks work on platform

testsuite: apply explicit check if symlinks work on platform

(1) By Jannick on 2020-11-24 11:54:21 [source]

There are Unix-like platforms on which symlinks do not necessarily work dependant on the system configuration (example: MSYS2). For tests it would be helpful to explicitly check if symlinks work or not instead of simply using the platform name.

The procedure CHECK_FILES_EQUAL below could be moved to the test library file to apply it whenever checks assume symlinks to properly work. Something along the lines of the simple sample patch for test/symlink.test below could do the job here and in other places where tests assume symlinks to work.


diff --git a/test/symlink.test b/test/symlink.test
index 98b2a32..f1d432c 100644
--- a/test/symlink.test
+++ b/test/symlink.test
@@ -28,6 +28,28 @@ do_execsql_test 1.0 {
   CREATE TABLE t1(x, y);
+proc check_files_equal {file1 file2} {
+  set rc 0
+  if {[file size $file1] == [file size $file2]} {
+    set fd1 [open $file1 r]
+    set fd2 [open $file2 r]
+    set rc [string equal [read $fd1] [read $fd2]]
+    close $fd1
+    close $fd2
+  }
+  return $rc
+## Test whether on platform softlinks are file copies.
+forcedelete test.db2
+file link test.db2 test.db
+if {[check_files_equal test.db test.db2]} {
+  output2 "!Skipping test '$testprefix' since softlinks are file copies on system."
+  finish_test
+  return

(2) By Dan Kennedy (dan) on 2020-11-24 17:08:16 in reply to 1 [link] [source]

The patch seems to disable the test on regular Linux as well.

How do you get a libtcl for which {$tcl_platform(platform)=="unix"} on msys2? Is it a cygwin build or something like that?

(3) By Jannick on 2020-11-29 20:24:27 in reply to 2 [link] [source]

1 - Yes, the file size test is a brigde too far, it should be removed.  I thought 'file size' looks through a link, but it appears that this is not the case.

2 - Yes, too: It is a CYGWIN-build which - as I learned during the last days looking at the tcl package - is a bit of a pain.  Sadly, Tcl does properly compile out of the box for CYGWIN-like platforms.  Extensive patches are required effectively removing __CYGWIN__ branches in the code.

Here my contribution to have an automated compilation for MSYS2 (github workflow plus patches to get things up and running for the test suite) as a start for the tcl devels to fix things for CYGWIN-like platforms: https://core.tcl-lang.org/tcl/tktview/1315cf2868bbf215add0e3d605ca6ef8f69de679.

I am still inclined to a solution checking if symbolic links (soft/hard) work or not for the sqlite testsuite.

Thanks for looking at this.