Mercurial > hg > nginx-tests
annotate random_index.t @ 165:fca70f483608
Tests: fix previous commit (print original message length).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 01 Aug 2011 21:50:01 +0400 |
parents | b714d6df958c |
children | c0ae29632905 |
rev | line source |
---|---|
109
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for random index module. |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
121
8ac1faaddd2c
Tests: better handle various configure arguments.
Maxim Dounin <mdounin@mdounin.ru>
parents:
110
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http random_index/)->plan(1) |
109
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 ->write_file_expand('nginx.conf', <<'EOF'); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 %%TEST_GLOBALS%% |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 master_process off; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 daemon off; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 events { |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 } |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 http { |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 server { |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 listen 127.0.0.1:8080; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 server_name localhost; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 location / { |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 random_index on; |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 } |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 } |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 } |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 EOF |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 my $d = $t->testdir(); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 mkdir("$d/x"); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 mkdir("$d/x/test-dir"); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 symlink("$d/x/test-dir", "$d/x/test-dir-link"); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 $t->write_file('test-file', 'RIGHT'); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 symlink("$d/test-file", "$d/x/test-file-link"); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 $t->run(); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 ############################################################################### |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 like(http_get('/x/'), qr/RIGHT/s, 'file'); |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
d125e51ea596
Tests: add random index module test for symlink issue.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 ############################################################################### |