tests/containers: comments: specs only
This commit is contained in:
1 parent
53aa9a6ebf
commit
70f50917fa
5 files changed
+8
-46
No files matched your search
@@ -1,5 +1,4 @@
|
||||
-- containers/Chunks tests: RIFF (padding, an odd chunk without its pad byte, open-ended data), IFF big-endian, PNG
|
||||
-- (size first + CRC trailer, truncation), CAF 64-bit sizes, resize hooks, find, and a no-throw pass over garbage.
|
||||
-- containers/Chunks tests: RIFF, IFF, PNG and CAF chunks, resize hooks, find, and a no-throw pass over garbage.
|
||||
local T = require("@tests/T")
|
||||
local Chunks = require("@rosetta/containers/Chunks")
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
-- containers/IsoBmff tests: ffmpeg / MP4Box files (H.264 + AAC with B-frames, fast start, QuickTime MJPEG + PCM, HEVC,
|
||||
-- fragmented by ffmpeg and MP4Box, stz2 + co64, ALAC) demuxed packet for packet against ffprobe (-ignore_editlist);
|
||||
-- track facts and codec configurations; iTunes tags and cover art; AVIF items (libavif, plain and with alpha); the
|
||||
-- muxer round-trips through the demuxer (sizes, times, cts, sync, tags, 64-bit sizes); a sub-range reader; the fuzz
|
||||
-- no-throw pass. Fixtures: tools/fixtures/isobmff.py.
|
||||
-- containers/IsoBmff tests: ffmpeg / MP4Box files against ffprobe (-ignore_editlist), AVIF items, the muxer.
|
||||
-- Fixtures: tools/fixtures/isobmff.py.
|
||||
local T = require("@tests/T")
|
||||
local IsoBmff = require("@rosetta/containers/IsoBmff")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -22,7 +19,6 @@ local function reader(s: string, pad: number?): Bytes.Reader
|
||||
return Bytes.reader(buffer.fromstring(s))
|
||||
end
|
||||
|
||||
-- every fixture against ffprobe
|
||||
for _, c in Fx.cases do
|
||||
for _, pad in { 0, 5 } do
|
||||
local r = reader(c.data, if pad > 0 then pad else nil)
|
||||
@@ -46,7 +42,6 @@ for _, c in Fx.cases do
|
||||
t:eq(if tr.config then buffer.len(tr.config) else 0, s.extradata, label .. ": codec config size")
|
||||
end
|
||||
end
|
||||
-- packets in file order
|
||||
local n, bad = 0, nil
|
||||
local base = r.base
|
||||
for p in dmx:packets() do
|
||||
@@ -73,7 +68,6 @@ for _, c in Fx.cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- per-track packets, seek
|
||||
do
|
||||
local c = Fx.cases[1]
|
||||
local dmx = IsoBmff.demux(reader(c.data))
|
||||
@@ -90,7 +84,6 @@ do
|
||||
t:check(v.skip >= 0 and v.edits ~= nil, "edit list parsed")
|
||||
end
|
||||
|
||||
-- tags and cover
|
||||
do
|
||||
local r = reader(Fx.tagged.data)
|
||||
local movie = IsoBmff.parse(r) :: IsoBmff.Movie
|
||||
@@ -104,7 +97,6 @@ do
|
||||
t:eq(pics[1] and pics[1].mime, "image/png", "cover mime")
|
||||
end
|
||||
|
||||
-- AVIF items
|
||||
for _, c in Fx.avif do
|
||||
local r = reader(c.data)
|
||||
t:check(IsoBmff.sniff(r) == "avif", c.name .. ": brand")
|
||||
@@ -139,7 +131,6 @@ for _, c in Fx.avif do
|
||||
t:eq(auxl ~= nil, c.alpha, c.name .. ": alpha auxiliary item")
|
||||
end
|
||||
|
||||
-- the muxer: round trip through the demuxer
|
||||
do
|
||||
local rand = T.rng(5)
|
||||
local function sample(n: number): buffer
|
||||
@@ -199,7 +190,6 @@ do
|
||||
t:check(tags.title == "Mux Test" and tags.artist == "Me" and tags.track == "2" and tags.tracktotal == "9" and tags.custom == "free form" and tags.bpm == "120", "mux: tags round trip")
|
||||
t:check(#pics == 1 and buffer.len(pics[1].data) == 4, "mux: cover round trip")
|
||||
t:note("mux: %d bytes, crc %08x", buffer.len(file :: buffer), Crc32.of(file :: buffer))
|
||||
-- data + sizes form, bad specs
|
||||
local f2 = IsoBmff.mux({ tracks = { { kind = "audio", entry = "alac", timescale = 8000, data = buffer.create(30), sizes = { 10, 10, 10 }, durations = { 4096, 4096, 100 }, config = buffer.create(24) } } })
|
||||
local d2 = IsoBmff.demux(Bytes.reader(f2 :: buffer))
|
||||
t:check(d2 and d2.tracks[1].codec == "alac" and d2.tracks[1].sampleCount == 3 and d2.tracks[1].durations[3] == 100 and buffer.len(d2.tracks[1].config) == 24, "mux: data + sizes, alac cookie")
|
||||
@@ -209,7 +199,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Fx.cases do
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
-- containers/Ogg tests: real encoder files (opusenc, flac --ogg, ffmpeg vorbis) and hand-made multiplexed files,
|
||||
-- checked packet by packet against the independent Python parser of tools/fixtures/ogg.py; seeking on each; a big
|
||||
-- multiplexed file written with the muxer (bisection seeks); muxer edge cases (lacing at 255 multiples, page breaks,
|
||||
-- continued packets, flush, eos); a sub-range Reader; truncated / garbage input never throws. The muxer was also
|
||||
-- checked by hand against opus-tools: an opusenc file remuxed through it passes opusinfo and decodes identically.
|
||||
-- Ported from ogg-luau tests/ogg.luau. Fixtures: tools/fixtures/ogg.py.
|
||||
-- containers/Ogg tests: encoder and hand-made multiplexed files against the parser in tools/fixtures/ogg.py, the muxer.
|
||||
-- The muxer was checked against opus-tools: an opusenc file remuxed through it passes opusinfo, decodes identically.
|
||||
-- Fixtures: tools/fixtures/ogg.py.
|
||||
local T = require("@tests/T")
|
||||
local Ogg = require("@rosetta/containers/Ogg")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -13,7 +10,6 @@ local Cases = require("@tests/gen/ogg_cases")
|
||||
|
||||
local t = T.suite("ogg")
|
||||
|
||||
-- seek expectations from a packet list: { size, crc, granule, bos, eos }
|
||||
local function expectSeek(list: { any }, g: number): (number, number)
|
||||
local start, idx = -1, 1
|
||||
for i, p in list do
|
||||
@@ -77,7 +73,6 @@ for _, fx in Cases do
|
||||
t:eq(counts[i], #fx.streams[i].packets, fx.name .. ": interleaved count")
|
||||
end
|
||||
end
|
||||
-- seeking
|
||||
for _, es in fx.streams do
|
||||
local serial = es.serial
|
||||
local last = es.lastGranule
|
||||
@@ -104,7 +99,6 @@ for _, fx in Cases do
|
||||
end
|
||||
end
|
||||
end
|
||||
-- a Reader over a sub-range of a bigger buffer
|
||||
local big = buffer.create(#fx.data + 20)
|
||||
buffer.writestring(big, 11, fx.data)
|
||||
local ds = Ogg.open(Bytes.reader(big, 11, #fx.data))
|
||||
@@ -221,7 +215,6 @@ do
|
||||
t:check(pages > 70, "edge: page breaks (" .. pages .. " pages)")
|
||||
t:eq(d:stream(42).lastGranule, #sizes * 10, "edge: last granule")
|
||||
t:eq(d:stream(42).codec, "unknown", "edge: codec")
|
||||
-- strings, ranges and bad arguments
|
||||
local m2 = Ogg.muxer()
|
||||
local s2 = m2:stream()
|
||||
t:check(s2:packet("OpusHead" .. string.rep("\0", 11), 0, { flush = true }), "string packet")
|
||||
@@ -237,7 +230,6 @@ do
|
||||
t:check(d2:nextPacket(1) == nil, "empty eos page ends the stream")
|
||||
end
|
||||
|
||||
-- errors and garbage
|
||||
do
|
||||
local _, e1 = Ogg.open(buffer.create(0))
|
||||
t:check(e1 and e1.code == Err.CORRUPT, "empty: " .. tostring(e1))
|
||||
@@ -246,7 +238,6 @@ do
|
||||
t:check(e2 and e2.code == Err.ARG, "not a buffer: " .. tostring(e2))
|
||||
end
|
||||
|
||||
-- fuzz: open + read every packet + seek never throws
|
||||
t:fuzz("open + read + seek", function(b: buffer)
|
||||
local d = Ogg.open(b)
|
||||
if d then
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- containers/Riff tests: the writer (RIFF, RIFX, forced RF64 with ds64, LIST/INFO, odd pad bytes, parts) read back by
|
||||
-- the reader; lenient reading (missing pad byte, truncated chunk, open-ended data of size 0 / 0xFFFFFFFF, the ds64
|
||||
-- table, a sub-range Reader); errors; the fuzz pass. The WAVE form is checked against ffmpeg in tests/audio/wav.luau.
|
||||
-- containers/Riff tests: writer -> reader, lenient reading, errors. WAVE vs ffmpeg is in tests/audio/wav.luau.
|
||||
local T = require("@tests/T")
|
||||
local Riff = require("@rosetta/containers/Riff")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -14,7 +12,6 @@ local function u32(v: number): string
|
||||
return buffer.tostring(b)
|
||||
end
|
||||
|
||||
-- writer -> reader
|
||||
local samples = {}
|
||||
for _, mode in { "riff", "rifx", "rf64" } do
|
||||
local w = Riff.writer("TEST", { bigEndian = mode == "rifx", rf64 = mode == "rf64", sampleCount = 77 })
|
||||
@@ -49,7 +46,6 @@ for _, mode in { "riff", "rifx", "rf64" } do
|
||||
if mode == "rf64" then
|
||||
t:check(f.ds64 and f.ds64.dataSize == 8 and f.ds64.sampleCount == 77 and d.declared == 0xFFFFFFFF, "rf64: ds64")
|
||||
end
|
||||
-- parts: the same bytes
|
||||
local parts = w:finish({ parts = true }) :: { buffer }
|
||||
local j = Bytes.writer()
|
||||
for _, p in parts do
|
||||
@@ -59,28 +55,23 @@ for _, mode in { "riff", "rifx", "rf64" } do
|
||||
end
|
||||
t:check(not Riff.writer("WAVE", { bigEndian = true, rf64 = true }):finish(), "RIFX RF64 refused")
|
||||
|
||||
-- lenient reading
|
||||
do
|
||||
-- a missing pad byte after an odd chunk
|
||||
local body = "WAVE" .. "abcd" .. u32(5) .. "12345" .. "next" .. u32(2) .. "ok"
|
||||
local f = Riff.read(buffer.fromstring("RIFF" .. u32(#body) .. body)) :: any
|
||||
t:check(#f.chunks == 2 and f.chunks[2].id == "next", "missing pad byte detected")
|
||||
-- truncated
|
||||
local tb = "WAVE" .. "data" .. u32(100) .. "short"
|
||||
local ft = Riff.read(buffer.fromstring("RIFF" .. u32(#tb) .. tb)) :: any
|
||||
t:check(ft.chunks[1].truncated and ft.chunks[1].avail == 5 and ft.chunks[1].size == 100, "truncated chunk")
|
||||
-- open-ended
|
||||
for _, sz in { 0, 0xFFFFFFFF } do
|
||||
local ob = "WAVE" .. "data" .. u32(sz) .. "abcdefLIST"
|
||||
local fo = Riff.read(buffer.fromstring("RIFF" .. u32(0) .. ob), { openEnded = { data = true } }) :: any
|
||||
t:check(#fo.chunks == 1 and fo.chunks[1].streamed and fo.chunks[1].size == 10, "open-ended data " .. sz)
|
||||
end
|
||||
-- ds64 table
|
||||
local ds = "ds64" .. u32(40) .. u32(0) .. u32(0) .. u32(4) .. u32(0) .. u32(0) .. u32(0) .. u32(1) .. "big " .. u32(3) .. u32(0)
|
||||
local rb = "WAVE" .. ds .. "big " .. u32(0xFFFFFFFF) .. "xyz" .. "\0"
|
||||
local fr = Riff.read(buffer.fromstring("RF64" .. u32(0xFFFFFFFF) .. rb)) :: any
|
||||
t:check(fr.ds64 and fr.ds64.table["big "] == 3 and fr.chunks[2].size == 3, "ds64 table")
|
||||
-- a sub-range reader
|
||||
local s = samples[1]
|
||||
local big = buffer.create(#s + 7)
|
||||
buffer.writestring(big, 3, s)
|
||||
@@ -89,7 +80,6 @@ do
|
||||
t:eq(Riff.sniff(Bytes.reader(buffer.fromstring(s))), "TEST", "sniff")
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local _, e1 = Riff.read(buffer.fromstring("RIFF"))
|
||||
t:check(e1 and e1.code == Err.TRUNCATED, "too short")
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
-- containers/Tar and containers/Archive tests: hand-made headers for the edge cases the reference archives do not hit
|
||||
-- (base-256 numbers, the historical signed checksum, GNU 'K' long links, pax 'g' global records, pax size overrides,
|
||||
-- v7 headers without magic, a missing end-of-archive marker), the writer's GNU / pax extensions (long links, fractional
|
||||
-- and negative mtimes), and Archive helpers (streamName, entries of foreign archive values, failing loaders).
|
||||
-- containers/Tar and Archive tests: hand-made headers for edge cases the reference archives miss, the writer, helpers.
|
||||
local T = require("@tests/T")
|
||||
local Tar = require("@rosetta/containers/Tar")
|
||||
local Archive = require("@rosetta/containers/Archive")
|
||||
@@ -9,7 +6,6 @@ local Err = require("@rosetta/core/Err")
|
||||
|
||||
local t = T.suite("containers/tar")
|
||||
|
||||
-- a header block built by hand
|
||||
local function hdr(fields: { [string]: any }): buffer
|
||||
local h = buffer.create(512)
|
||||
buffer.writestring(h, 0, fields.name or "f")
|
||||
@@ -94,7 +90,6 @@ do
|
||||
t:eq(list[3].uname, "globaluser", "global records apply to later entries")
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local _, e1 = Tar.read(cat({ hdr({ size = "00000002000\0" }), block("x") }))
|
||||
t:check(e1 and e1.code == Err.TRUNCATED, "data past the end: " .. tostring(e1))
|
||||
@@ -109,7 +104,6 @@ do
|
||||
t:check(list and #list == 0, "empty input is an empty archive")
|
||||
end
|
||||
|
||||
-- writer extensions
|
||||
do
|
||||
local long = string.rep("n", 120)
|
||||
for _, fmt in { "gnu", "pax" } do
|
||||
@@ -128,7 +122,6 @@ do
|
||||
t:check(e and e.code == Err.ARG, "empty name")
|
||||
end
|
||||
|
||||
-- Archive helpers
|
||||
do
|
||||
t:eq(Archive.streamName({ name = "/x/y/notes.txt.gz" }, { "gz" }), "notes.txt", "streamName strips the extension")
|
||||
t:eq(Archive.streamName({ name = "a.tbz2" }, { "bz2" }), "a.tar", "streamName .tbz2")
|
||||
|
||||
Reference in new issue
Block a user