diff options
Diffstat (limited to 'CC/test')
-rw-r--r-- | CC/test/EXPRESSIONS | 410 | ||||
-rw-r--r-- | CC/test/RULES | 287 | ||||
-rw-r--r-- | CC/test/TARGETS | 1 | ||||
-rwxr-xr-x | CC/test/runner | 71 |
4 files changed, 0 insertions, 769 deletions
diff --git a/CC/test/EXPRESSIONS b/CC/test/EXPRESSIONS deleted file mode 100644 index 1389bbc..0000000 --- a/CC/test/EXPRESSIONS +++ /dev/null @@ -1,410 +0,0 @@ -{ "run_test": - { "doc": - [ "Build and run a CC test binary using the provided runner." - , "" - , "Note that if variable RUNS_PER_TEST contains a non-false value, a" - , "summarizer must be provided." - ] - , "vars": - [ "ARCH" - , "HOST_ARCH" - , "TARGET_ARCH" - , "ARCH_DISPATCH" - , "TEST_SUMMARY_EXECUTION_PROPERTIES" - , "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "ENV" - , "TEST_ENV" - , "TIMEOUT_SCALE" - , "CC_TEST_LAUNCHER" - , "RUNS_PER_TEST" - , "name" - , "pure C" - , "stage" - , "srcs" - , "private-hdrs" - , "private-defines" - , "private-cflags" - , "private-ldflags" - , "defaults-transition" - , "deps-transition" - , "deps-fieldnames" - , "runner" - , "runner-data" - , "test-args" - , "test-data" - , "summarizer" - , "summary artifacts" - , "LINT" - ] - , "imports": - { "artifacts": ["./", "../..", "field_artifacts"] - , "runfiles": ["./", "../..", "field_runfiles"] - , "compile-deps": ["./", "..", "compile-deps"] - , "compile-args-deps": ["./", "..", "compile-args-deps"] - , "link-deps": ["./", "..", "link-deps"] - , "link-args-deps": ["./", "..", "link-args-deps"] - , "run-libs-deps": ["./", "..", "run-libs-deps"] - , "run-libs-args-deps": ["./", "..", "run-libs-args-deps"] - , "cflags-files-deps": ["./", "..", "cflags-files-deps"] - , "ldflags-files-deps": ["./", "..", "ldflags-files-deps"] - , "binary": ["./", "..", "bin artifact"] - , "host transition": ["transitions", "for host"] - , "target properties": ["transitions", "target properties"] - , "stage": ["./", "../..", "stage_singleton_field"] - , "list_provider": ["./", "../..", "field_list_provider"] - , "lint": ["./", "..", "lint information"] - } - , "expression": - { "type": "let*" - , "bindings": - [ [ "cflags-files" - , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"} - ] - , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}] - , [ "compile-args" - , { "type": "++" - , "$1": - [ { "type": "foreach" - , "var": "def" - , "range": - {"type": "var", "name": "private-defines", "default": []} - , "body": - {"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]} - } - , {"type": "var", "name": "private-cflags", "default": []} - , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"} - ] - } - ] - , [ "ldflags-files" - , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"} - ] - , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}] - , [ "link-args" - , { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "link-args-deps"} - , {"type": "var", "name": "private-ldflags", "default": []} - ] - } - ] - , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}] - , [ "run-libs-args" - , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"} - ] - , ["binary", {"type": "CALL_EXPRESSION", "name": "binary"}] - , [ "lint" - , { "type": "if" - , "cond": {"type": "var", "name": "LINT"} - , "then": - { "type": "let*" - , "bindings": - [ ["hdrs", {"type": "empty_map"}] - , [ "lint-deps fieldnames" - , ["private-hdrs", "srcs", "private-deps"] - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "lint"} - } - } - ] - , [ "staged test binary" - , { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "range": {"type": "var", "name": "binary"} - , "var_val": "binary" - , "body": - { "type": "singleton_map" - , "key": "test" - , "value": {"type": "var", "name": "binary"} - } - } - } - ] - , [ "test-args" - , { "type": "singleton_map" - , "key": "test-args.json" - , "value": - { "type": "BLOB" - , "data": - { "type": "json_encode" - , "$1": {"type": "var", "name": "test-args", "default": []} - } - } - } - ] - , [ "test-launcher" - , { "type": "singleton_map" - , "key": "test-launcher.json" - , "value": - { "type": "BLOB" - , "data": - { "type": "json_encode" - , "$1": - {"type": "var", "name": "CC_TEST_LAUNCHER", "default": []} - } - } - } - ] - , [ "test-name" - , { "type": "join" - , "separator": "/" - , "$1": - [{"type": "var", "name": "stage"}, {"type": "var", "name": "name"}] - } - ] - , [ "test input" - , { "type": "map_union" - , "$1": - [ { "type": "to_subdir" - , "subdir": "work" - , "$1": {"type": "var", "name": "test-data"} - } - , {"type": "var", "name": "runner"} - , { "type": "var" - , "name": "runner-data" - , "default": {"type": "empty_map"} - } - , {"type": "var", "name": "test-args"} - , {"type": "var", "name": "test-launcher"} - , {"type": "var", "name": "staged test binary"} - , {"type": "var", "name": "run-libs"} - ] - } - ] - , [ "target properties" - , {"type": "CALL_EXPRESSION", "name": "target properties"} - ] - ] - , "body": - { "type": "if" - , "cond": {"type": "var", "name": "RUNS_PER_TEST"} - , "else": - { "type": "let*" - , "bindings": - [ [ "test-results" - , { "type": "ACTION" - , "outs": - [ "result" - , "stdout" - , "stderr" - , "time-start" - , "time-stop" - , "pwd" - ] - , "inputs": {"type": "var", "name": "test input"} - , "cmd": ["./runner"] - , "env": - { "type": "var" - , "name": "TEST_ENV" - , "default": {"type": "empty_map"} - } - , "may_fail": ["test"] - , "fail_message": - { "type": "join" - , "$1": - ["CC test ", {"type": "var", "name": "test-name"}, " failed"] - } - , "timeout scaling": - {"type": "var", "name": "TIMEOUT_SCALE", "default": 1.0} - , "execution properties": - {"type": "var", "name": "target properties"} - } - ] - , [ "runfiles" - , { "type": "singleton_map" - , "key": {"type": "var", "name": "name"} - , "value": - {"type": "TREE", "$1": {"type": "var", "name": "test-results"}} - } - ] - ] - , "body": - { "type": "RESULT" - , "artifacts": {"type": "var", "name": "test-results"} - , "runfiles": {"type": "var", "name": "runfiles"} - , "provides": {"type": "env", "vars": ["lint"]} - } - } - , "then": - { "type": "let*" - , "bindings": - [ [ "attempts (plain)" - , { "type": "map_union" - , "$1": - { "type": "foreach" - , "var": "ATTEMPT" - , "range": - { "type": "range" - , "$1": {"type": "var", "name": "RUNS_PER_TEST"} - } - , "body": - { "type": "singleton_map" - , "key": {"type": "var", "name": "ATTEMPT"} - , "value": - { "type": "ACTION" - , "outs": - ["result", "stdout", "stderr", "time-start", "time-stop"] - , "inputs": - { "type": "map_union" - , "$1": - [ { "type": "singleton_map" - , "key": "ATTEMPT" - , "value": - { "type": "BLOB" - , "data": {"type": "var", "name": "ATTEMPT"} - } - } - , {"type": "var", "name": "test input"} - ] - } - , "cmd": ["./runner"] - , "env": - { "type": "var" - , "name": "TEST_ENV" - , "default": {"type": "empty_map"} - } - , "may_fail": ["test"] - , "no_cache": ["test"] - , "fail_message": - { "type": "join" - , "$1": - [ "CC test " - , {"type": "var", "name": "test-name"} - , " failed (Run" - , {"type": "var", "name": "ATTEMPT"} - , ")" - ] - } - , "timeout scaling": - {"type": "var", "name": "TIMEOUT_SCALE", "default": 1.0} - , "execution properties": - {"type": "var", "name": "target properties"} - } - } - } - } - ] - , [ "attempts (for summary)" - , { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "range": {"type": "var", "name": "attempts (plain)"} - , "body": - { "type": "singleton_map" - , "key": {"type": "var", "name": "_"} - , "value": - { "type": "TREE" - , "$1": - { "type": "map_union" - , "$1": - { "type": "foreach" - , "range": {"type": "var", "name": "summary artifacts"} - , "body": - { "type": "singleton_map" - , "key": {"type": "var", "name": "_"} - , "value": - { "type": "lookup" - , "map": {"type": "var", "name": "$_"} - , "key": {"type": "var", "name": "_"} - } - } - } - } - } - } - } - } - ] - , [ "summary PATH" - , { "type": "join" - , "separator": ":" - , "$1": - { "type": "let*" - , "bindings": - [["fieldname", "shell-defaults"], ["provider", "PATH"]] - , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} - } - } - ] - , [ "summary" - , { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "var", "name": "attempts (for summary)"} - , {"type": "var", "name": "summarizer"} - ] - } - , "outs": - ["stdout", "stderr", "result", "time-start", "time-stop"] - , "cmd": ["./summarizer"] - , "execution properties": - { "type": "var" - , "name": "TEST_SUMMARY_EXECUTION_PROPERTIES" - , "default": {"type": "empty_map"} - } - , "env": - { "type": "if" - , "cond": {"type": "var", "name": "summary PATH"} - , "then": - { "type": "singleton_map" - , "key": "PATH" - , "value": {"type": "var", "name": "summary PATH"} - } - , "else": {"type": "empty_map"} - } - } - ] - , [ "attempts" - , { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "range": {"type": "var", "name": "attempts (plain)"} - , "body": - { "type": "singleton_map" - , "key": {"type": "var", "name": "_"} - , "value": - {"type": "TREE", "$1": {"type": "var", "name": "$_"}} - } - } - } - ] - , [ "artifacts" - , { "type": "`" - , "$1": - { "pwd": - {"type": ",", "$1": {"type": "BLOB", "data": "/summary"}} - , "work": - { "type": "," - , "$1": - {"type": "TREE", "$1": {"type": "var", "name": "attempts"}} - } - } - } - ] - , [ "runfiles" - , { "type": "singleton_map" - , "key": {"type": "var", "name": "name"} - , "value": - {"type": "TREE", "$1": {"type": "var", "name": "artifacts"}} - } - ] - ] - , "body": - { "type": "RESULT" - , "artifacts": {"type": "var", "name": "artifacts"} - , "runfiles": {"type": "var", "name": "runfiles"} - , "provides": {"type": "env", "vars": ["lint"]} - } - } - } - } - } -} diff --git a/CC/test/RULES b/CC/test/RULES deleted file mode 100644 index 3401974..0000000 --- a/CC/test/RULES +++ /dev/null @@ -1,287 +0,0 @@ -{ "test": - { "doc": ["A test written in C++"] - , "tainted": ["test"] - , "target_fields": ["srcs", "private-hdrs", "private-deps", "data"] - , "string_fields": - [ "name" - , "args" - , "stage" - , "pure C" - , "private-defines" - , "private-cflags" - , "private-ldflags" - ] - , "config_vars": - [ "ARCH" - , "HOST_ARCH" - , "TARGET_ARCH" - , "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "LDFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "ADD_LDFLAGS" - , "ENV" - , "BUILD_POSITION_INDEPENDENT" - , "TEST_ENV" - , "TIMEOUT_SCALE" - , "CC_TEST_LAUNCHER" - , "RUNS_PER_TEST" - , "ARCH_DISPATCH" - , "TEST_SUMMARY_EXECUTION_PROPERTIES" - , "LINT" - ] - , "implicit": - { "defaults": [["./", "..", "defaults"]] - , "shell-defaults": [["./", "../../shell", "defaults"]] - , "runner": ["runner"] - , "summarizer": [["./", "../../shell/test", "summarizer"]] - } - , "field_doc": - { "name": - [ "The name of the test" - , "" - , "Used to name the test binary as well as for staging the test result" - ] - , "args": ["Command line arguments for the test binary"] - , "srcs": - [ "The sources of the test binary" - , "" - , "The resulting test binary is run in an environment where it can assume" - , "that the environment variable TEST_TMPDIR points to a" - , "directory that may be used exclusively by this test." - , "For convenience, the environment variable TMPDIR is also set to TEST_TMPDIR." - , "" - , "This running of the test is carried out by the implicit dependency" - , "on the target \"runner\". By setting this target in the target layer" - , "of this rules repository (instead of letting it default to the" - , "respective file), the C/C++ test environment can be modified globally." - ] - , "private-hdrs": - [ "Any additional header files that need to be present when compiling" - , "the test binary." - ] - , "private-defines": - [ "List of defines set for source files local to this target." - , "Each list entry will be prepended by \"-D\"." - ] - , "private-cflags": - ["List of compile flags set for source files local to this target."] - , "private-ldflags": - [ "Additional linker flags for linking external libraries (not built" - , "by this tool, typically system libraries)." - ] - , "stage": - [ "The logical location of all header and source files." - , "Individual directory components are joined with \"/\"." - ] - , "data": ["Any files the test binary needs access to when running"] - , "defaults": ["The C/C++ toolchain to use"] - , "shell-defaults": - ["The shell toolchain to use PATH from for calling the summary action"] - , "runner": - [ "The test runner which starts the actual test binary after providing" - , "the respective environment. The runner also takes care of capturing" - , "stdout/stderr and timing information." - ] - , "summarizer": - [ "Tool to aggregate the results of individual test runs (for flakyness" - , "detection) to an overall test result. If more fields than the result" - , "itself is needed, those can be specified using the \"summarizer\" rule." - ] - } - , "config_doc": - { "CC": ["The name of the C compiler to be used."] - , "CXX": ["The name of the C++ compiler to be used."] - , "CFLAGS": - [ "The flags for CC to be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "CXXFLAGS": - [ "The flags for CXX to be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "LDFLAGS": - [ "The linker flags do be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_CFLAGS": - [ "The flags to add to the default ones for CC" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_CXXFLAGS": - [ "The flags to add to the default ones for CXX" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_LDFLAGS": - [ "The linker flags to add to the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ENV": ["The environment for any action generated."] - , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."] - , "TEST_ENV": ["The environment for executing the test runner."] - , "TIMEOUT_SCALE": - ["Factor on how to scale the timeout for this test. Defaults to 1.0."] - , "CC_TEST_LAUNCHER": - [ "List of strings representing the launcher that is prepend to the" - , "command line for running the test binary." - ] - , "RUNS_PER_TEST": - [ "The number of times the test should be run in order to detect flakyness." - , "If set, no test action will be taken from cache." - , "" - , "Test runs are summarized by the [\"shell/test\", \"summarizer\"] that" - , "is also used by shell tests." - ] - , "TARGET_ARCH": - [ "The architecture to build the test for." - , "" - , "Will only be honored, if that architecture is available in the" - , "ARCH_DISPATCH map. Otherwise, the test will be built for and run" - , "on the host architecture." - ] - , "ARCH_DISPATCH": - [ "Map of architectures to execution properties that ensure execution" - , "on that architecture. Only the actual test binary will be run with" - , "the specified execution properties (i.e., on the target architecture);" - , "all building will be done on the host architecture." - ] - , "TEST_SUMMARY_EXECUTION_PROPERTIES": - [ "Additional remote-execution properties for the test-summarizing action" - , "in case RUNS_PER_TEST is set; defaults to the empty map." - ] - , "LINT": - [ "Also provide nodes describing compile actions and header files;" - , "those can be used by lint rules (doing also the config transition)" - , "for additional checks." - ] - } - , "artifacts_doc": - [ "result: the result of this test (\"PASS\" or \"FAIL\"); useful for" - , " generating test reports." - , "stdout/stderr: Any output the invocation of the test binary produced on" - , " the respective file descriptor" - , "time-start/time-stop: The time (decimally coded) in seconds since the" - , " epoch when the test invocation started and ended." - , "pwd: the directory in which the test was carried out" - ] - , "runfiles_doc": - [ "A tree consisting of the artifacts staged at the name of the test." - , "As the built-in \"install\" rule only takes the runfiles of its" - , "\"private-deps\" argument, this gives an easy way of defining test" - , "suites." - ] - , "imports": - { "artifacts": ["./", "../..", "field_artifacts"] - , "runfiles": ["./", "../..", "field_runfiles"] - , "host transition": ["transitions", "maybe for host"] - , "stage": ["./", "../..", "stage_singleton_field"] - , "run_test": "run_test" - , "field_list": ["", "field_list_provider"] - } - , "config_transitions": - { "defaults": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - , "private-deps": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - , "private-hdrs": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - , "srcs": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - , "data": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - , "runner": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - } - , "expression": - { "type": "let*" - , "bindings": - [ [ "name" - , { "type": "assert_non_empty" - , "msg": "A non-empty name has to be provided for binaries" - , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}} - } - ] - , ["pure C", {"type": "FIELD", "name": "pure C"}] - , [ "stage" - , { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "stage"} - } - ] - , ["host-trans", {"type": "CALL_EXPRESSION", "name": "host transition"}] - , [ "srcs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": - [ ["fieldname", "srcs"] - , ["transition", {"type": "var", "name": "host-trans"}] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , [ "private-hdrs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": - [ ["fieldname", "private-hdrs"] - , ["transition", {"type": "var", "name": "host-trans"}] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , ["defaults-transition", {"type": "var", "name": "host-trans"}] - , ["deps-transition", {"type": "var", "name": "host-trans"}] - , ["deps-fieldnames", ["private-deps", "defaults"]] - , [ "runner" - , { "type": "let*" - , "bindings": - [ ["fieldname", "runner"] - , ["location", "runner"] - , ["transition", {"type": "var", "name": "host-trans"}] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "stage"} - } - ] - , ["test-args", {"type": "FIELD", "name": "args", "default": []}] - , [ "test-data" - , { "type": "let*" - , "bindings": - [ ["fieldname", "data"] - , ["transition", {"type": "var", "name": "deps-transition"}] - ] - , "body": - { "type": "map_union" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "runfiles"} - , {"type": "CALL_EXPRESSION", "name": "artifacts"} - ] - } - } - ] - , [ "summarizer" - , { "type": "let*" - , "bindings": - [["fieldname", "summarizer"], ["location", "summarizer"]] - , "body": {"type": "CALL_EXPRESSION", "name": "stage"} - } - ] - , [ "summary artifacts" - , { "type": "++" - , "$1": - [ ["result"] - , { "type": "let*" - , "bindings": - [["provider", "artifacts"], ["fieldname", "summarizer"]] - , "body": {"type": "CALL_EXPRESSION", "name": "field_list"} - } - ] - } - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "run_test"} - } - } -} diff --git a/CC/test/TARGETS b/CC/test/TARGETS deleted file mode 100644 index 0967ef4..0000000 --- a/CC/test/TARGETS +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/CC/test/runner b/CC/test/runner deleted file mode 100755 index 4984b17..0000000 --- a/CC/test/runner +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import os -import subprocess -import time - -time_start: float = time.time() -time_stop: float = 0 -result: str = "UNKNOWN" -stderr: str = "" -stdout: str = "" - - -def dump_results() -> None: - with open("result", "w") as f: - f.write("%s\n" % (result, )) - with open("time-start", "w") as f: - f.write("%d\n" % (time_start, )) - with open("time-stop", "w") as f: - f.write("%d\n" % (time_stop, )) - with open("stdout", "w") as f: - f.write("%s\n" % (stdout, )) - with open("stderr", "w") as f: - f.write("%s\n" % (stderr, )) - with open("pwd", "w") as f: - f.write("%s\n" % (os.getcwd(), )) - - -dump_results() - -TEMP_DIR = os.path.realpath("scratch") -os.makedirs(TEMP_DIR, exist_ok=True) - -WORK_DIR = os.path.realpath("work") -os.makedirs(WORK_DIR, exist_ok=True) - -ENV = dict(os.environ, TEST_TMPDIR=TEMP_DIR, TMPDIR=TEMP_DIR) - -with open('test-launcher.json') as f: - test_launcher = json.load(f) - -with open('test-args.json') as f: - test_args = json.load(f) - -ret = subprocess.run(test_launcher + ["../test"] + test_args, - cwd=WORK_DIR, - env=ENV, - capture_output=True) - -time_stop = time.time() -result = "PASS" if ret.returncode == 0 else "FAIL" -stdout = ret.stdout.decode("utf-8") -stderr = ret.stderr.decode("utf-8") - -dump_results() - -if result != "PASS": exit(1) |