##// END OF EJS Templates
tests: make test-serve works on system that allow user to bind low port...
marmoute -
r48573:a8deb9dc stable
parent child Browse files
Show More
@@ -1,112 +1,119 b''
1 #require serve
1 #require serve
2
2
3 $ hgserve()
3 $ hgserve()
4 > {
4 > {
5 > hg serve -a localhost -d --pid-file=hg.pid -E errors.log -v $@ \
5 > hg serve -a localhost -d --pid-file=hg.pid -E errors.log -v $@ \
6 > | sed -e "s/:$HGPORT1\\([^0-9]\\)/:HGPORT1\1/g" \
6 > | sed -e "s/:$HGPORT1\\([^0-9]\\)/:HGPORT1\1/g" \
7 > -e "s/:$HGPORT2\\([^0-9]\\)/:HGPORT2\1/g" \
7 > -e "s/:$HGPORT2\\([^0-9]\\)/:HGPORT2\1/g" \
8 > -e 's/http:\/\/[^/]*\//http:\/\/localhost\//'
8 > -e 's/http:\/\/[^/]*\//http:\/\/localhost\//'
9 > if [ -f hg.pid ]; then
9 > if [ -f hg.pid ]; then
10 > killdaemons.py hg.pid
10 > killdaemons.py hg.pid
11 > fi
11 > fi
12 > echo % errors
12 > echo % errors
13 > cat errors.log
13 > cat errors.log
14 > }
14 > }
15
15
16 $ hg init test
16 $ hg init test
17 $ cd test
17 $ cd test
18 $ echo '[web]' > .hg/hgrc
18 $ echo '[web]' > .hg/hgrc
19 $ echo 'accesslog = access.log' >> .hg/hgrc
19 $ echo 'accesslog = access.log' >> .hg/hgrc
20 $ echo "port = $HGPORT1" >> .hg/hgrc
20 $ echo "port = $HGPORT1" >> .hg/hgrc
21
21
22 Without -v
22 Without -v
23
23
24 $ hg serve -a localhost -p $HGPORT -d --pid-file=hg.pid -E errors.log
24 $ hg serve -a localhost -p $HGPORT -d --pid-file=hg.pid -E errors.log
25 $ cat hg.pid >> "$DAEMON_PIDS"
25 $ cat hg.pid >> "$DAEMON_PIDS"
26 $ if [ -f access.log ]; then
26 $ if [ -f access.log ]; then
27 > echo 'access log created - .hg/hgrc respected'
27 > echo 'access log created - .hg/hgrc respected'
28 > fi
28 > fi
29 access log created - .hg/hgrc respected
29 access log created - .hg/hgrc respected
30
30
31 errors
31 errors
32
32
33 $ cat errors.log
33 $ cat errors.log
34
34
35 With -v
35 With -v
36
36
37 $ hgserve
37 $ hgserve
38 listening at http://localhost/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
38 listening at http://localhost/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
39 % errors
39 % errors
40
40
41 With -v and -p HGPORT2
41 With -v and -p HGPORT2
42
42
43 $ hgserve -p "$HGPORT2"
43 $ hgserve -p "$HGPORT2"
44 listening at http://localhost/ (bound to *$LOCALIP*:HGPORT2) (glob) (?)
44 listening at http://localhost/ (bound to *$LOCALIP*:HGPORT2) (glob) (?)
45 % errors
45 % errors
46
46
47 With -v and -p daytime (should fail because low port)
47 With -v and -p daytime
48
48
49 #if no-root no-windows
49 # On some system this will fails because port < 1024 are not bindable by normal
50 # users.
51 #
52 # On some others the kernel is configured to allow any user to bind them and
53 # this will work fine
54
55 #if no-windows
50 $ KILLQUIETLY=Y
56 $ KILLQUIETLY=Y
51 $ hgserve -p daytime
57 $ hgserve -p daytime
52 abort: cannot start server at 'localhost:13': Permission denied
58 abort: cannot start server at 'localhost:13': Permission denied (?)
53 abort: child process failed to start
59 abort: child process failed to start (?)
60 listening at http://localhost/ (bound to $LOCALIP:13) (?)
54 % errors
61 % errors
55 $ KILLQUIETLY=N
62 $ KILLQUIETLY=N
56 #endif
63 #endif
57
64
58 With --prefix foo
65 With --prefix foo
59
66
60 $ hgserve --prefix foo
67 $ hgserve --prefix foo
61 listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
68 listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
62 % errors
69 % errors
63
70
64 With --prefix /foo
71 With --prefix /foo
65
72
66 $ hgserve --prefix /foo
73 $ hgserve --prefix /foo
67 listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
74 listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
68 % errors
75 % errors
69
76
70 With --prefix foo/
77 With --prefix foo/
71
78
72 $ hgserve --prefix foo/
79 $ hgserve --prefix foo/
73 listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
80 listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
74 % errors
81 % errors
75
82
76 With --prefix /foo/
83 With --prefix /foo/
77
84
78 $ hgserve --prefix /foo/
85 $ hgserve --prefix /foo/
79 listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
86 listening at http://localhost/foo/ (bound to *$LOCALIP*:HGPORT1) (glob) (?)
80 % errors
87 % errors
81
88
82 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
89 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
83
90
84 With out of bounds accesses
91 With out of bounds accesses
85
92
86 $ rm access.log
93 $ rm access.log
87 $ hg serve -a localhost -p $HGPORT -d --prefix some/dir \
94 $ hg serve -a localhost -p $HGPORT -d --prefix some/dir \
88 > --pid-file=hg.pid -E errors.log
95 > --pid-file=hg.pid -E errors.log
89 $ cat hg.pid >> "$DAEMON_PIDS"
96 $ cat hg.pid >> "$DAEMON_PIDS"
90
97
91 $ hg id http://localhost:$HGPORT/some/dir7
98 $ hg id http://localhost:$HGPORT/some/dir7
92 abort: HTTP Error 404: Not Found
99 abort: HTTP Error 404: Not Found
93 [100]
100 [100]
94 $ hg id http://localhost:$HGPORT/some
101 $ hg id http://localhost:$HGPORT/some
95 abort: HTTP Error 404: Not Found
102 abort: HTTP Error 404: Not Found
96 [100]
103 [100]
97
104
98 $ cat access.log errors.log
105 $ cat access.log errors.log
99 $LOCALIP - - [$LOGDATE$] "GET /some/dir7?cmd=capabilities HTTP/1.1" 404 - (glob)
106 $LOCALIP - - [$LOGDATE$] "GET /some/dir7?cmd=capabilities HTTP/1.1" 404 - (glob)
100 $LOCALIP - - [$LOGDATE$] "GET /some?cmd=capabilities HTTP/1.1" 404 - (glob)
107 $LOCALIP - - [$LOGDATE$] "GET /some?cmd=capabilities HTTP/1.1" 404 - (glob)
101
108
102 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
109 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
103
110
104 issue6362: Previously, this crashed on Python 3
111 issue6362: Previously, this crashed on Python 3
105
112
106 $ hg serve -a 0.0.0.0 -d --pid-file=hg.pid
113 $ hg serve -a 0.0.0.0 -d --pid-file=hg.pid
107 listening at http://*:$HGPORT1/ (bound to *:$HGPORT1) (glob) (?)
114 listening at http://*:$HGPORT1/ (bound to *:$HGPORT1) (glob) (?)
108
115
109 $ cat hg.pid > "$DAEMON_PIDS"
116 $ cat hg.pid > "$DAEMON_PIDS"
110 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
117 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
111
118
112 $ cd ..
119 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now