Skip to content

Commit 9b28ad0

Browse files
committed
test: pkgimages and object files with multiple cpu targets
1 parent cdc0133 commit 9b28ad0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/cmdlineargs.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,42 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
726726
end
727727
end
728728

729+
let exename = `$(Base.julia_cmd(; cpu_target="native;native")) --startup-file=no --color=no`
730+
# --pkgimages with multiple cpu targets
731+
@testset let v = readchomperrors(`$exename --pkgimages=no`)
732+
@test !v[1]
733+
@test isempty(v[2])
734+
@test v[3] == "ERROR: More than one command line CPU targets specified without a `--output-` flag specified"
735+
end
736+
737+
@test readchomp(`$exename --pkgimages=yes -e '
738+
println("cpu_target = $(unsafe_string(Base.JLOptions().cpu_target)) and use_pkgimages = $(Base.JLOptions().use_pkgimages)")'`) ==
739+
"cpu_target = native;native and use_pkgimages = 1"
740+
end
741+
742+
# Object file with multiple cpu targets
743+
@testset "Object file for multiple microarchitectures" begin
744+
julia_path = joinpath(Sys.BINDIR, Base.julia_exename())
745+
outputo_file = tempname()
746+
write(outputo_file, "1")
747+
object_file = tempname() * ".o"
748+
749+
# This is to test that even with `pkgimages=no`, we can create object file
750+
# with multiple cpu-targets
751+
# The cmd is checked for `--object-o` as soon as it is run. So, to avoid long
752+
# testing times, intentionally don't pass `--sysimage`; when we reach the
753+
# corresponding error, we know that `check_cmdline` has already passed
754+
let v = readchomperrors(`$julia_path
755+
--cpu-target='native;native'
756+
--output-o=$object_file $outputo_file
757+
--pkgimages=no`)
758+
759+
@test v[1] == false
760+
@test v[2] == ""
761+
@test !contains(v[3], "More than one command line CPU targets specified")
762+
@test v[3] == "ERROR: File \"boot.jl\" not found"
763+
end
764+
end
729765

730766
# Find the path of libjulia (or libjulia-debug, as the case may be)
731767
# to use as a dummy shlib to open

0 commit comments

Comments
 (0)