From patchwork Thu Jun 2 00:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 36038 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6914:b0:82:6b11:2509 with SMTP id q20csp3738983pzj; Wed, 1 Jun 2022 17:31:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznQa+ZWGBdY8l7JQ5fFAnu/lUHFiemSUonISOY/GsXrLCbaBEeJGX8G+We42opTD4feD6A X-Received: by 2002:a05:6402:44e:b0:42a:6266:3f15 with SMTP id p14-20020a056402044e00b0042a62663f15mr2613922edw.418.1654129869512; Wed, 01 Jun 2022 17:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654129869; cv=none; d=google.com; s=arc-20160816; b=XDzzxaCAr5vsoaakpCx4oF1Lshf1qEZUXlrghcCUDU2JQdxyVykjwkoEqd+h+4WDuR OFWwpMXQ0V9YO6E3HjgaZdzMeE68zqEdExd2JNEeUxJ5e0M4qefyxjx+mGvlIhek10rV AhHbjoWpkgTFJRe0eRH1Jp8ACOYb+/YlJiqiLt06SiJDjJ72MTGjPVVnnVERM8weJAea IwSr0hM2LRj9hwZ0RFZViH751JdOq4ELYajRmkWdRIO8UqHkrNM91L9XnhbCxoUZelJ1 ZRPI+wmGy1RTDBWt8xaq/lLY3lGHCjjKO68xYudTpLs3zw/qjxUfJAOV+v5KwLjKyNXb MqhQ== 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=nDBMqcJRg+8SDbBD38sou3gdimoLeHTgjbRReSGK0ZE=; b=fn3oy6FsDx4a9Y7oh0avA7uMGaudEvro/uF0b5dOUF9ZveqcJPv+NV1ooWJGh1QYVV X5DZCE5DtwtwwrV5pTEirA1cS2MI50xuWncWNrovXQ2yOCuGGBOhipLTcd9w71WG6jMc ib7tJriJI4yToiu54SyG0s2o9yUXhdw+V7THG/NO2oDwanaMNP9zcl8Qg4lggX7fzzFD uPG+j4ARUwKGF6FK1K3oDXD29of2Bmz5/IyTEg0lh/QSHTDtTpF6AYWuf/NIFS/BmyQJ KvT4+JuKYp4K6rkmkDVQuLuuDG0b+Y1msCWBBrB7cQrONQjKwFNQh4ejpSIyE+7buvr6 R3FQ== 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w12-20020a1709062f8c00b006f38560fe61si3191216eji.94.2022.06.01.17.31.09; Wed, 01 Jun 2022 17:31:09 -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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 255F768B7B2; Thu, 2 Jun 2022 03:30:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2A84B68B60A for ; Thu, 2 Jun 2022 03:30:50 +0300 (EEST) Received: by mail-pj1-f53.google.com with SMTP id a10so3481857pju.3 for ; Wed, 01 Jun 2022 17:30:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fEQhv6FeTKETHnUqKBIak/1OT2JTV4ywf5O6lwGXBIM=; b=nYp2OJFBLmtv/ss5A5byOGihJJcMVAw1UUV6C2ImdFDprgu/CZXGkMxUGmpAx2jRaI 2OE2dmiRqJmjeklG9h7CEr2S9G/I7mos0e09usPBASWxtm6EssLmjulCsx3N0PUuk7lC 9/v34Zvvx8BzNz3PviNxcFgdghZO2aj9pfKnosheOjCZqFwwGWzFhxLIwjEQRFZdXQYI 5h+hEB/eUfbPu2yT/eu2ifFPPVpUoK9xZQo32BcnuzTUex3MGROr+Ttsme4CwlyzxeKB mjuOfDsrhCVu4oF2EZ1ypgZE1s5/QxqvafEyt0PYkRSqPz3iynIfYRp040GBg1aGgPFc BDPg== X-Gm-Message-State: AOAM531oiUUvsDfzEW4hIi97u3b3A0jqBjO853P7Z2tjkPnx6kN6hxSI 133/9SDouqI8CN7aFEqq0Bl1ZcZdW6c= X-Received: by 2002:a17:90b:4b88:b0:1e2:d504:fb22 with SMTP id lr8-20020a17090b4b8800b001e2d504fb22mr2163829pjb.97.1654129848057; Wed, 01 Jun 2022 17:30:48 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id y13-20020a17090a600d00b001d9927ef1desm4407235pji.34.2022.06.01.17.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 17:30:47 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Wed, 01 Jun 2022 17:30:42 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Jun 2022 17:30:33 -0700 Message-Id: <20220602003037.24597-2-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220602003037.24597-1-pal@sandflow.com> References: <20220602003037.24597-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 2/6] 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: /iSvRk/DR5SU From: Pierre-Anthony Lemieux --- libavutil/Makefile | 1 + libavutil/tests/.gitignore | 1 + libavutil/tests/uuid.c | 141 +++++++++++++++++++++++++++++++++++++ tests/fate/libavutil.mak | 5 ++ 4 files changed, 148 insertions(+) create mode 100644 libavutil/tests/uuid.c diff --git a/libavutil/Makefile b/libavutil/Makefile index a0c5cacef4..5c2ff319cc 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -261,6 +261,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..ff688be030 --- /dev/null +++ b/libavutil/tests/uuid.c @@ -0,0 +1,141 @@ +/* + * 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(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; + + return 0; +} 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)