diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-07-25 16:22:46 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-07-25 16:22:46 +0200 |
commit | 1825c775dafd591e2a9e6bf12065e8c41727b96f (patch) | |
tree | 2e6aa43ba606ad2b086e5d73590bb56db4ee4bc9 | |
parent | e85a871e579ef77b6b226249d199a50d8a91f08f (diff) | |
download | rules-cc-1825c775dafd591e2a9e6bf12065e8c41727b96f.tar.gz |
Add a test for the use of the "components" field of a library
-rw-r--r-- | tests/test_cases/deps/TARGETS | 51 | ||||
-rw-r--r-- | tests/test_cases/deps/components/TARGETS | 47 | ||||
-rw-r--r-- | tests/test_cases/deps/components/bar.cpp | 9 | ||||
-rw-r--r-- | tests/test_cases/deps/components/bar.hpp | 6 | ||||
-rw-r--r-- | tests/test_cases/deps/components/foo.cpp | 10 | ||||
-rw-r--r-- | tests/test_cases/deps/components/foo.hpp | 6 | ||||
-rw-r--r-- | tests/test_cases/deps/components/foodep.cpp | 9 | ||||
-rw-r--r-- | tests/test_cases/deps/components/foodep.hpp | 6 | ||||
-rw-r--r-- | tests/test_cases/deps/components/main.cpp | 10 |
9 files changed, 153 insertions, 1 deletions
diff --git a/tests/test_cases/deps/TARGETS b/tests/test_cases/deps/TARGETS index b1047a8..662eea2 100644 --- a/tests/test_cases/deps/TARGETS +++ b/tests/test_cases/deps/TARGETS @@ -278,10 +278,59 @@ ] , "data": [["TREE", null, "install"]] } +, "components": + { "type": ["test_rules", "test_case"] + , "name": ["deps_components"] + , "targets": + [ "+foo" + , "+bar" + , "+combined_static_lib" + , "+combined_shared_lib" + , "+main" + , "+main-dynamic" + ] + , "asserts": + [ "test -f foo/foo.hpp" + , "test -f foo/libfoo.a" + , "! test -e foo/libfoo.so" + , "test -f bar/bar.hpp" + , "test -f bar/libbar.a" + , "! test -e bar/libbar.so" + , "test -f combined_static_lib/libcombstatic.a" + , "test -f combined_static_lib/foo.hpp" + , "test -f combined_static_lib/bar.hpp" + , "! test -f combined_static_lib/libfoo.a" + , "! test -f combined_static_lib/libbar.a" + , "test -f combined_shared_lib/libcombshared.so" + , "test -f combined_shared_lib/foo.hpp" + , "test -f combined_shared_lib/bar.hpp" + , "! test -f combined_shared_lib/libfoo.a" + , "! test -f combined_shared_lib/libbar.a" + , "! test -f combined_shared_lib/libfoo.so" + , "! test -f combined_shared_lib/libbar.so" + , "./main/main" + , "./main/main | grep 'Hello-from-main'" + , "./main/main | grep 'bar.3'" + , "./main/main | grep 'foo.15'" + , "./main-dynamic/bin/main" + , "./main-dynamic/bin/main | grep 'Hello-from-main'" + , "./main-dynamic/bin/main | grep 'bar.3'" + , "./main-dynamic/bin/main | grep 'foo.15'" + ] + , "data": [["TREE", null, "components"]] + } , "ALL": { "type": "install" , "deps": - ["private", "public", "shared", "object", "prebuilt", "cmake", "install"] + [ "private" + , "public" + , "shared" + , "object" + , "prebuilt" + , "cmake" + , "install" + , "components" + ] , "tainted": ["test"] } } diff --git a/tests/test_cases/deps/components/TARGETS b/tests/test_cases/deps/components/TARGETS new file mode 100644 index 0000000..edd62db --- /dev/null +++ b/tests/test_cases/deps/components/TARGETS @@ -0,0 +1,47 @@ +{ "combined_static_lib": + { "type": ["@", "rules", "CC", "library"] + , "name": ["combstatic"] + , "components": ["foo", "bar"] + } +, "combined_shared_lib": + { "type": ["@", "rules", "CC", "library"] + , "name": ["combshared"] + , "shared": [""] + , "components": ["foo", "bar"] + } +, "foo": + { "type": ["@", "rules", "CC", "library"] + , "name": ["foo"] + , "hdrs": ["foo.hpp"] + , "srcs": ["foo.cpp"] + , "deps": ["foodep"] + } +, "foodep": + { "type": ["@", "rules", "CC", "library"] + , "name": ["foodep"] + , "hdrs": ["foodep.hpp"] + , "srcs": ["foodep.cpp"] + } +, "bar": + { "type": ["@", "rules", "CC", "library"] + , "name": ["bar"] + , "hdrs": ["bar.hpp"] + , "srcs": ["bar.cpp"] + } +, "main": + { "type": ["@", "rules", "CC", "binary"] + , "name": ["main"] + , "srcs": ["main.cpp"] + , "private-deps": ["combined_static_lib"] + } +, "main-shared": + { "type": ["@", "rules", "CC", "binary"] + , "name": ["main"] + , "srcs": ["main.cpp"] + , "private-deps": ["combined_shared_lib"] + } +, "main-dynamic": + { "type": ["@", "rules", "CC", "install-with-deps"] + , "targets": ["main-shared"] + } +} diff --git a/tests/test_cases/deps/components/bar.cpp b/tests/test_cases/deps/components/bar.cpp new file mode 100644 index 0000000..525a3a4 --- /dev/null +++ b/tests/test_cases/deps/components/bar.cpp @@ -0,0 +1,9 @@ +#include "bar.hpp" + +#include <iostream> +#include <ostream> + +int bar(int x) { + std::cout << "bar(" << x << ")" << std::endl; + return x * 5; +} diff --git a/tests/test_cases/deps/components/bar.hpp b/tests/test_cases/deps/components/bar.hpp new file mode 100644 index 0000000..63f851d --- /dev/null +++ b/tests/test_cases/deps/components/bar.hpp @@ -0,0 +1,6 @@ +#ifndef BAR_HPP +#define BAR_HPP + +int bar(int); + +#endif diff --git a/tests/test_cases/deps/components/foo.cpp b/tests/test_cases/deps/components/foo.cpp new file mode 100644 index 0000000..163c6e2 --- /dev/null +++ b/tests/test_cases/deps/components/foo.cpp @@ -0,0 +1,10 @@ +#include "foo.hpp" + +#include "foodep.hpp" +#include <iostream> +#include <ostream> + +int foo(int x) { + std::cout << "foo(" << x << ")" << std::endl; + return foodep(x) + 7; +} diff --git a/tests/test_cases/deps/components/foo.hpp b/tests/test_cases/deps/components/foo.hpp new file mode 100644 index 0000000..f919ea3 --- /dev/null +++ b/tests/test_cases/deps/components/foo.hpp @@ -0,0 +1,6 @@ +#ifndef FOO_HPP +#define FOO_HPP + +int foo(int); + +#endif diff --git a/tests/test_cases/deps/components/foodep.cpp b/tests/test_cases/deps/components/foodep.cpp new file mode 100644 index 0000000..70dc491 --- /dev/null +++ b/tests/test_cases/deps/components/foodep.cpp @@ -0,0 +1,9 @@ +#include "foodep.hpp" + +#include <iostream> +#include <ostream> + +int foodep(int x) { + std::cout << "foodep(" << x << ")" << std::endl; + return x + 2; +} diff --git a/tests/test_cases/deps/components/foodep.hpp b/tests/test_cases/deps/components/foodep.hpp new file mode 100644 index 0000000..792c63b --- /dev/null +++ b/tests/test_cases/deps/components/foodep.hpp @@ -0,0 +1,6 @@ +#ifndef FOODEP_HPP +#define FOODEP_HPP + +int foodep(int); + +#endif diff --git a/tests/test_cases/deps/components/main.cpp b/tests/test_cases/deps/components/main.cpp new file mode 100644 index 0000000..b6734a2 --- /dev/null +++ b/tests/test_cases/deps/components/main.cpp @@ -0,0 +1,10 @@ +#include "foo.hpp" +#include "bar.hpp" + +#include <iostream> +#include <ostream> + +int main(int argc, char **argv) { + std::cout << "Hello-from-main" << std::endl; + std::cout << foo(bar(3)) << std::endl; +} |