From patchwork Tue Aug 30 12:09:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Roberts X-Patchwork-Id: 37563 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp2515103pzh; Tue, 30 Aug 2022 05:11:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5wOGVBxsFsAwUWxBlKDaid+6+9Zor1t1vwRvp9aq4i3rXfCxV5rEMWaOjicagTJ26jVz0Q X-Received: by 2002:a05:6402:3506:b0:43e:954b:bc8a with SMTP id b6-20020a056402350600b0043e954bbc8amr20567945edd.266.1661861461561; Tue, 30 Aug 2022 05:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661861461; cv=none; d=google.com; s=arc-20160816; b=pW8SA1DqhtT21PxSwynJSVnqVjDTMk4N5Ou0HEBHsBMO4e0YccQGbGJ6erF/AKxTqK T2Lc67SZHhqqrQnmVQiTrFF8huMxPcYEQQ1zW+mfCeNee6gJ9VlW/qW9PNCTSMMfOG0f HIiIl3yraI/goHK5x7ieRX5gY8wqpPgWqiNRXfG3vGXYvRzpaEY1UZ0JNEEOftWkyOAx Ia9EKJ+0UK+7wxlfa/MexMG8iSyKGv9fIHk6oJ2+RQemEiFXw3tLaX/JysLWhFXde2Sa bhWEu7KomPh8QFeHoFucsAvC1ZTwgqgOTca24XmsXbo4mC4rush0gG7mCX45wikRo9Tw avnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=pRrfqufhb4v7is3smecKZ+xQyhXndoUDN48Qf+rLFyI=; b=l66Koxw9OdSO+zVD4dIQpD6MxptW0Ltx0yZAXBaxXASiuldImDiKCw5hhEAreb4IDf WZCmwYdfgvO72CTsxNyI+ECmtAkA+rL3PqmTh6RRCxQRFv1hRrQWITQvVYKZHf4SzP89 pqr4yfR9HQXqzsWNGCIZrEbCpf5OPZ7EZnMbUkHHImh4mPpYVnDwlr0JtLpXvf7b8Arz yfkbJO7hvoWK1yxMt1OmSYVTM7GhhheD3ZxWvP2PwavQMuhItJsXWfthVVcQE+ZAo8N/ +YWEGx5TZOey1p603OzzU/irDw2OxORn3Adean4FF/2NpD9zz1jWvrpfcBAOrt3cj2cK ypxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@yahoo.co.uk header.s=s2048 header.b=BHrYR7Dm; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k3-20020a1709063e0300b00733002330edsi1848728eji.342.2022.08.30.05.10.50; Tue, 30 Aug 2022 05:11:01 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@yahoo.co.uk header.s=s2048 header.b=BHrYR7Dm; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2622868BAEC; Tue, 30 Aug 2022 15:10:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sonic310-57.consmr.mail.ir2.yahoo.com (sonic310-57.consmr.mail.ir2.yahoo.com [77.238.177.30]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2FD7E68B149 for ; Tue, 30 Aug 2022 15:10:37 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1661861436; bh=AwhGwQonBXV4fi/s7z6/NnX52BjIwq3GLGFgAHkAWQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=BHrYR7DmQIpNGL9MUEFB1zfXIZ9FlNl4bOVhuhTvexB/sKnPhEgXSOZ/5w2bFJnaF09PaappJWII+6/Dqb8kS57880VqAhzIbRuvfGjADoeqDQRj1sr0bE04g67jM/pMVT73RVT42wVcEqr6jIWoYPsx0grTIPP0f9upw/JXOPqKuBSckolRUfDECug2LvfMjWHb7ebvBO+qSFx3PulmUcBMSt0HX3sls4f7QEMiA0u64tknA1nVVFdexoOYjDHeKheV707OoE6OCSEUJUWAF1MeME8W0nRsqGM5rbYzAQgCrP2b+dEB5KgWeOpLWGLJPFTcZ+MIutz44G1DvpWZ2A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1661861436; bh=yC/S5Z4xTZ5LixK3eC2xyDGgKLuBZ4oKgil1vH3rAPs=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=WTuKJv607uxPWr9dyfP/m0a3+J4VeoBXQY8eir+5Q6uSqPHNU3Bm9HVuh3FvwP/i5DvfUvaE4dLCbTXfQe8VRKhq4hPmyLXd518QbBPiuakB2ENaLSEh35+1JlqbovOtwbpD28RE1adbdtcExInvzs5+vHpGFISWTiMVruzqaz8jLUUbPhENKODBJT0enFrOmScIQZWfcbBg4YyVgEBvmAMVLSaoY7BEjRoVJlib/UYTOKCQBgyF2xkDPWlrX27Yh0/DOtNoWUoN05i4CoA9PitddRGmYnuaSmewoxYn7tGkxhGVJgUrV7PuapguW6MvYCZQl9amMZkwR/RloRWVhQ== X-YMail-OSG: ud72vGkVM1mUXOe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JmoN9olOvSnirazn7MOXEp lXlT3joA0pcHv3C3fE1695dkF7cNM8QrjtkYYXmmkqnlV2XrPZXSgZNcyVq..3HVFuoAwu1OOeK5 Nosw05Zopuemt_xbCz0x1PObsm8GQAQMhz4jYm8AImw-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ir2.yahoo.com with HTTP; Tue, 30 Aug 2022 12:10:36 +0000 Received: by hermes--canary-production-ir2-f74ffc99c-5fxhh (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID d799474098d1407f2db818b0fae1fd02; Tue, 30 Aug 2022 12:10:34 +0000 (UTC) From: Neil Roberts To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Aug 2022 14:09:54 +0200 Message-Id: <20220830120954.452255-2-bpeeluk@yahoo.co.uk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220830120954.452255-1-bpeeluk@yahoo.co.uk> References: <20220829215422.GK2088045@pb2> <20220830120954.452255-1-bpeeluk@yahoo.co.uk> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] avformat/tests: Add a test for avio_check with the pipe protocol X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Michael Niedermayer Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: U6ooOeyIuviP Creates a UNIX pipe and then verifies that avio_check returns the right access flags for the two ends of the pipe. v2: Add support for the Windows version of _pipe Signed-off-by: Neil Roberts --- libavformat/Makefile | 1 + libavformat/tests/.gitignore | 1 + libavformat/tests/pipe.c | 108 +++++++++++++++++++++++++++++++++++ tests/fate/libavformat.mak | 5 ++ 4 files changed, 115 insertions(+) create mode 100644 libavformat/tests/pipe.c diff --git a/libavformat/Makefile b/libavformat/Makefile index f67a99f839..9c681c58c5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -732,6 +732,7 @@ TESTPROGS-$(CONFIG_MOV_MUXER) += movenc TESTPROGS-$(CONFIG_NETWORK) += noproxy TESTPROGS-$(CONFIG_SRTP) += srtp TESTPROGS-$(CONFIG_IMF_DEMUXER) += imf +TESTPROGS-$(CONFIG_PIPE_PROTOCOL) += pipe TOOLS = aviocat \ ismindex \ diff --git a/libavformat/tests/.gitignore b/libavformat/tests/.gitignore index cdd0cce061..567d6f9e40 100644 --- a/libavformat/tests/.gitignore +++ b/libavformat/tests/.gitignore @@ -7,3 +7,4 @@ /srtp /url /seek_utils +/pipe diff --git a/libavformat/tests/pipe.c b/libavformat/tests/pipe.c new file mode 100644 index 0000000000..18a8551fd5 --- /dev/null +++ b/libavformat/tests/pipe.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2022 Neil Roberts + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include "libavformat/avio.h" +#include "libavutil/error.h" + +static int check_pipe(const char *url, int mask, int expected) +{ + int flags = avio_check(url, mask); + + if (flags < 0) { + fprintf(stderr, + "avio_check for %s with mask 0x%x failed: %s\n", + url, + mask, + av_err2str(flags)); + return 0; + } + + if (flags != expected) { + fprintf(stderr, + "Wrong result returned from avio_check for %s with mask 0x%x. " + "Expected 0x%x but received 0x%x\n", + url, + mask, + expected, + flags); + return 0; + } + + return 1; +} + +int main(int argc, char **argv) +{ + int ret = 0; + int pipe_fds[2]; + char read_url[20], write_url[20]; + int check_invalid_ret; + int pipe_ret; + +#ifdef _WIN32 + pipe_ret = _pipe(pipe_fds, 1024 /* psize */, 0 /* textmode */); +#else + pipe_ret = pipe(pipe_fds); +#endif + + if (pipe_ret == -1) { + fprintf(stderr, "error creating pipe: %s\n", strerror(errno)); + return 1; + } + + snprintf(read_url, sizeof(read_url), "pipe:%d", pipe_fds[0]); + snprintf(write_url, sizeof(write_url), "pipe:%d", pipe_fds[1]); + + if (!check_pipe(read_url, + AVIO_FLAG_READ | AVIO_FLAG_WRITE, + AVIO_FLAG_READ)) + ret = 1; + + if (!check_pipe(write_url, + AVIO_FLAG_READ | AVIO_FLAG_WRITE, + AVIO_FLAG_WRITE)) + ret = 1; + + /* Ensure that we don't get flags that we didn't ask for */ + if (!check_pipe(read_url, AVIO_FLAG_WRITE, 0)) + ret = 1; + + close(pipe_fds[0]); + close(pipe_fds[1]); + + /* An invalid fd should return EBADF */ + check_invalid_ret = avio_check(read_url, AVIO_FLAG_READ); + + if (check_invalid_ret != AVERROR(EBADF)) { + fprintf(stderr, + "avio_check on invalid FD expected to return %i " + "but %i was received\n", + AVERROR(EBADF), + check_invalid_ret); + ret = 1; + } + + return ret; +} diff --git a/tests/fate/libavformat.mak b/tests/fate/libavformat.mak index d2acb4c9e0..7a22f54c04 100644 --- a/tests/fate/libavformat.mak +++ b/tests/fate/libavformat.mak @@ -26,6 +26,11 @@ FATE_LIBAVFORMAT-$(CONFIG_IMF_DEMUXER) += fate-imf fate-imf: libavformat/tests/imf$(EXESUF) fate-imf: CMD = run libavformat/tests/imf$(EXESUF) +FATE_LIBAVFORMAT-$(CONFIG_PIPE_PROTOCOL) += fate-pipe +fate-pipe: libavformat/tests/pipe$(EXESUF) +fate-pipe: CMD = run libavformat/tests/pipe$(EXESUF) +fate-pipe: CMP = null + FATE_LIBAVFORMAT += fate-seek_utils fate-seek_utils: libavformat/tests/seek_utils$(EXESUF) fate-seek_utils: CMD = run libavformat/tests/seek_utils$(EXESUF)