Mercurial > hg > nginx-tests
comparison mp4_ssi.t @ 1056:1e41a0de0772
Tests: various last_buf tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 12 Oct 2016 17:49:03 +0300 |
parents | |
children | 673c3e12214e |
comparison
equal
deleted
inserted
replaced
1055:8979f0d86c29 | 1056:1e41a0de0772 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Test for mp4 module in subrequests. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 use Config; | |
16 | |
17 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
18 | |
19 use lib 'lib'; | |
20 use Test::Nginx; | |
21 | |
22 ############################################################################### | |
23 | |
24 select STDERR; $| = 1; | |
25 select STDOUT; $| = 1; | |
26 | |
27 my $t = Test::Nginx->new()->has(qw/http mp4 ssi/)->has_daemon('ffprobe') | |
28 ->has_daemon('ffmpeg')->write_file_expand('nginx.conf', <<'EOF'); | |
29 | |
30 %%TEST_GLOBALS%% | |
31 | |
32 daemon off; | |
33 | |
34 events { | |
35 } | |
36 | |
37 http { | |
38 %%TEST_GLOBALS_HTTP%% | |
39 | |
40 server { | |
41 listen 127.0.0.1:8080; | |
42 server_name localhost; | |
43 | |
44 location / { | |
45 ssi on; | |
46 } | |
47 location /ssi { | |
48 mp4; | |
49 } | |
50 } | |
51 } | |
52 | |
53 EOF | |
54 | |
55 plan(skip_all => 'no lavfi') | |
56 unless grep /lavfi/, `ffmpeg -loglevel quiet -formats`; | |
57 system('ffmpeg -loglevel quiet -y ' | |
58 . '-f lavfi -i testsrc=duration=10:size=320x200:rate=15 ' | |
59 . '-f lavfi -i testsrc=duration=20:size=320x200:rate=15 ' | |
60 . '-map 0:0 -map 1:0 -pix_fmt yuv420p -g 15 -c:v libx264 ' | |
61 . "${\($t->testdir())}/ssi.mp4") == 0 | |
62 or die "Can't create mp4 file: $!"; | |
63 | |
64 $t->write_file('index.html', 'X<!--#include virtual="/ssi.mp4?end=1" -->X'); | |
65 | |
66 $t->run()->plan(1); | |
67 | |
68 ############################################################################### | |
69 | |
70 TODO: { | |
71 local $TODO = 'not yet' unless $t->has_version('1.11.5'); | |
72 | |
73 (my $r = get('/')) =~ s/([^\x20-\x7e])/sprintf('\\x%02x', ord($1))/gmxe; | |
74 unlike($r, qr/\\x0d(\\x0a)?0\\x0d(\\x0a)?\\x0d(\\x0a)?\w/, 'only final chunk'); | |
75 | |
76 } | |
77 | |
78 ############################################################################### | |
79 | |
80 sub get { | |
81 my ($url, $extra) = @_; | |
82 return http(<<EOF); | |
83 GET $url HTTP/1.1 | |
84 Host: localhost | |
85 Connection: close | |
86 | |
87 EOF | |
88 } | |
89 | |
90 ############################################################################### |