diff options
author | Sascha Roloff <sascha.roloff@huawei.com> | 2024-09-10 16:12:27 +0200 |
---|---|---|
committer | Sascha Roloff <sascha.roloff@huawei.com> | 2024-09-10 18:10:15 +0200 |
commit | 71a2459012df43239657aede7f24733f2e9dfc46 (patch) | |
tree | 2471ae91de479850a2adfb12c27c60469c3cd983 /tests | |
parent | 363abcecfc2e486892018401a1b8816b78b6fdd1 (diff) | |
download | rules-cc-71a2459012df43239657aede7f24733f2e9dfc46.tar.gz |
Add test verifying dependency chains
Shared libraries require their (direct and indirect) dependencies to be built
in a position independent way. This might cause such a dependent library to be
built twice. As, however, shared libraries need not forward their static
dependencies this does not cause staging conflicts. Verify that this is also
the case for distant indirect dependencies.
Co-authored-by: Klaus Aehlig <klaus.aehlig@huawei.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cases/deps/TARGETS | 11 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/TARGETS | 38 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/bar.cpp | 5 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/bar.hpp | 8 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/baz.cpp | 5 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/baz.hpp | 8 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/foo.cpp | 5 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/foo.hpp | 8 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/main.cpp | 7 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/qux.cpp | 5 | ||||
-rw-r--r-- | tests/test_cases/deps/chain/qux.hpp | 8 |
11 files changed, 108 insertions, 0 deletions
diff --git a/tests/test_cases/deps/TARGETS b/tests/test_cases/deps/TARGETS index ece8560..0ac2f3e 100644 --- a/tests/test_cases/deps/TARGETS +++ b/tests/test_cases/deps/TARGETS @@ -389,6 +389,16 @@ ] , "data": [["TREE", null, "lint"]] } +, "chain": + { "type": ["test_rules", "test_case"] + , "name": ["chain"] + , "targets": ["+main", "+main-with-deps"] + , "asserts": + [ "./main-with-deps/bin/main | grep 'foo.*fine'" + , "./main-with-deps/bin/main | grep 'qux.*ok'" + ] + , "data": [["TREE", null, "chain"]] + } , "ALL": { "type": "install" , "deps": @@ -402,6 +412,7 @@ , "components" , "transitive-components" , "lint" + , "chain" ] , "tainted": ["test"] } diff --git a/tests/test_cases/deps/chain/TARGETS b/tests/test_cases/deps/chain/TARGETS new file mode 100644 index 0000000..974df61 --- /dev/null +++ b/tests/test_cases/deps/chain/TARGETS @@ -0,0 +1,38 @@ +{ "foo": + { "type": ["@", "rules", "CC", "library"] + , "name": ["foo"] + , "shared": ["yes"] + , "hdrs": ["foo.hpp"] + , "srcs": ["foo.cpp"] + , "deps": ["bar"] + } +, "bar": + { "type": ["@", "rules", "CC", "library"] + , "name": ["bar"] + , "shared": ["yes"] + , "hdrs": ["bar.hpp"] + , "srcs": ["bar.cpp"] + , "deps": ["baz"] + } +, "baz": + { "type": ["@", "rules", "CC", "library"] + , "name": ["baz"] + , "hdrs": ["baz.hpp"] + , "srcs": ["baz.cpp"] + , "deps": ["qux"] + } +, "qux": + { "type": ["@", "rules", "CC", "library"] + , "name": ["qux"] + , "hdrs": ["qux.hpp"] + , "srcs": ["qux.cpp"] + } +, "main": + { "type": ["@", "rules", "CC", "binary"] + , "name": ["main"] + , "srcs": ["main.cpp"] + , "private-deps": ["foo", "qux"] + } +, "main-with-deps": + {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["main"]} +} diff --git a/tests/test_cases/deps/chain/bar.cpp b/tests/test_cases/deps/chain/bar.cpp new file mode 100644 index 0000000..e79bcf1 --- /dev/null +++ b/tests/test_cases/deps/chain/bar.cpp @@ -0,0 +1,5 @@ +#include "bar.hpp" + +#include "baz.hpp" + +void print_bar(std::string s) { print_baz("[bar]: " + s); } diff --git a/tests/test_cases/deps/chain/bar.hpp b/tests/test_cases/deps/chain/bar.hpp new file mode 100644 index 0000000..cf3cb8c --- /dev/null +++ b/tests/test_cases/deps/chain/bar.hpp @@ -0,0 +1,8 @@ +#ifndef BAR_HPP +#define BAR_HPP + +#include <string> + +void print_bar(std::string); + +#endif diff --git a/tests/test_cases/deps/chain/baz.cpp b/tests/test_cases/deps/chain/baz.cpp new file mode 100644 index 0000000..b22163b --- /dev/null +++ b/tests/test_cases/deps/chain/baz.cpp @@ -0,0 +1,5 @@ +#include "baz.hpp" + +#include "qux.hpp" + +void print_baz(std::string s) { print_qux("[baz]: " + s); } diff --git a/tests/test_cases/deps/chain/baz.hpp b/tests/test_cases/deps/chain/baz.hpp new file mode 100644 index 0000000..f700c9c --- /dev/null +++ b/tests/test_cases/deps/chain/baz.hpp @@ -0,0 +1,8 @@ +#ifndef BAZ_HPP +#define BAZ_HPP + +#include <string> + +void print_baz(std::string); + +#endif diff --git a/tests/test_cases/deps/chain/foo.cpp b/tests/test_cases/deps/chain/foo.cpp new file mode 100644 index 0000000..a981b95 --- /dev/null +++ b/tests/test_cases/deps/chain/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.hpp" + +#include "bar.hpp" + +void print_foo(std::string s) { print_bar("[foo]: " + s); } diff --git a/tests/test_cases/deps/chain/foo.hpp b/tests/test_cases/deps/chain/foo.hpp new file mode 100644 index 0000000..9d66a9d --- /dev/null +++ b/tests/test_cases/deps/chain/foo.hpp @@ -0,0 +1,8 @@ +#ifndef FOO_HPP +#define FOO_HPP + +#include <string> + +void print_foo(std::string); + +#endif diff --git a/tests/test_cases/deps/chain/main.cpp b/tests/test_cases/deps/chain/main.cpp new file mode 100644 index 0000000..db539d4 --- /dev/null +++ b/tests/test_cases/deps/chain/main.cpp @@ -0,0 +1,7 @@ +#include "foo.hpp" +#include "qux.hpp" + +int main() { + print_foo("Everthing is fine."); + print_qux("Everthing is ok."); +} diff --git a/tests/test_cases/deps/chain/qux.cpp b/tests/test_cases/deps/chain/qux.cpp new file mode 100644 index 0000000..e0499cc --- /dev/null +++ b/tests/test_cases/deps/chain/qux.cpp @@ -0,0 +1,5 @@ +#include "qux.hpp" + +#include <cstdio> + +void print_qux(std::string s) { printf("[qux]: %s\n", s.data()); } diff --git a/tests/test_cases/deps/chain/qux.hpp b/tests/test_cases/deps/chain/qux.hpp new file mode 100644 index 0000000..2975cad --- /dev/null +++ b/tests/test_cases/deps/chain/qux.hpp @@ -0,0 +1,8 @@ +#ifndef QUX_HPP +#define QUX_HPP + +#include <string> + +void print_qux(std::string); + +#endif |