Import gst-integration-testsuites
[platform/upstream/gstreamer.git] / subprojects / gst-integration-testsuites / testsuites / validate.py
1 # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
2 #
3 # Copyright (c) 2014,Thibault Saunier <thibault.saunier@collabora.com>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this program; if not, write to the
17 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 # Boston, MA 02110-1301, USA.
19
20 """
21 The GstValidate default testsuite
22 """
23
24 import os
25 import glob
26 import re
27
28 from testsuiteutils import update_assets
29 from launcher.baseclasses import MediaFormatCombination
30 from launcher.apps.gstvalidate import GstValidateSimpleTestsGenerator
31 from validate_known_issues import KNOWN_ISSUES
32
33
34 TEST_MANAGER = "validate"
35
36 BLACKLIST = [('validate.file.transcode.to_vorbis_and_vp8_in_webm.GH1_00094_1920x1280_MTS',
37               'Got error: Internal data stream error. -- Debug message: mpegtsbase.c(1371):'
38               'mpegts_base_loop (): ...: stream stopped, reason not-negotiated'),
39              ('validate.testbin.transcode.*',
40               "Encoding testsrc is not so interesting and the source is now unlimited"),
41              ('validate.file.*.simple.fast_forward.synchronized',
42               'https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/541'),
43              ('validate.hls.playback.change_state_intensive.*',
44               'https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/482'),
45             ('validate.rtsp.*playback.switch.*',
46              'https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/357'),
47             ('validate.rtsp.*playback.*seek.*mxf$|validate.rtsp.*playback.*change_state_intensive.*mxf$',
48              'Actions on MXF streams with rtsp-server fail in racy ways.'
49              ' (Deactivating as it is not very important.)'),
50             ('validate.rtsp.*pal-dv25_mxf$',
51              'File has decoding issues with rtsp-server.'
52              ' (Deactivating as it is not very important.)'),
53              ("(?!.*.media_check.qtdemux-test-frag-basic_zero_dur_no_mehd_mp4).*.qtdemux-test-frag-basic_zero_dur_no_mehd_mp4",
54               '`qtdemux-test-frag-basic_zero_dur_no_mehd_mp4` is there only for media_check tests.'),
55              ('validate.rtsp.*playback.*mp3_h265_0_mp4$',
56               'The version of libav shipped by Fedora 29 crashes in various ways with these tests.'),
57              ('validate.rtsp.*playback.seek.*GH1_00094_1920x1280_MTS',
58               'Do not preroll after pause.'),
59              ('validate.file.playback.reverse_playback.sample_mpeg_program_stream_scr_mpg',
60               'Do not decode any frame in reverse playback with SCR.'),
61              ('validate.rtsp.*playback.seek.*sample_mpeg_program_stream_scr_mpg',
62               'Racy with CI. No frames decoded before the end of the stream.'),
63              ]
64
65 def add_accurate_seek_tests(test_manager, media_dir, extra_data):
66     accurate_seeks_media_infos = []
67     for f in [
68             'mp4/timecoded_jpeg_23976fps.mp4.media_info.skipped',
69             'mp4/timecoded_jpeg_2997fps.mp4.media_info.skipped',
70             'mp4/timecoded_jpeg_30fps.mp4.media_info.skipped',
71
72             'mp4/timecoded_vp8_23976fps.mp4.media_info.skipped',
73             'mp4/timecoded_vp8_2997fps.mp4.media_info.skipped',
74             'mp4/timecoded_vp8_30fps.mp4.media_info.skipped',
75
76             'mp4/timecoded_h264_23976fps.mp4.media_info.skipped',
77             'mp4/timecoded_h264_2997fps.mp4.media_info.skipped',
78             'mp4/timecoded_h264_30fps.mp4.media_info.skipped',
79         ]:
80         dirname = os.path.join(media_dir, "defaults", os.path.dirname(f))
81         filename = os.path.basename(f)
82         media_info = os.path.join(dirname, filename)
83         reference_frames_dir = os.path.join(dirname, re.sub(r"\.media_info.*", "_reference_frames", filename).replace('.', '_'))
84         accurate_seeks_media_infos.append((media_info, reference_frames_dir))
85
86     test_manager.add_generators(
87         test_manager.GstValidateCheckAccurateSeekingTestGenerator(
88             'accurate_seeks',
89             test_manager,
90             [(os.path.join(media_dir, media_info), os.path.join(media_dir, reference_frames_dir)) for media_info, reference_frames_dir in accurate_seeks_media_infos],
91             extra_data=extra_data)
92     )
93
94
95 def setup_tests(test_manager, options):
96     testsuite_dir = os.path.realpath(os.path.join(os.path.dirname(__file__)))
97     media_dir = os.path.realpath(os.path.join(testsuite_dir, os.path.pardir, "medias"))
98
99     assets_dir = os.path.realpath(os.path.join(testsuite_dir, os.path.pardir, "medias", "defaults"))
100     if options.sync:
101         if not update_assets(options, assets_dir):
102             return False
103
104     options.add_paths(assets_dir)
105     options.set_http_server_dir(media_dir)
106     test_manager.set_default_blacklist(BLACKLIST)
107
108     extra_data = {
109         "config_path": os.path.dirname(testsuite_dir),
110         "medias": media_dir,
111         "validate-flow-expectations-dir": os.path.join(testsuite_dir, "validate", "flow-expectations"),
112         "validate-flow-actual-results-dir": test_manager.options.logsdir,
113         "ssim-results-dir": os.path.join(test_manager.options.logsdir, "ssim-results"),
114     }
115     add_accurate_seek_tests(test_manager, media_dir, extra_data)
116
117     test_manager.add_generators(
118         GstValidateSimpleTestsGenerator("simple", test_manager,
119             os.path.join(testsuite_dir, "validate"))
120     )
121
122     test_manager.add_expected_issues(KNOWN_ISSUES)
123     test_manager.register_defaults()
124
125     test_manager.add_encoding_formats([MediaFormatCombination("quicktime", "rawaudio", "prores")])
126
127     valid_mixing_scenarios = ["play_15s",
128                               "fast_forward",
129                               "seek_forward",
130                               "seek_backward",
131                               "seek_with_stop",
132                               "scrub_forward_seeking"]
133
134     for compositor in ["compositor", "glvideomixer"]:
135         test_manager.add_generators(
136             test_manager.GstValidateMixerTestsGenerator(compositor + ".simple", test_manager,
137                                                         compositor,
138                                                         "video",
139                                                         converter="deinterlace ! videoconvert",
140                                                         mixed_srcs={
141                                                              "synchronized": {"mixer_props": "sink_1::alpha=0.5 sink_1::xpos=50 sink_1::ypos=50",  # noqa
142                                                                               "sources":
143                                                                               ("videotestsrc pattern=snow timestamp-offset=3000000000 ! 'video/x-raw,format=AYUV,width=640,height=480,framerate=(fraction)30/1' !  timeoverlay",  # noqa
144                                                                                "videotestsrc pattern=smpte ! 'video/x-raw,format=AYUV,width=800,height=600,framerate=(fraction)10/1' ! timeoverlay")},  # noqa
145                                                              "bgra": ("videotestsrc ! video/x-raw, framerate=\(fraction\)10/1, width=100, height=100",  # noqa
146                                                                       "videotestsrc ! video/x-raw, framerate=\(fraction\)5/1, width=320, height=240")
147                                                         },
148                                                         valid_scenarios=valid_mixing_scenarios))
149
150     test_manager.add_generators(
151         test_manager.GstValidateMixerTestsGenerator("audiomixer.simple", test_manager,
152                                                     "audiomixer",
153                                                     "audio",
154                                                     converter="audioconvert ! audioresample",
155                                                     mixed_srcs={"basic": {"mixer_props": "",
156                                                                 "sources": ("audiotestsrc wave=triangle",
157                                                                             "audiotestsrc wave=ticks")}},
158                                                     valid_scenarios=valid_mixing_scenarios))
159
160     return True