From: pal@sandflow.com
To: ffmpeg-devel@ffmpeg.org
Cc: Pierre-Anthony Lemieux <pal@palemieux.com>
Subject: [FFmpeg-devel] [PATCH v4 2/6] avutil/tests/uuid: add uuid tests
Date: Wed, 1 Jun 2022 17:30:33 -0700
Message-ID: <20220602003037.24597-2-pal@sandflow.com> (raw)
In-Reply-To: <20220602003037.24597-1-pal@sandflow.com>
From: Pierre-Anthony Lemieux <pal@palemieux.com>
---
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 <pal@palemieux.com>
+ * Zane van Iperen <zane@zanevaniperen.com>
+ *
+ * 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)
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-06-02 0:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-02 0:30 [FFmpeg-devel] [PATCH v4 1/6] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 pal
2022-06-02 0:30 ` pal [this message]
2022-06-07 12:55 ` [FFmpeg-devel] [PATCH v4 2/6] avutil/tests/uuid: add uuid tests Zane van Iperen
2022-06-02 0:30 ` [FFmpeg-devel] [PATCH v4 3/6] avformat/mov: refactor to use avutil/uuid pal
2022-06-02 0:30 ` [FFmpeg-devel] [PATCH v4 4/6] avformat/smoothstreamingenc: " pal
2022-06-02 0:30 ` [FFmpeg-devel] [PATCH v4 5/6] avformat/imf: " pal
2022-06-02 0:30 ` [FFmpeg-devel] [PATCH v4 6/6] avfilter/showinfo: " pal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220602003037.24597-2-pal@sandflow.com \
--to=pal@sandflow.com \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=pal@palemieux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git