From patchwork Thu Oct 13 06:30:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Turner X-Patchwork-Id: 988 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp286016vsd; Thu, 13 Oct 2016 10:04:07 -0700 (PDT) X-Received: by 10.194.216.99 with SMTP id op3mr7540612wjc.75.1476378247843; Thu, 13 Oct 2016 10:04:07 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id yr9si13403773wjc.282.2016.10.13.10.04.07; Thu, 13 Oct 2016 10:04:07 -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=@googlemail.com; 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; dmarc=fail (p=QUARANTINE dis=QUARANTINE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F3C1689C29; Thu, 13 Oct 2016 20:04:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0591689B68 for ; Thu, 13 Oct 2016 09:30:58 +0300 (EEST) Received: by mail-pf0-f193.google.com with SMTP id s8so4355089pfj.2 for ; Wed, 12 Oct 2016 23:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=0Q4G02A67XMZAwtaaTE7lgZLATFM36snF8AL4a+bT+M=; b=pUYoJoSNdQXrzIoeHJNVvd69cK5xQ4/d6vm7Ez47d3IsZomcre2OmSJw2V6fv6RbIw eowWnHbi9ynapaVsAvzJZvxdDMOP8V6VVTCugBCgDQjtaUV1Ayw6ZSMVJcsmskGI5Vgk 9pyxnuoQeGZ+MqUAA2DnFIcqSO2IndfZ42yw45tvIVF7rS2tal7oxl5gD/Ks4KBfp6Ht j249+DYT41Jvc7v7yI6ytaHMQLdyaetz9QwwoHTTzVlxeGSS12jg7+4+Au9tHoT3FTyA DYolvv72K+6TZDJo8l8MbnDnezcALuP/IeU8Ieth1iFBALn/JTt0MnS6s47PwBxuvPV0 NwYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0Q4G02A67XMZAwtaaTE7lgZLATFM36snF8AL4a+bT+M=; b=d7VsZCfrO5rNTd9/BVARWczdzGnkdnTEKOvqCyB2kRGMP9Q4Ni1Q2Up1SWH69GhOhd b+UcRPEB/UkQWpsnQAicwuZZXU3Lt3tXRMuXdLSion3zj+ipb4yFY9OzhSI3ytDzUb6k DiaiFab+VCdIbum4erMAX/hAMIosQm/I8acHHxtUArrxyv2eQYbaXSoiuZ413FcsYlqg pxwnc5V48IpFxxbgQnMGVSJG7+mUVwqg9umKjyh5AhzLMShz8NIADvaFR22MFGGk+Ql7 4aN0K/8+jJX+MdrA+koCrdyDd592ox/u/pRFdyuhCBZcImbojyArWPa9Fwju7ISA98dy 4FHQ== X-Gm-Message-State: AA6/9RkUAmcXznxnNW9p3Red3b2HgNdCedTYn/4bS+0T6UgHNbeS3LOttErUfand4MzMDQ== X-Received: by 10.98.58.73 with SMTP id h70mr2615016pfa.138.1476340257498; Wed, 12 Oct 2016 23:30:57 -0700 (PDT) Received: from Zany.domain.actdsltmp ([47.136.133.132]) by smtp.gmail.com with ESMTPSA id x1sm16367387pay.41.2016.10.12.23.30.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Oct 2016 23:30:57 -0700 (PDT) From: Thomas Turner X-Google-Original-From: Thomas Turner To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Oct 2016 23:30:19 -0700 Message-Id: <1476340219-7282-1-git-send-email-thomastdt@gmail.com> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Thu, 13 Oct 2016 20:04:04 +0300 Subject: [FFmpeg-devel] [PATCH] Improved selftest coverage for libavutil/fifo.c X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Thomas Turner MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Tested functions: av_fifo_generic_peek(), av_fifo_grow() --- libavutil/tests/fifo.c | 32 +++++++++++++++++++++++++++++++- tests/ref/fate/fifo | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/libavutil/tests/fifo.c b/libavutil/tests/fifo.c index e4d7edf..4d598d3 100644 --- a/libavutil/tests/fifo.c +++ b/libavutil/tests/fifo.c @@ -24,7 +24,7 @@ int main(void) { /* create a FIFO buffer */ AVFifoBuffer *fifo = av_fifo_alloc(13 * sizeof(int)); - int i, j, n; + int i, j, n, *p; /* fill data */ for (i = 0; av_fifo_space(fifo) >= sizeof(int); i++) @@ -46,6 +46,19 @@ int main(void) } printf("\n"); + /* generic peek at FIFO */ + + n = av_fifo_size(fifo); + p = malloc(n); + (void) av_fifo_generic_peek(fifo, p, n, NULL); + + /* read data at p */ + n /= sizeof(int); + for(i = 0; i < n; ++i) + printf("%d: %d\n", i, p[i]); + + putchar('\n'); + /* read data */ for (i = 0; av_fifo_size(fifo) >= sizeof(int); i++) { av_fifo_generic_read(fifo, &j, sizeof(int), NULL); @@ -67,8 +80,25 @@ int main(void) av_fifo_generic_peek_at(fifo, &j, i * sizeof(int), sizeof(j), NULL); printf("%d: %d\n", i, j); } + putchar('\n'); + + /* test fifo_grow */ + (void) av_fifo_grow(fifo, 15 * sizeof(int)); + + /* fill data */ + n = av_fifo_size(fifo) / sizeof(int); + for (i = n; av_fifo_space(fifo) >= sizeof(int); ++i) + av_fifo_generic_write(fifo, &i, sizeof(int), NULL); + + /* peek_at at FIFO */ + n = av_fifo_size(fifo) / sizeof(int); + for (i = 0; i < n; i++) { + av_fifo_generic_peek_at(fifo, &j, i * sizeof(int), sizeof(j), NULL); + printf("%d: %d\n", i, j); + } av_fifo_free(fifo); + free(p); return 0; } diff --git a/tests/ref/fate/fifo b/tests/ref/fate/fifo index 162d754..2b18ed5 100644 --- a/tests/ref/fate/fifo +++ b/tests/ref/fate/fifo @@ -38,6 +38,20 @@ 11: 11 12: 12 +0: 0 +1: 1 +2: 2 +3: 3 +4: 4 +5: 5 +6: 6 +7: 7 +8: 8 +9: 9 +10: 10 +11: 11 +12: 12 + 0 1 2 3 4 5 6 7 8 9 10 11 12 0: 0 1: 1 @@ -52,3 +66,32 @@ 10: 10 11: 11 12: 12 + +0: 0 +1: 1 +2: 2 +3: 3 +4: 4 +5: 5 +6: 6 +7: 7 +8: 8 +9: 9 +10: 10 +11: 11 +12: 12 +13: 13 +14: 14 +15: 15 +16: 16 +17: 17 +18: 18 +19: 19 +20: 20 +21: 21 +22: 22 +23: 23 +24: 24 +25: 25 +26: 26 +27: 27