From 1bfad74561b063efd3669b72d0e460be45df3023 Mon Sep 17 00:00:00 2001 From: YazZz1k Date: Thu, 27 Oct 2022 14:42:22 +0300 Subject: [PATCH] [ci] introduce mpl_test --- testsuite/driver/config/ci_testall.conf | 1 + testsuite/driver/config/testall.conf | 1 + testsuite/driver/src/api/c_linker.py | 6 +-- testsuite/driver/src/api/maple.py | 20 +++++---- testsuite/driver/src/mode/ASTO2.py | 2 +- testsuite/driver/src/mode/CO0.py | 4 +- testsuite/driver/src/mode/CO2.py | 4 +- testsuite/driver/src/mode/GC_O0.py | 2 +- testsuite/driver/src/mode/GC_O2.py | 2 +- testsuite/driver/src/mode/MPLIR.py | 42 +++++++++++++++++++ testsuite/driver/src/mode/O0.py | 2 +- testsuite/driver/src/mode/O2.py | 2 +- testsuite/driver/src/mode/SCO0_TEST.py | 6 +-- testsuite/driver/src/mode/SCO0_TRAIN.py | 6 +-- testsuite/driver/src/mode/SCO2_TEST.py | 6 +-- testsuite/driver/src/mode/SCO2_TRAIN.py | 6 +-- .../mplir_test/MPLIR0001-helloworld/driver.c | 8 ++++ .../MPLIR0001-helloworld/expected.txt | 1 + .../mplir_test/MPLIR0001-helloworld/hello.mpl | 8 ++++ .../mplir_test/MPLIR0001-helloworld/test.cfg | 2 + 20 files changed, 98 insertions(+), 33 deletions(-) create mode 100644 testsuite/driver/src/mode/MPLIR.py create mode 100644 testsuite/mplir_test/MPLIR0001-helloworld/driver.c create mode 100644 testsuite/mplir_test/MPLIR0001-helloworld/expected.txt create mode 100644 testsuite/mplir_test/MPLIR0001-helloworld/hello.mpl create mode 100644 testsuite/mplir_test/MPLIR0001-helloworld/test.cfg diff --git a/testsuite/driver/config/ci_testall.conf b/testsuite/driver/config/ci_testall.conf index 1035305802..a963f69dec 100755 --- a/testsuite/driver/config/ci_testall.conf +++ b/testsuite/driver/config/ci_testall.conf @@ -26,6 +26,7 @@ java_test/unsafe_test: java_common_mode_set java_test/gconly_test: GC_O0, GC_O2 irbuild_test: IR + mplir_test: MPLIR [BAN_TEST_SUITE] java_test/compact_test/RT0194-rt-compact-AnnotationStaticFieldSetTest: GC_O0, GC_O2 diff --git a/testsuite/driver/config/testall.conf b/testsuite/driver/config/testall.conf index 73a2ddd060..d66cecaa53 100644 --- a/testsuite/driver/config/testall.conf +++ b/testsuite/driver/config/testall.conf @@ -20,6 +20,7 @@ java_test/thread_test: java_common_mode_set java_test/unsafe_test: java_common_mode_set irbuild_test: IR + mplir_test: MPLIR c_test/sanity_test: c_common_mode_set c_test/driver_test: c_driver_mode_set diff --git a/testsuite/driver/src/api/c_linker.py b/testsuite/driver/src/api/c_linker.py index 039b8da449..ca29b1e72e 100644 --- a/testsuite/driver/src/api/c_linker.py +++ b/testsuite/driver/src/api/c_linker.py @@ -17,14 +17,14 @@ from api.shell_operator import ShellOperator class CLinker(ShellOperator): - def __init__(self, infile, front_option, outfile, back_option, mid_opt="",return_value_list=None, redirection=None): + def __init__(self, infiles, front_option, outfile, back_option, mid_opt="",return_value_list=None, redirection=None): super().__init__(return_value_list, redirection) - self.infile = infile + self.infiles = infiles self.front_option = front_option self.outfile = outfile self.back_option = back_option self.mid_opt = mid_opt def get_command(self, variables): - self.command = "${OUT_ROOT}/tools/bin/aarch64-linux-gnu-gcc " + self.front_option + " -o " + self.outfile + " " + self.mid_opt + " " + self.infile + " " + self.back_option + self.command = "${OUT_ROOT}/tools/bin/aarch64-linux-gnu-gcc " + self.front_option + " -o " + self.outfile + " " + self.mid_opt + " " + " ".join(self.infiles) + " " + self.back_option return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/maple.py b/testsuite/driver/src/api/maple.py index 6417addd2d..2bff3d44f8 100644 --- a/testsuite/driver/src/api/maple.py +++ b/testsuite/driver/src/api/maple.py @@ -17,20 +17,22 @@ from api.shell_operator import ShellOperator class Maple(ShellOperator): - def __init__(self, maple, run, option, global_option, infile, return_value_list=None, redirection=None): + def __init__(self, maple, run, option, global_option, infiles, return_value_list=None, redirection=None): super().__init__(return_value_list, redirection) self.maple = maple self.run = run self.option_dict = option self.global_option = global_option - self.infile = infile + self.infiles = infiles def get_command(self, variables): - self.command = self.maple + " --run=" + ":".join(self.run) + " " - option = [] - for cmd in self.run: - option.append(self.option_dict[cmd]) - self.command += "--option=\"" + ":".join(option) + "\" " - self.command += self.global_option + " " - self.command += "--infile " + self.infile + self.command = self.maple + " " + self.command += "--infile " + " ".join(self.infiles) + if self.run: + self.command += " --run=" + ":".join(self.run) + " " + option = [] + for cmd in self.run: + option.append(self.option_dict[cmd]) + self.command += "--option=\"" + ":".join(option) + "\" " + self.command += self.global_option + " " return super().get_final_command(variables) diff --git a/testsuite/driver/src/mode/ASTO2.py b/testsuite/driver/src/mode/ASTO2.py index 094e8b4871..d0918270c3 100644 --- a/testsuite/driver/src/mode/ASTO2.py +++ b/testsuite/driver/src/mode/ASTO2.py @@ -40,7 +40,7 @@ ASTO2 = { "mplcg": "-O2 --fpic --quiet" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), GenBin( infile="${APP}.s", diff --git a/testsuite/driver/src/mode/CO0.py b/testsuite/driver/src/mode/CO0.py index faa45a1f5a..51e139388e 100644 --- a/testsuite/driver/src/mode/CO0.py +++ b/testsuite/driver/src/mode/CO0.py @@ -40,10 +40,10 @@ CO0 = { "mplcg": "--quiet" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="", outfile="${APP}.out", back_option="-lm" diff --git a/testsuite/driver/src/mode/CO2.py b/testsuite/driver/src/mode/CO2.py index d90abd9ad8..929ee74e15 100644 --- a/testsuite/driver/src/mode/CO2.py +++ b/testsuite/driver/src/mode/CO2.py @@ -42,10 +42,10 @@ CO2 = { "mplcg": "-O2 --fpic --quiet" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="", outfile="${APP}.out", back_option="-lm" diff --git a/testsuite/driver/src/mode/GC_O0.py b/testsuite/driver/src/mode/GC_O0.py index e4c3ee6a8c..062b6212dd 100644 --- a/testsuite/driver/src/mode/GC_O0.py +++ b/testsuite/driver/src/mode/GC_O0.py @@ -39,7 +39,7 @@ GC_O0 = { "mplcg": "--O2 --quiet --no-pie --fpic --verbose-asm --maplelinker --gconly" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), Linker( lib="host-x86_64-GC_O0", diff --git a/testsuite/driver/src/mode/GC_O2.py b/testsuite/driver/src/mode/GC_O2.py index a5d01f05d0..6d8453025b 100644 --- a/testsuite/driver/src/mode/GC_O2.py +++ b/testsuite/driver/src/mode/GC_O2.py @@ -39,7 +39,7 @@ GC_O2 = { "mplcg": "--O2 --quiet --no-pie --fpic --verbose-asm --maplelinker --gconly" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), Linker( lib="host-x86_64-GC_O2", diff --git a/testsuite/driver/src/mode/MPLIR.py b/testsuite/driver/src/mode/MPLIR.py new file mode 100644 index 0000000000..bd3d429b71 --- /dev/null +++ b/testsuite/driver/src/mode/MPLIR.py @@ -0,0 +1,42 @@ +# +# Copyright (c) [2022] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api import * + +MPLIR = { + "compile" : [ + Maple( + maple="${OUT_ROOT}/${MAPLE_BUILD_TYPE}/bin/maple", + run=[], + option={}, + global_option="", + infiles=["${DRIVER}.c", "${APP}.mpl" ] + ), + CLinker( + infiles=["${DRIVER}.s" "${APP}.s"], + front_option="", + outfile="${APP}.out", + back_option="-lm" + ) + ], + "run": [ + Shell( + "${OUT_ROOT}/tools/bin/qemu-aarch64 -L ${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc ${APP}.out > output.log 2>&1" + ), + CheckFileEqual( + file1="output.log", + file2="expected.txt" + ) + ] +} diff --git a/testsuite/driver/src/mode/O0.py b/testsuite/driver/src/mode/O0.py index 220b48c05d..1c6b642e81 100644 --- a/testsuite/driver/src/mode/O0.py +++ b/testsuite/driver/src/mode/O0.py @@ -39,7 +39,7 @@ O0 = { "mplcg": "--quiet --no-pie --fpic --verbose-asm --maplelinker" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), Linker( lib="host-x86_64-O0", diff --git a/testsuite/driver/src/mode/O2.py b/testsuite/driver/src/mode/O2.py index 9cad688be4..c5526ec2e6 100644 --- a/testsuite/driver/src/mode/O2.py +++ b/testsuite/driver/src/mode/O2.py @@ -39,7 +39,7 @@ O2 = { "mplcg": "--O2 --quiet --no-pie --fpic --verbose-asm --maplelinker" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), Linker( lib="host-x86_64-O2", diff --git a/testsuite/driver/src/mode/SCO0_TEST.py b/testsuite/driver/src/mode/SCO0_TEST.py index 65cd3a4d5c..f1305c1b7c 100644 --- a/testsuite/driver/src/mode/SCO0_TEST.py +++ b/testsuite/driver/src/mode/SCO0_TEST.py @@ -41,10 +41,10 @@ SCO0_TEST = { "mplcg": "--O0 --patch-long-branch --quiet --no-pie --fpic --verbose-asm" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="-O2 -std=c99", outfile="${APP}.o", back_option="", @@ -53,7 +53,7 @@ SCO0_TEST = { ], "link": [ CLinker( - infile="${APP}", + infiles=["${APP}"], front_option="-std=gnu99 -no-pie", outfile="${EXE}", back_option="-lm -L${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib/", diff --git a/testsuite/driver/src/mode/SCO0_TRAIN.py b/testsuite/driver/src/mode/SCO0_TRAIN.py index d1fb051bc8..fa72d00f45 100644 --- a/testsuite/driver/src/mode/SCO0_TRAIN.py +++ b/testsuite/driver/src/mode/SCO0_TRAIN.py @@ -41,10 +41,10 @@ SCO0_TRAIN = { "mplcg": "--O0 --patch-long-branch --quiet --no-pie --fpic --verbose-asm" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="-O2 -std=c99", outfile="${APP}.o", back_option="", @@ -53,7 +53,7 @@ SCO0_TRAIN = { ], "link": [ CLinker( - infile="${APP}", + infiles=["${APP}"], front_option="-std=gnu99 -no-pie", outfile="${EXE}", back_option="-lm -L${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib/" diff --git a/testsuite/driver/src/mode/SCO2_TEST.py b/testsuite/driver/src/mode/SCO2_TEST.py index eabf287dbb..17229e794f 100644 --- a/testsuite/driver/src/mode/SCO2_TEST.py +++ b/testsuite/driver/src/mode/SCO2_TEST.py @@ -43,10 +43,10 @@ SCO2_TEST = { "mplcg": "--O2 --fpic --quiet --no-pie --verbose-asm" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="-O2 -std=c99", outfile="${APP}.o", back_option="", @@ -55,7 +55,7 @@ SCO2_TEST = { ], "link": [ CLinker( - infile="${APP}", + infiles=["${APP}"], front_option="-std=gnu99 -no-pie", outfile="${EXE}", back_option="-lm -L${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib/" diff --git a/testsuite/driver/src/mode/SCO2_TRAIN.py b/testsuite/driver/src/mode/SCO2_TRAIN.py index 5bc1519f34..5776bbbc35 100644 --- a/testsuite/driver/src/mode/SCO2_TRAIN.py +++ b/testsuite/driver/src/mode/SCO2_TRAIN.py @@ -43,10 +43,10 @@ SCO2_TRAIN = { "mplcg": "--O2 --fpic --quiet --no-pie --verbose-asm" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="-O2 -std=c99", outfile="${APP}.o", back_option="", @@ -55,7 +55,7 @@ SCO2_TRAIN = { ], "link": [ CLinker( - infile="${APP}", + infiles=["${APP}"], front_option="-std=gnu99 -no-pie", outfile="${EXE}", back_option="-lm -L${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib/" diff --git a/testsuite/mplir_test/MPLIR0001-helloworld/driver.c b/testsuite/mplir_test/MPLIR0001-helloworld/driver.c new file mode 100644 index 0000000000..373e18700b --- /dev/null +++ b/testsuite/mplir_test/MPLIR0001-helloworld/driver.c @@ -0,0 +1,8 @@ +#include + +extern void print_hello(); + +int main() { + print_hello(); + return 0; +} diff --git a/testsuite/mplir_test/MPLIR0001-helloworld/expected.txt b/testsuite/mplir_test/MPLIR0001-helloworld/expected.txt new file mode 100644 index 0000000000..af5626b4a1 --- /dev/null +++ b/testsuite/mplir_test/MPLIR0001-helloworld/expected.txt @@ -0,0 +1 @@ +Hello, world! diff --git a/testsuite/mplir_test/MPLIR0001-helloworld/hello.mpl b/testsuite/mplir_test/MPLIR0001-helloworld/hello.mpl new file mode 100644 index 0000000000..cbcd4b10fb --- /dev/null +++ b/testsuite/mplir_test/MPLIR0001-helloworld/hello.mpl @@ -0,0 +1,8 @@ +srclang 1 +func &printf public used varargs extern (var %format <* i8>, ...) i32 + +func &print_hello public () void { + var %ret i32 + callassigned &printf (conststr ptr "Hello, world!\x0a") { dassign %ret 0 } + return () +} diff --git a/testsuite/mplir_test/MPLIR0001-helloworld/test.cfg b/testsuite/mplir_test/MPLIR0001-helloworld/test.cfg new file mode 100644 index 0000000000..b8ca0dc52e --- /dev/null +++ b/testsuite/mplir_test/MPLIR0001-helloworld/test.cfg @@ -0,0 +1,2 @@ +compile(DRIVER=driver, hello) +run(hello) -- Gitee