diff --git a/test/README.md b/test/README.md index a8f340680938a17f2794ee373f0a4e5540efbad8..428b09abe178f3f62bf8e74ced16e0839d356c1d 100644 --- a/test/README.md +++ b/test/README.md @@ -34,6 +34,7 @@ test # 指定测试套路径,以‘:’划分 dir = ../testsuite/irbuild_test: + ../testsuite/ouroboros: [running] #指定运行时的临时路径 @@ -49,18 +50,6 @@ level = INFO 依赖环境变量:MAPLE_ROOT -### 运行单个irbuild用例 - -```shell -python3 main.py -pFAIL -pPASS --timeout=180 --test_cfg=testsuite/irbuild_test/test.cfg testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32 -``` - -### 运行文件夹内的所有用例 - -```shell -python3 main.py -pFAIL -pPASS --timeout=180 --test_cfg=testsuite/irbuild_test/test.cfg testsuite/irbuild_test -``` - ### 运行已配置的所有测试套 ```shell @@ -136,6 +125,221 @@ Log arguments: 当前测试框架仅支持编码格式为 `UTF-8`,测试用例和配置文件仅支持 `UTF-8` 编码格式,如果测试用例编码非 `UTF-8` 测试用例会被认定为 `UNRESOLVED` +## ouroboros 测试套 + +ouroboros测试套是基于 `Java` 测试用例的测试套 + +### 运行测试套 + +批量运行ouroboros:参数 `-j20` 设定并行为20 + +`python3 test/main.py test/testsuite/ouroboros/ -j20` + +运行ourobors下的子文件夹: + +`python3 test/main.py test/testsuite/ouroboros/string_test -j20` + +运行ourobors下的单一测试用例: + +`python3 test/main.py test/testsuite/ouroboros/string_test` + +只输出失败用例: + +`python3 test/main.py test/testsuite/ouroboros/ -j20 -pFAIL` + +屏幕输出详细运行日至: + +`python3 test/main.py test/testsuite/ouroboros/string_test -j20` + +### 测试套配置 + +测试套配置文件路径为 `testsuite/ourobors/test.cfg`, 含有测试套的一些设置和内部变量 + +```ini +[suffix] +java = // + +[internal-var] +maple = python3 ${MAPLE_ROOT}/test/testsuite/maple.py +run = # +build_option = --javac="-bootclasspath ${MAPLE_ROOT}/libjava-core/java-core.jar" --maple="-O0 --mplt=${MAPLE_ROOT}/libjava-core/java-core.mplt --option=\"-use-string-factory::: \"" -s maple +run_option = + +[description] +title = Maple Ouroboros Test +``` + +**`[suffix]`**:限定搜索测试用例文件的后缀,以及测试用例中注释符,注释符后会跟随执行语句或者校验语句,当前测试套中的用例为 `java` 文件,`\\` 作为注释符 + +**`[internal-val]`**:内部变量,此处的内部变量会替换用例中相应的变量。例如配置文件中的 `maple = python3 ${MAPLE_ROOT}/test/testsuite/maple.py` ,将会将用例中跟随在 `\\ EXEC:## ouroboros 测试套 + +ouroboros测试套是基于 `Java` 测试用例的测试套 + +### 运行测试套 + +批量运行ouroboros:参数 `-j20` 设定并行为20 + +`python3 test/main.py test/testsuite/ouroboros/ -j20` + +运行ourobors下的子文件夹: + +`python3 test/main.py test/testsuite/ouroboros/string_test -j20` + +运行ourobors下的单一测试用例: + +`python3 test/main.py test/testsuite/ouroboros/string_test` + +只输出失败用例: + +`python3 test/main.py test/testsuite/ouroboros/ -j20 -pFAIL` + +屏幕输出详细运行日至: + +`python3 test/main.py test/testsuite/ouroboros/string_test -j20` + +### 测试套配置 + +测试套配置文件路径为 `testsuite/ourobors/test.cfg`, 含有测试套的一些设置和内部变量 + +```ini +[suffix] +java = // + +[internal-var] +maple = python3 ${MAPLE_ROOT}/test/testsuite/maple.py +run = # +build_option = --javac="-bootclasspath ${MAPLE_ROOT}/libjava-core/java-core.jar" --maple="-O0 --mplt=${MAPLE_ROOT}/libjava-core/java-core.mplt --option=\"-use-string-factory::: \"" -s maple +run_option = + +[description] +title = Maple Ouroboros Test +``` + +**`[suffix]`**:限定搜索测试用例文件的后缀,以及测试用例中注释符,注释符后会跟随执行语句或者校验语句,当前测试套中的用例为 `java` 文件,`\\` 作为注释符 + +**`[internal-val]`**:内部变量,此处的内部变量会替换用例中相应的变量。例如配置文件中的 `maple = python3 ${MAPLE_ROOT}/test/testsuite/maple.py` ,将会将用例中跟随在 `\\ EXEC: ` 之后的执行语句中的 `%maple` 替换为 `python3 ${MAPLE_ROOT}/test/testsuite/maple.py`。当前的用例只能编译无法运行所以在内部变量 `run` 出用 `shell` 注释符 `#` 代表,注释运行的语句。 + +**`[description]`**:测试套的描述信息 + +### 测试套列表 + +默认测试列表路径为 `testsuite/ourobors/testlist`,测试列表规定了运行测试用例的范围,同时指定了排除的测试用例 + +```list +[ALL-TEST-CASE] + arrayboundary_test + clinit_test + eh_test + fuzzapi_test + other_test + parent_test + reflection_test + stmtpre_test + string_test + subsumeRC_test + thread_test + unsafe_test + memory_management + +[EXCLUDE-TEST-CASE] + memory_management/Annotation +``` + +由两个部分组成:`[ALL-TEST-CASE]` 与 `[EXCLUDE-TEST-CASE]` + +`[ALL-TEST-CASE]`: 指定了运行测试用例的范围 + +`[EXCLUDE-TEST-CASE]`: 不运行的测试用例 + +当前测试用例排除了测试套 `testsuite/ourobors` 下子文件夹 `memory_management/Annotation` 中所有的用例文件 + ` 之后的执行语句中的 `%maple` 替换为 `python3 ${MAPLE_ROOT}/test/testsuite/maple.py`。当前的用例只能编译无法运行所以在内部变量 `run` 出用 `shell` 注释符 `#` 代表,注释运行的语句。 + +**`[description]`**:测试套的描述信息 + +### 测试套列表 + +默认测试列表路径为 `testsuite/ourobors/testlist`,测试列表规定了运行测试用例的范围,同时指定了排除的测试用例 + +```list +[ALL-TEST-CASE] + arrayboundary_test + clinit_test + eh_test + fuzzapi_test + other_test + parent_test + reflection_test + stmtpre_test + string_test + subsumeRC_test + thread_test + unsafe_test + memory_management + +[EXCLUDE-TEST-CASE] + memory_management/Annotation +``` + +由两个部分组成:`[ALL-TEST-CASE]` 与 `[EXCLUDE-TEST-CASE]` + +`[ALL-TEST-CASE]`: 指定了运行测试用例的范围 + +`[EXCLUDE-TEST-CASE]`: 不运行的测试用例 + +当前测试用例排除了测试套 `testsuite/ourobors` 下子文件夹 `memory_management/Annotation` 中所有的用例文件 + +#### 完整Main.mpl + +``` + func &addf32r( + var %i f32, var %j f32 + ) f32 { + return ( + add f32(dread f32 %i, dread f32 %j))} + + func &addf32I ( + var %i f32 + ) f32 { + return ( + add f32(dread f32 %i, + constval f32 1.234f))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl +``` + +#### 1. 测试案例部分 + +``` + func &addf32r( + var %i f32, var %j f32 + ) f32 { + return ( + add f32(dread f32 %i, dread f32 %j))} + + func &addf32I ( + var %i f32 + ) f32 { + return ( + add f32(dread f32 %i, + constval f32 1.234f))} +``` + +#### 2. 测试案例运行部分 + +``` + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl +``` + +三条执行语句: + +1. EXEC语句,利用%irbuild,编译Main.mpl为Main.irb.mpl +2. EXEC语句,利用%irbuild,编译Main.irb.mpl为Main.irb.irb.mpl +3. EXEC语句,利用%cmp,比较Main.irb.irb.mpl与Main.irb.mpl是否一致,一致测试通过 + + ## irbuild测试套配置说明 irbuild测试套配置:testsuite/irbuild_test/test.cfg @@ -175,7 +379,19 @@ cmp = /usr/bin/cmp -s * 所有测试用例中的EXEC语句内的"%irbuild"会被替换为"${MAPLE_ROOT}/output/bin/irbuild" * 所有测试用例中的EXEC语句内的"%cmp"会被替换为"/usr/bin/cmp -s" -#### irbuild测试套文件结构 +### 运行单个irbuild用例 + +```shell +python3 main.py -pFAIL -pPASS --timeout=180 --test_cfg=testsuite/irbuild_test/test.cfg testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32 +``` + +### 运行文件夹内的所有用例 + +```shell +python3 main.py -pFAIL -pPASS --timeout=180 --test_cfg=testsuite/irbuild_test/test.cfg testsuite/irbuild_test +``` + +### irbuild测试套文件结构 ```shell testsuite/irbuild 测试套路径 @@ -185,9 +401,9 @@ cmp = /usr/bin/cmp -s └── ... ``` -## 测试用例说明 +### `irbuild_test` 测试用例说明 -### 完整Main.mpl +#### 完整Main.mpl ``` func &addf32r( diff --git a/test/maple_test/configs.py b/test/maple_test/configs.py index 110486d72fb8c5c207e2f620085e637ab61eec99..3cce3d61e00da025788dc16982e9c1d670735ffa 100644 --- a/test/maple_test/configs.py +++ b/test/maple_test/configs.py @@ -88,7 +88,7 @@ def parse_args(): "normal: one line progress bar, update per second," "no_flush_progress: print test progress per 10 seconds", ) - + test_suite_parser = parser.add_argument_group("Test Suite arguments") test_suite_parser.add_argument( "test_paths", nargs="*", type=complete_path, help="Test suite path", diff --git a/test/maple_test/main.py b/test/maple_test/main.py index c610f93663cff8a9c87030be4938c0ae90db5910..696abbb7c5a99d42efd2db8772a20c54acf48f21 100644 --- a/test/maple_test/main.py +++ b/test/maple_test/main.py @@ -33,13 +33,14 @@ def main(): logger = configs.LOGGER test_paths = test_suite_config.get("test_paths") - test_cfg = test_suite_config.get("test_cfg") + cli_test_cfg = test_suite_config.get("test_cfg") cli_running_config = test_suite_config.get("cli_running_config") retry = configs.get_val("retry") result = "" failed = False for test in test_paths: + test_cfg = cli_test_cfg test_result = None test_failed = False if test.exists(): diff --git a/test/maple_test/maple_test.cfg b/test/maple_test/maple_test.cfg index e2c0cab928fd7bef9fa6ae4cbb2fbfbd64e557a5..06848399cf9c110368364e266c7120ebb107f6f6 100644 --- a/test/maple_test/maple_test.cfg +++ b/test/maple_test/maple_test.cfg @@ -3,6 +3,7 @@ # 指定测试套路径,以‘:’划分 dir = ../testsuite/irbuild_test: + ../testsuite/ouroboros: [running] #指定运行时的临时路径 diff --git a/test/maple_test/test.py b/test/maple_test/test.py index 924920fa27154fc729c67b79904d23fa4f284da7..570dc585d4aa9d0e8fb271ee51b5f1af0027caac 100644 --- a/test/maple_test/test.py +++ b/test/maple_test/test.py @@ -35,9 +35,7 @@ class Case: self.relative_path = path self.comment = comment try: - _, comment_lines = split_comment( - comment, read_file(self.path), - ) + _, comment_lines = split_comment(comment, read_file(self.path),) except UnicodeDecodeError as e: print(e) self.commands = []