From patchwork Sun Apr 24 10:14:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 35425 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp1335184pzh; Sun, 24 Apr 2022 03:14:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbsEFndNCr+8/GUvu2H78sagYESebytffAh90hnNDnmELc/1VnKX6RrTx/dl+tTXlwY1pI X-Received: by 2002:a17:907:3f02:b0:6f3:5c42:321a with SMTP id hq2-20020a1709073f0200b006f35c42321amr9749997ejc.521.1650795291727; Sun, 24 Apr 2022 03:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650795291; cv=none; d=google.com; s=arc-20160816; b=yunH8mEUApUxgYXvJ9M5RW+KWbjjlXcJL2XkvxMCiW1EJ2tyM+AIlGllg7vyWquldK wIBTXUwKfQdAnQR+y2wn+H+UPftFdkE8OGdGpxcl0F1I7vHe8r2wVHawe/QecMDAE35c zcPuNyzSEKVVW5a+gXg2wKa25oSqu0Pt8zNw85scLVLvyCx2MDKke2p/8IgK7zExX+Ju cb4ltQQmgnrbZ1UA31Qv3+UrYtyDOVXuVS1oUW8Yz3xrCMF3il2nP3e40u0LfP+NHn3T oYxBz1gFhk+CbdGHspiR4diHYr1PgwTWO8W3EHSooD2LvdzrdgGoiXXkeybU9WZGqs/r 4cBw== 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:delivered-to; bh=p1rQ1lzDLws+JM3Ek434mn1HJmmmaBLAGUw2WsHSRI8=; b=JjU6xslbMs6agsUBwp0Tk519aX0zmFfHvdd+WSVoO7jsdAICzSAGkPUWAaAew1lJxU DI62O3Gt9DVbZZP3yiH6E6UUlyM230EjxG+CmVPDq89KEhJKeVnS0yM4ufW54WeHt4Xm HefW3Iy0JzEvnmh6yFSsN8Ms0WYvlRfBeN3KhDLbdV4tSasP1MeRdnj3ou5iZ6Zt0RK7 BHGtX2KAEYKpV8T2bUVHvWFLE7SH9Ta2atf6k0grdZCf58t8U2LgeS1BOAhi70ver4o4 jT3nlYgzJyyZWiD7wvBhSuR2X8By4NYBZ6J9Q8EP8oXkX8PbicSMY0asX7jWsNQLx22Y 3SCg== ARC-Authentication-Results: i=1; mx.google.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=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j40-20020a05640223a800b00425e3c772b9si570716eda.333.2022.04.24.03.14.51; Sun, 24 Apr 2022 03:14:51 -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; 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=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9CB3F68B1E1; Sun, 24 Apr 2022 13:14:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1266568B08A for ; Sun, 24 Apr 2022 13:14:31 +0300 (EEST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Sun, 24 Apr 2022 20:14:04 +1000 Message-Id: <20220424101409.95486-3-zane@zanevaniperen.com> In-Reply-To: <20220424101409.95486-1-zane@zanevaniperen.com> References: <20220424101409.95486-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: cadance.vs49688.net Subject: [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/uuid: add uuid tests 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: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: LT6L17ymF5dg From: Pierre-Anthony Lemieux --- libavutil/Makefile | 1 + libavutil/tests/.gitignore | 1 + libavutil/tests/uuid.c | 139 +++++++++++++++++++++++++++++++++++++ tests/fate/libavutil.mak | 5 ++ 4 files changed, 146 insertions(+) create mode 100644 libavutil/tests/uuid.c diff --git a/libavutil/Makefile b/libavutil/Makefile index 29742668b8..fef726b39a 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -260,6 +260,7 @@ TESTPROGS = adler32 \ tree \ twofish \ utf8 \ + uuid \ xtea \ tea \ diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore index 9d90827954..919010e4fc 100644 --- a/libavutil/tests/.gitignore +++ b/libavutil/tests/.gitignore @@ -48,4 +48,5 @@ /tree /twofish /utf8 +/uuid /xtea diff --git a/libavutil/tests/uuid.c b/libavutil/tests/uuid.c new file mode 100644 index 0000000000..0a7a0eb07d --- /dev/null +++ b/libavutil/tests/uuid.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2022 Pierre-Anthony Lemieux + * Zane van Iperen + * + * 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 "libavutil/uuid.h" +#include "libavutil/log.h" + +static const char *UUID_1 = "6021b21e-894e-43ff-8317-1ca891c1c49b"; +static const char *UUID_1_UC = "6021B21E-894E-43FF-8317-1CA891C1C49B"; +static const char *UUID_1_MIXED = "6021b21e-894E-43fF-8317-1CA891C1c49b"; +static const char *UUID_1_URN = "urn:uuid:6021b21e-894e-43ff-8317-1ca891c1c49b"; +static const AVUUID UUID_1_BYTES = {0x60, 0x21, 0xb2, 0x1e, 0x89, 0x4e, 0x43, 0xff, + 0x83, 0x17, 0x1c, 0xa8, 0x91, 0xc1, 0xc4, 0x9b}; + +static const AVUUID UUID_NIL = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +static const char *UUID_BAD_1 = "16a2c9f8-afbc-4767-8621-8cb2b27599"; +static const char *UUID_BAD_2 = "75df62c2999b4bd38c9d8058fcde9123"; +static const char *UUID_BAD_3 = "a1b9a05e-f1d1-464g-a951-1ba0a374f02"; +static const char *UUID_BAD_4 = "279c66d432-7b39-41d5-966f-5e8138265c20"; + +int main(int argc, char **argv) +{ + AVUUID uuid; + AVUUID uuid2 = {0x32, 0xc7, 0x00, 0xc4, 0xd5, 0xd7, 0x42, 0x0, + 0x93, 0xc0, 0x3b, 0x6d, 0xea, 0x1b, 0x20, 0x5b}; + + /* test parsing */ + + if (av_uuid_parse(UUID_1, uuid)) + return 1; + + if (!av_uuid_equal(uuid, UUID_1_BYTES)) + return 1; + + /* test nil */ + + av_uuid_nil_set(uuid); + + if (!av_uuid_equal(uuid, UUID_NIL)) + return 1; + + /* test equality */ + + if (av_uuid_equal(UUID_1_BYTES, uuid2)) + return 1; + + /* test copy */ + + av_uuid_copy(uuid2, UUID_1_BYTES); + + if (!av_uuid_equal(uuid2, UUID_1_BYTES)) + return 1; + + /* test uppercase parsing */ + + if (av_uuid_parse(UUID_1_UC, uuid)) + return 1; + + if (!av_uuid_equal(uuid, UUID_1_BYTES)) + return 1; + + /* test mixed-case parsing */ + + if (av_uuid_parse(UUID_1_MIXED, uuid)) + return 1; + + if (!av_uuid_equal(uuid, UUID_1_BYTES)) + return 1; + + /* test URN uuid parse */ + + if (av_uuid_urn_parse(UUID_1_URN, uuid)) + return 1; + + if (!av_uuid_equal(uuid, UUID_1_BYTES)) + return 1; + + /* test parse range */ + + if (av_uuid_parse_range(UUID_1_URN + 9, UUID_1_URN + 45, uuid)) + return 1; + + if (!av_uuid_equal(uuid, UUID_1_BYTES)) + return 1; + + /* test bad parse range */ + + if (!av_uuid_parse_range(UUID_1_URN + 9, UUID_1_URN + 44, uuid)) + return 1; + + /* test bad parse range 2 */ + + if (!av_uuid_parse_range(UUID_1_URN + 8, UUID_1_URN + 44, uuid)) + return 1; + + /* test bad parse range 2 */ + + if (!av_uuid_parse_range(UUID_1_URN + 8, UUID_1_URN + 45, uuid)) + return 1; + + /* test bad uuid 1 */ + + if (!av_uuid_parse(UUID_BAD_1, uuid)) + return 1; + + /* test bad uuid 2 */ + + if (!av_uuid_parse(UUID_BAD_2, uuid)) + return 1; + + /* test bad uuid 3 */ + + if (!av_uuid_parse(UUID_BAD_3, uuid)) + return 1; + + /* test bad uuid 4 */ + + if (!av_uuid_parse(UUID_BAD_4, uuid)) + return 1; +} diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index c32cf2e706..80153f4395 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -170,6 +170,11 @@ FATE_LIBAVUTIL += fate-opt fate-opt: libavutil/tests/opt$(EXESUF) fate-opt: CMD = run libavutil/tests/opt$(EXESUF) +FATE_LIBAVUTIL += fate-uuid +fate-uuid: libavutil/tests/uuid$(EXESUF) +fate-uuid: CMD = run libavutil/tests/uuid$(EXESUF) +fate-uuid: CMP = null + FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes) FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL) fate-libavutil: $(FATE_LIBAVUTIL)