summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-10-20 16:07:58 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2023-10-20 16:07:58 +0200
commit060a0cf338d6024eee37cc344c224fe3bcb78e81 (patch)
tree3fea7c654b69ecf3490fe9c6cbc542aba0d5bd8f /test
downloadbootstrappable-toolchain-060a0cf338d6024eee37cc344c224fe3bcb78e81.tar.gz
Initial commit
Diffstat (limited to 'test')
-rw-r--r--test/TARGETS260
-rw-r--r--test/main.c6
-rw-r--r--test/main.cpp6
-rw-r--r--test/test.sh5
4 files changed, 277 insertions, 0 deletions
diff --git a/test/TARGETS b/test/TARGETS
new file mode 100644
index 0000000..d9da126
--- /dev/null
+++ b/test/TARGETS
@@ -0,0 +1,260 @@
+{ "helloworld-c":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "pure C": ["yes"]
+ , "name": ["helloworld"]
+ , "srcs": ["main.c"]
+ , "private-cflags": ["-Wno-unused-command-line-argument"]
+ }
+, "helloworld-cpp":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["helloworld"]
+ , "srcs": ["main.cpp"]
+ , "private-cflags": ["-Wno-unused-command-line-argument"]
+ }
+, "installed helloworld-c":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["helloworld-c"]
+ }
+, "installed helloworld-cpp":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["helloworld-cpp"]
+ }
+, "test-c":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "arguments_config": ["TEST_NAME_SUFFIX"]
+ , "name":
+ { "type": "++"
+ , "$1": [["test-c"], {"type": "var", "name": "TEST_NAME_SUFFIX"}]
+ }
+ , "test": ["test.sh"]
+ , "deps": ["installed helloworld-c"]
+ }
+, "test-cpp":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "arguments_config": ["TEST_NAME_SUFFIX"]
+ , "name":
+ { "type": "++"
+ , "$1": [["test-cpp"], {"type": "var", "name": "TEST_NAME_SUFFIX"}]
+ }
+ , "test": ["test.sh"]
+ , "deps": ["installed helloworld-cpp"]
+ }
+, "config":
+ { "type": "configure"
+ , "arguments_config":
+ [ "CONFIG_TARGET"
+ , "ARCH"
+ , "TOOLCHAIN_CONFIG"
+ , "STATIC_FULL"
+ , "STATIC_RUNLIBS"
+ , "USE_LIBCXX"
+ , "ENV"
+ ]
+ , "tainted": ["test"]
+ , "target": {"type": "var", "name": "CONFIG_TARGET"}
+ , "config":
+ { "type": "let*"
+ , "bindings":
+ [ ["ARCH", {"type": "var", "name": "ARCH", "default": "x86_64"}]
+ , [ "STATIC_RUNLIBS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "STATIC_FULL"}
+ , "then": true
+ , "else": {"type": "var", "name": "STATIC_RUNLIBS"}
+ }
+ ]
+ , [ "TOOLCHAIN_CONFIG"
+ , { "type": "map_union"
+ , "$1":
+ [ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , {"type": "env", "vars": ["STATIC_RUNLIBS", "USE_LIBCXX"]}
+ ]
+ }
+ ]
+ , [ "ADD_LDFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "STATIC_FULL"}
+ , "then": ["-static", "-s"]
+ }
+ ]
+ , [ "TEST_NAME_SUFFIX"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "STATIC_FULL"}
+ , "then": ["_static"]
+ , "else":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "STATIC_RUNLIBS"}
+ , "then": ["_mixed"]
+ , "else": ["_shared"]
+ }
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "USE_LIBCXX"}
+ , "then": ["-llvmlibs"]
+ , "else": ["-gnulibs"]
+ }
+ ]
+ }
+ ]
+ , ["TEST_ENV", {"type": "var", "name": "ENV"}]
+ ]
+ , "body":
+ { "type": "env"
+ , "vars":
+ [ "ARCH"
+ , "TOOLCHAIN_CONFIG"
+ , "ADD_LDFLAGS"
+ , "TEST_NAME_SUFFIX"
+ , "TEST_ENV"
+ ]
+ }
+ }
+ }
+, "test-c_shared-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": false
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-c"
+ }
+ , "target": "config"
+ }
+, "test-cpp_shared-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": false
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-cpp_shared-llvmlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": false
+ , "USE_LIBCXX": true
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-c_mixed-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-c"
+ }
+ , "target": "config"
+ }
+, "test-cpp_mixed-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-cpp_mixed-llvmlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": true
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-c_static-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": true
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-c"
+ }
+ , "target": "config"
+ }
+, "test-cpp_static-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": true
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-cpp_static-llvmlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": true
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": true
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "ALL":
+ { "type": "install"
+ , "arguments_config": ["SKIP_STATIC", "SKIP_SHARED", "HAVE_LIBCXX"]
+ , "tainted": ["test"]
+ , "deps":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "SKIP_SHARED"}
+ , "then": []
+ , "else":
+ [ "test-c_shared-gnulibs"
+ , "test-cpp_shared-gnulibs"
+ , "test-c_mixed-gnulibs"
+ , "test-cpp_mixed-gnulibs"
+ ]
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "SKIP_STATIC"}
+ , "then": []
+ , "else": ["test-c_static-gnulibs", "test-cpp_static-gnulibs"]
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "HAVE_LIBCXX"}
+ , "then":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "SKIP_SHARED"}
+ , "then": []
+ , "else": ["test-cpp_shared-llvmlibs", "test-cpp_mixed-llvmlibs"]
+ }
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "HAVE_LIBCXX"}
+ , "then":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "SKIP_STATIC"}
+ , "then": []
+ , "else": ["test-cpp_static-llvmlibs"]
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/test/main.c b/test/main.c
new file mode 100644
index 0000000..e4074b7
--- /dev/null
+++ b/test/main.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, const char *argv[]) {
+ printf("Hello world!\n");
+ return 0;
+}
diff --git a/test/main.cpp b/test/main.cpp
new file mode 100644
index 0000000..88484d6
--- /dev/null
+++ b/test/main.cpp
@@ -0,0 +1,6 @@
+#include <iostream>
+
+int main(int argc, const char *argv[]) {
+ std::cout << "Hello world!\n";
+ return 0;
+}
diff --git a/test/test.sh b/test/test.sh
new file mode 100644
index 0000000..1039343
--- /dev/null
+++ b/test/test.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+[ "$(./bin/helloworld)" = "Hello world!" ]