From 71a2459012df43239657aede7f24733f2e9dfc46 Mon Sep 17 00:00:00 2001 From: Sascha Roloff Date: Tue, 10 Sep 2024 16:12:27 +0200 Subject: 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 --- tests/test_cases/deps/TARGETS | 11 +++++++++++ tests/test_cases/deps/chain/TARGETS | 38 ++++++++++++++++++++++++++++++++++++ tests/test_cases/deps/chain/bar.cpp | 5 +++++ tests/test_cases/deps/chain/bar.hpp | 8 ++++++++ tests/test_cases/deps/chain/baz.cpp | 5 +++++ tests/test_cases/deps/chain/baz.hpp | 8 ++++++++ tests/test_cases/deps/chain/foo.cpp | 5 +++++ tests/test_cases/deps/chain/foo.hpp | 8 ++++++++ tests/test_cases/deps/chain/main.cpp | 7 +++++++ tests/test_cases/deps/chain/qux.cpp | 5 +++++ tests/test_cases/deps/chain/qux.hpp | 8 ++++++++ 11 files changed, 108 insertions(+) create mode 100644 tests/test_cases/deps/chain/TARGETS create mode 100644 tests/test_cases/deps/chain/bar.cpp create mode 100644 tests/test_cases/deps/chain/bar.hpp create mode 100644 tests/test_cases/deps/chain/baz.cpp create mode 100644 tests/test_cases/deps/chain/baz.hpp create mode 100644 tests/test_cases/deps/chain/foo.cpp create mode 100644 tests/test_cases/deps/chain/foo.hpp create mode 100644 tests/test_cases/deps/chain/main.cpp create mode 100644 tests/test_cases/deps/chain/qux.cpp create mode 100644 tests/test_cases/deps/chain/qux.hpp (limited to 'tests') 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 + +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 + +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 + +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 + +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 + +void print_qux(std::string); + +#endif -- cgit v1.2.3