Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: yzewei <[email protected]>
  • Loading branch information
yzewei committed Jan 5, 2024
1 parent 30389ea commit 5e9c2b9
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ target "_all-platforms" {
"linux/mips64le",
"linux/ppc64le",
"linux/s390x",
"linux/riscv64",
"linux/riscv64",
"linux/loong64"
]
}
Expand Down
13 changes: 2 additions & 11 deletions src/test-cargo.bats
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ testHelloCargoRustup() {
}

@test "loong64-hellocargo-rustup" {
if ! supportLoongArchCGo; then
skip "LOONG64 not supported" # rust stdlib package not available
fi
export TARGETARCH=loong64
testHelloCargoRustup
skip "LOONG64 not supported" # rust stdlib package not available
}

@test "386-hellocargo-rustup" {
Expand Down Expand Up @@ -152,12 +148,7 @@ testHelloCargoRustup() {
}

@test "loong64-hellocargo-rustpkg" {
if ! supportLoongArchCGo; then
skip "LOONG64 not supported" # rust stdlib package not available
fi
export TARGETARCH=loong64
export LOONGARCH64_TARGET_ARCH=loong64
testHelloCargo
skip "LOONG64 not supported" # rust stdlib package not available
}

@test "386-hellocargo-rustpkg" {
Expand Down
8 changes: 4 additions & 4 deletions src/test-clang.bats
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ testBuildHello() {
}

@test "loong64-c-ld" {
skip "LOONG64 not supported"
if ! supportLoongArch; then
skip "LOONGARCH not supported"
fi
export TARGETARCH=loong64
testHelloCLLD # actually runs with ld
expectedLinker=
expectedSuffix=
testHelloCLLD
}

@test "ppc64le-c-lld" {
Expand Down
103 changes: 100 additions & 3 deletions src/test-go.bats
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ testEnv() {
}

@test "loong64-env" {
skip "LOONG64 GO not supported"
export TARGETARCH=loong64
testEnv
}
Expand Down Expand Up @@ -170,6 +169,106 @@ testEnv() {
unset TARGETOS
}


testHelloGO() {
run xx-go build -o /tmp/a.out ./fixtures/hello.go
assert_success
xx-verify /tmp/a.out
if ! xx-info is-cross; then
run /tmp/a.out
assert_success
assert_output "hello go"
fi
}

@test "native-hellogo" {
unset TARGETARCH
testHelloGO
}

@test "amd64-hellogo" {
export TARGETARCH=amd64
testHelloGO
}

@test "arm64-hellogo" {
export TARGETARCH=arm64
testHelloGO
}

@test "arm-hellogo" {
export TARGETARCH=arm
testHelloGO
}

@test "armv5-hellogo" {
export TARGETARCH=arm
export TARGETVARIANT=v5
testHelloGO
unset TARGETVARIANT
}

@test "s390x-hellogo" {
export TARGETARCH=s390x
testHelloGO
}

@test "ppc64le-hellogo" {
export TARGETARCH=ppc64le
testHelloGO
}

@test "riscv64-hellogo" {
if ! supportRiscVGo; then
skip "RISC-V GO not supported"
fi
export TARGETARCH=riscv64
testHelloGO
}

@test "loong64-hellogo" {
if ! supportLoongArchGo; then
skip "LOONG64 GO not supported"
fi
export TARGETARCH=loong64
testHelloGO
}

@test "386-hellogo" {
export TARGETARCH=386
testHelloGO
}

@test "mipsle-hellogo" {
export TARGETARCH=mipsle
testHelloGO
}

@test "mipsle-softfloat-hellogo" {
export TARGETARCH=mipsle
export TARGETVARIANT=softfloat
testHelloGO
unset TARGETVARIANT
}

@test "mips64le-hellogo" {
export TARGETARCH=mips64le
testHelloGO
}

@test "mips64le-softfloat-hellogo" {
export TARGETARCH=mips64le
export TARGETVARIANT=softfloat
testHelloGO
unset TARGETVARIANT
}

@test "darwin-amd64-hellogo" {
export TARGETARCH=amd64
export TARGETOS=darwin
testHelloGO
}

testHelloCGO() {
export CGO_ENABLED=1
xxadd xx-c-essentials
Expand Down Expand Up @@ -220,8 +319,6 @@ testHelloCGO() {

@test "loong64-hellocgo" {
skip "LOONG64 CGO not supported"
export TARGETARCH=loong64
testHelloCGO
}

@test "386-hellocgo" {
Expand Down
4 changes: 2 additions & 2 deletions src/test-info-alpine.bats
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ load 'assert'
}

@test "loong64" {
assert_equal "loong64-alpine-linux-muslabi" "$(TARGETPLATFORM=linux/loong64 xx-info triple)"
assert_equal "loong64" "$(TARGETPLATFORM=linux/loong64 xx-info pkg-arch)"
assert_equal "loong64-alpine-linux-musl" "$(TARGETPLATFORM=linux/loong64 xx-info triple)"
assert_equal "loongarch64" "$(TARGETPLATFORM=linux/loong64 xx-info pkg-arch)"
}

@test "custom-vendor" {
Expand Down
9 changes: 1 addition & 8 deletions src/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,7 @@ supportLoongArch() {
}

supportLoongArchGo() {
go version | grep -E "1.14|1.15|1.16|1.17|1.18|1.19|1.20|1.21" >/dev/null 2>&1
}

supportLoongArchCGo() {
if ! supportLoongArch; then
return 1
fi
go version | egrep -E "1.16|1.17|1.18|1.19|1.20|1.21" >/dev/null 2>&1
go version | grep -E "1.19|1.20|1.21" >/dev/null 2>&1
}

supportRC() {
Expand Down
3 changes: 0 additions & 3 deletions src/xx-cargo
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ fi
if [ -z "$ARM_TARGET_ARCH" ]; then
export ARM_TARGET_ARCH=armv7
fi
if [ -z "$LOONG64_TARGET_ARCH" ]; then
export LOONG64_TARGET_ARCH=loong64
fi

rustup=
if which rustup >/dev/null 2>&1; then
Expand Down
2 changes: 1 addition & 1 deletion src/xx-cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ setup() {
exp="riscv"
fi
if [ "$exp" = "loong64" ]; then
exp="loong64"
exp="loongarch"
fi
if ld -V 2>/dev/null | grep $exp >/dev/null; then
ln -s "$(command -v ld)" "/usr/bin/${target}-ld"
Expand Down
2 changes: 1 addition & 1 deletion src/xx-info
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ case "$TARGETARCH" in
"loong64")
XX_MARCH="loong64"
XX_DEBIAN_ARCH="loong64"
XX_ALPINE_ARCH="loong64"
XX_ALPINE_ARCH="loongarch64"
XX_RHEL_ARCH="loong64"
XX_TRIPLE="loong64${vendor}-linux-${XX_LIBC}abi"
;;
Expand Down
6 changes: 2 additions & 4 deletions util/bats-assert/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#FROM --platform=$BUILDPLATFORM alpine AS build
FROM cr.loongnix.cn/library/alpine:3.11 AS build
FROM --platform=$BUILDPLATFORM alpine AS build
RUN apk add --no-cache git
WORKDIR /work
ENV https_proxy=http://10.130.0.20:7890
RUN git clone --bare https://github.com/ztombol/bats-support && \
mkdir -p /out/bats-support && cd /out/bats-support && \
git --git-dir=/work/bats-support.git --work-tree=. checkout 004e707638eedd62e0481e8cdc9223ad471f12ee -- src load.bash LICENSE
Expand All @@ -18,7 +16,7 @@ RUN echo 'source "$(dirname "${BASH_SOURCE[0]}")/bats-support/load.bash"' > /out
FROM scratch AS release
COPY --from=build /out /

FROM cr.loongnix.cn/library/alpine:3.11 AS test-gen
FROM alpine AS test-gen
RUN apk add --no-cache bats
WORKDIR /work
COPY --from=release . .
Expand Down
2 changes: 1 addition & 1 deletion util/bats-assert/test.bats.golden
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ not ok 5 run-fail

The following warnings were encountered during tests:
BW01: `run`'s command `./foobar` exited with code 127, indicating 'Command not found'. Use run's return code checks, e.g. `run -127`, to fix this message.
(from function `run' in file /usr/lib/bats-core/test_functions.bash, line 297,
(from function `run' in file /usr/lib/bats-core/test_functions.bash, line 421,
in test file test.bats, line 15)

0 comments on commit 5e9c2b9

Please sign in to comment.