Fossil SCM

Skip tests needing loopback if it is unavailable, eg on isolated network namespaces.

danshearer 2026-11-11 08:32 UTC test-suite-new
Commit 1b458fd37748449cdca76285ba7121651e49a95526954fb77afa3f57000943d9
--- test/tester.tcl
+++ test/tester.tcl
@@ -856,10 +856,25 @@
856856
}
857857
append out \n$line
858858
}
859859
return [string range $out 1 end]
860860
}
861
+
862
+# Return true if a TCP connection can be made over the loopback interface,
863
+# as the tests that run "fossil server" need. Listening succeeds even when
864
+# the interface is down, so this procedure also connects.
865
+proc loopback_available {} {
866
+ if {[catch {socket -server {apply {{c a p} {close $c}}} \
867
+ -myaddr 127.0.0.1 0} srv]} {
868
+ return 0
869
+ }
870
+ set port [lindex [fconfigure $srv -sockname] 2]
871
+ set ok [expr {[catch {socket 127.0.0.1 $port} cli] == 0}]
872
+ if {$ok} { close $cli }
873
+ close $srv
874
+ return $ok
875
+}
861876
862877
# This procedure executes the "fossil server" command. The return value
863878
# is a list comprised of the new process identifier and the port on which
864879
# the server started. The varName argument refers to a variable
865880
# where the "stop argument" is to be stored. This value must eventually be
866881
--- test/tester.tcl
+++ test/tester.tcl
@@ -856,10 +856,25 @@
856 }
857 append out \n$line
858 }
859 return [string range $out 1 end]
860 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
861
862 # This procedure executes the "fossil server" command. The return value
863 # is a list comprised of the new process identifier and the port on which
864 # the server started. The varName argument refers to a variable
865 # where the "stop argument" is to be stored. This value must eventually be
866
--- test/tester.tcl
+++ test/tester.tcl
@@ -856,10 +856,25 @@
856 }
857 append out \n$line
858 }
859 return [string range $out 1 end]
860 }
861
862 # Return true if a TCP connection can be made over the loopback interface,
863 # as the tests that run "fossil server" need. Listening succeeds even when
864 # the interface is down, so this procedure also connects.
865 proc loopback_available {} {
866 if {[catch {socket -server {apply {{c a p} {close $c}}} \
867 -myaddr 127.0.0.1 0} srv]} {
868 return 0
869 }
870 set port [lindex [fconfigure $srv -sockname] 2]
871 set ok [expr {[catch {socket 127.0.0.1 $port} cli] == 0}]
872 if {$ok} { close $cli }
873 close $srv
874 return $ok
875 }
876
877 # This procedure executes the "fossil server" command. The return value
878 # is a list comprised of the new process identifier and the port on which
879 # the server started. The varName argument refers to a variable
880 # where the "stop argument" is to be stored. This value must eventually be
881
--- test/unversioned.test
+++ test/unversioned.test
@@ -319,10 +319,15 @@
319319
320320
fossil user new uvtester "Unversioned Test User" $password
321321
fossil user capabilities uvtester oy
322322
323323
###############################################################################
324
+
325
+if {![loopback_available]} {
326
+ test_skip "Loopback networking is not available, so the tests that run\
327
+\"fossil server\" cannot start a server."
328
+}
324329
325330
foreach {pid port outTmpFile} [test_start_server $repository stopArg] {}
326331
if {! $::QUIET} {
327332
puts [appendArgs "Started Fossil server, pid \"" $pid \" ", port \"" $port \".]
328333
}
329334
--- test/unversioned.test
+++ test/unversioned.test
@@ -319,10 +319,15 @@
319
320 fossil user new uvtester "Unversioned Test User" $password
321 fossil user capabilities uvtester oy
322
323 ###############################################################################
 
 
 
 
 
324
325 foreach {pid port outTmpFile} [test_start_server $repository stopArg] {}
326 if {! $::QUIET} {
327 puts [appendArgs "Started Fossil server, pid \"" $pid \" ", port \"" $port \".]
328 }
329
--- test/unversioned.test
+++ test/unversioned.test
@@ -319,10 +319,15 @@
319
320 fossil user new uvtester "Unversioned Test User" $password
321 fossil user capabilities uvtester oy
322
323 ###############################################################################
324
325 if {![loopback_available]} {
326 test_skip "Loopback networking is not available, so the tests that run\
327 \"fossil server\" cannot start a server."
328 }
329
330 foreach {pid port outTmpFile} [test_start_server $repository stopArg] {}
331 if {! $::QUIET} {
332 puts [appendArgs "Started Fossil server, pid \"" $pid \" ", port \"" $port \".]
333 }
334

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button