Skip to content

Commit a0e5006

Browse files
committed
test: add multi-threads jpeg_encode test
1 parent 4cdb22f commit a0e5006

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.github/workflows/UnitTest.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,20 @@ jobs:
4545
- uses: codecov/codecov-action@v2
4646
with:
4747
files: lcov.info
48-
48+
multithreads:
49+
name: Julia (threads) 1 - ubuntu-latest - x64 - ${{ github.event_name }}
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v2
53+
- uses: julia-actions/setup-julia@v1
54+
with:
55+
version: '1'
56+
arch: 'x64'
57+
- uses: julia-actions/cache@v1
58+
- uses: julia-actions/julia-buildpkg@v1
59+
- name: run test
60+
run: julia --project --code-coverage -t4 -e 'using Pkg; Pkg.test()'
61+
- uses: julia-actions/julia-processcoverage@v1
62+
- uses: codecov/codecov-action@v2
63+
with:
64+
files: lcov.info

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ end
4747
end
4848

4949
include("tst_encode.jl")
50+
if Threads.nthreads() > 1
51+
@info "Multi-threads test: enabled"
52+
include("tst_multithreads.jl")
53+
else
54+
@info "Multi-threads test: skipped"
55+
end
5056
end

test/tst_multithreads.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@testset "multithreads" begin
2+
@test Threads.nthreads() > 1
3+
4+
img = testimage("lighthouse")
5+
@testset "jpeg_encode" begin
6+
ref = jpeg_encode(img)
7+
8+
out = [fill(zero(UInt8), size(ref)) for _ in 1:Threads.nthreads()]
9+
Threads.@threads for i in 1:Threads.nthreads()
10+
out[i] = jpeg_encode(img)
11+
end
12+
@test all(out .== Ref(ref))
13+
end
14+
end

0 commit comments

Comments
 (0)