| | @@ -856,10 +856,25 @@ |
| 856 | 856 | } |
| 857 | 857 | append out \n$line |
| 858 | 858 | } |
| 859 | 859 | return [string range $out 1 end] |
| 860 | 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 | +} |
| 861 | 876 | |
| 862 | 877 | # This procedure executes the "fossil server" command. The return value |
| 863 | 878 | # is a list comprised of the new process identifier and the port on which |
| 864 | 879 | # the server started. The varName argument refers to a variable |
| 865 | 880 | # where the "stop argument" is to be stored. This value must eventually be |
| 866 | 881 | |