Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aarch64 linux CI. Add FreeBSD, M1 #386

Merged
merged 12 commits into from
Jan 4, 2023
58 changes: 58 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
task:
matrix:
- name: FreeBSD
freebsd_instance:
image_family: freebsd-13-1
env:
matrix:
- JULIA_VERSION: 1.6
- JULIA_VERSION: 1
# - JULIA_VERSION: nightly # not available
- name: Linux ARMv8
arm_container:
image: ubuntu:latest
env:
matrix:
- JULIA_VERSION: 1.6
- JULIA_VERSION: 1
- JULIA_VERSION: nightly
# - name: musl Linux # skip because of https://github.com/JuliaLang/julia/issues/40556
# container:
# image: alpine:3.14
# env:
# matrix:
# - JULIA_VERSION: 1.6
# - JULIA_VERSION: 1
# - JULIA_VERSION: nightly
- name: MacOS M1
macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-base:latest
env:
matrix:
# - JULIA_VERSION: 1.6 # not available
- JULIA_VERSION: 1
- JULIA_VERSION: nightly

allow_failures: $JULIA_VERSION == 'nightly'
install_script: |
URL="https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh"
set -x
if [ "$(uname -s)" = "Linux" ] && command -v apt; then
apt update
apt install -y curl
fi
if command -v curl; then
sh -c "$(curl ${URL})"
elif command -v wget; then
sh -c "$(wget ${URL} -O-)"
elif command -v fetch; then
sh -c "$(fetch ${URL} -o -)"
else
echo "No downloader installed! :( Install one! :)"
fi
build_script:
- cirrusjl build
test_script:
- cirrusjl test
coverage_script:
- cirrusjl coverage codecov
15 changes: 0 additions & 15 deletions .drone.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ test/ordertest_gray_test.mp4
docs/build/
test/temp.stream
.vscode/
*.heapsnapshot
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
15 changes: 9 additions & 6 deletions test/bugs.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@testset "c api memory leak test" begin
if (Sys.islinux())
if (Sys.islinux())
@testset "c api memory leak test" begin
function get_memory_usage()
open("/proc/$(getpid())/statm") do io
return split(read(io, String))[1]
Expand All @@ -20,9 +20,11 @@
usage_vec[i] = get_memory_usage()
end

println(usage_vec)

@debug "open file test" usage_vec
@test usage_vec[end-1] == usage_vec[end]
if usage_vec[end-1] != usage_vec[end]
@error "open file test" usage_vec
end
end

@testset "open and read file test" begin
Expand All @@ -38,9 +40,10 @@
usage_vec[i] = get_memory_usage()
end

println(usage_vec)

@test usage_vec[end-1] == usage_vec[end]
if usage_vec[end-1] != usage_vec[end]
@error "open and read file test" usage_vec
end
end
end
end
26 changes: 16 additions & 10 deletions test/reading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
end
end
end
@memory_profile

@testset "Reading monochrome videos" begin
testvid_path = joinpath(@__DIR__, "../videos", "annie_oakley.ogg")
Expand All @@ -163,25 +164,29 @@ end
)
@test minp.val.i >= 16
@test maxp.val.i <= 235
GC.gc()
end
@memory_profile

@testset "Reading RGB video as monochrome" begin
@testset "Iterative" begin
io = VideoIO.testvideo("ladybird")
f = VideoIO.openvideo(io, target_format = VideoIO.AV_PIX_FMT_GRAY8)
img = read(f)
for i in 1:10
read!(f, img)
VideoIO.openvideo(io, target_format = VideoIO.AV_PIX_FMT_GRAY8) do f
img = read(f)
for i in 1:10
read!(f, img)
end
@test eltype(img) == Gray{N0f8}
end
@test eltype(img) == Gray{N0f8}
close(f)
end
@testset "Full load" begin
testvid_path = joinpath(@__DIR__, "../videos", "ladybird.mp4")
vid = VideoIO.load(testvid_path, target_format = VideoIO.AV_PIX_FMT_GRAY8)
@test eltype(first(vid)) == Gray{N0f8}
end
GC.gc()
end
@memory_profile

@testset "IO reading of various example file formats" begin
swscale_options = (sws_flags = "accurate_rnd+full_chroma_inp+full_chroma_int",)
Expand All @@ -194,8 +199,7 @@ end
testvid_path = joinpath(@__DIR__, "../videos", name)
comparison_frame = make_comparison_frame_png(load, testvid_path, test_frameno)
filename = joinpath(videodir, name)
v = VideoIO.openvideo(filename; swscale_options = swscale_options)
try
VideoIO.openvideo(filename; swscale_options = swscale_options) do v
width, height = VideoIO.out_frame_size(v)
if size(comparison_frame, 1) > height
trimmed_comparison_frame = comparison_frame[1+size(comparison_frame, 1)-height:end, :]
Expand Down Expand Up @@ -238,16 +242,17 @@ end
## Test that iterator is mutable, and continues where iteration last
## stopped.
@test iterate(v) === nothing
finally
close(v)
end
GC.gc()
end
end

VideoIO.testvideo("ladybird") # coverage testing
@test_throws ErrorException VideoIO.testvideo("rickroll")
@test_throws ErrorException VideoIO.testvideo("")
GC.gc()
end
@memory_profile

@testset "Reading video metadata" begin
@testset "Reading Storage Aspect Ratio: SAR" begin
Expand All @@ -271,3 +276,4 @@ end
@test_throws ErrorException VideoIO.get_number_frames("Not_a_file")
end
end
@memory_profile
26 changes: 19 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using Test
using ColorTypes: RGB, Gray, N0f8, red, green, blue
using ColorVectorSpace: ColorVectorSpace
using FileIO, ImageCore, Dates, Statistics, StatsBase
using Profile

using FFMPEG: FFMPEG

Expand All @@ -18,14 +19,25 @@ VideoIO.TestVideos.download_all()

include("utils.jl") # Testing utility functions

include("avptr.jl")
include("reading.jl")
include("writing.jl")
include("accuracy.jl")
memory_profiling = get(ENV, "VIDEOIO_MEMPROFILE", "false") === "true" && Base.thisminor(Base.VERSION) >= v"1.9"
start_time = time()

GC.gc()
rm(tempvidpath, force = true)
@memory_profile

include("bugs.jl")
@testset "VideoIO" verbose = true begin
include("avptr.jl")
@memory_profile
include("reading.jl")
@memory_profile
include("writing.jl")
@memory_profile
include("accuracy.jl")
@memory_profile

GC.gc()
rm(tempvidpath, force = true)

include("bugs.jl")
@memory_profile
end
#VideoIO.TestVideos.remove_all()
14 changes: 14 additions & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,17 @@ function copy_imgbuf_to_buf!(buf::StridedArray, fwidth::Integer, fheight::Intege
bwidth = nbytesperpixel * fwidth
return copy_imgbuf_to_buf!(reinterpret(UInt8, buf), bwidth, fheight, args...)
end

macro memory_profile()
if memory_profiling
_line = __source__.line
_file = string(__source__.file)
_mod = __module__
quote
local snap_fpath = Profile.take_heap_snapshot()
local free_mem = Base.format_bytes(Sys.free_memory())
local total_mem = Base.format_bytes(Sys.total_memory())
@warn "Memory profile @ $(time() - start_time)s" free_mem total_mem snap_fpath _module=$_mod _line=$_line _file=$(repr(_file))
end
end
end