SQLite Forum

testsuite: apply explicit check if symlinks work on platform
Login
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.

Thanks.

~~~diff
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
+}
+
~~~