diff options
author | Roland Reichwein <mail@reichwein.it> | 2024-05-31 17:04:21 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2024-05-31 17:04:21 +0200 |
commit | 9b6c531505ff74f119bff6facae35c10801b2c6c (patch) | |
tree | e8efa038553588a7f4bde3f3ebe2cc3c996baf73 /test-ymake.cpp | |
parent | 92be2196d6515f854295b0b830ad7dd4b97bb956 (diff) |
Link dynamic lib, test
Diffstat (limited to 'test-ymake.cpp')
-rw-r--r-- | test-ymake.cpp | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/test-ymake.cpp b/test-ymake.cpp index 8184bcf..cf51a26 100644 --- a/test-ymake.cpp +++ b/test-ymake.cpp @@ -805,8 +805,71 @@ int main(int argc, char* argv[]) EXPECT_TRUE(!fs::exists("runmain")); } +TEST_F(ymakeTest, use_one_dynamic_lib) +{ + create_file("YMakefile", R"( +<ymake> + <build> + <name>libhello.so.1.0.0</name> + <source>hello.cpp</source> + </build> + <build> + <name>runmain</name> + <source>runmain.cpp</source> + <linklib>libhello.so</linklib> + </build> +</ymake> +)"); + + create_file("hello.cpp", R"(#include "hello.h" +#include <iostream> +int hello() +{ + std::cout << "Hello." << std::endl; + return 0; +})"); + + create_file("hello.h", R"(#pragma once +__attribute__((visibility("default"))) int hello(); +)"); + + create_file("runmain.cpp", R"(#include "hello.h" +int main(int argc, char* argv[]) +{ + hello(); + return 0; +})"); + + std::vector<std::string> output; + int result = run_command("../ymake", output); + EXPECT_EQ(result, 0); + ASSERT_EQ(output.size(), 6); // compile, link, compile, link, 2 dyn. lib links + + EXPECT_TRUE(fs::exists("hello.o")); + EXPECT_TRUE(fs::exists("libhello.so.1.0.0")); + EXPECT_TRUE(fs::exists("libhello.so.1")); + EXPECT_TRUE(fs::exists("libhello.so")); + EXPECT_TRUE(fs::exists("runmain.o")); + EXPECT_TRUE(fs::exists("runmain")); + + result = run_command("./runmain", output); + EXPECT_EQ(result, 0); + ASSERT_EQ(output.size(), 1); + EXPECT_EQ(output[0], "Hello."); + + result = run_command("../ymake clean", output); + EXPECT_EQ(result, 0); + ASSERT_EQ(output.size(), 8); // hello.o, hello.d, hello.so.1.0.0, hello.so.1, hello.so, runmain.o, runmain.d, runmain + + EXPECT_TRUE(!fs::exists("hello.o")); + EXPECT_TRUE(!fs::exists("libhello.so.1.0.0")); + EXPECT_TRUE(!fs::exists("libhello.so.1")); + EXPECT_TRUE(!fs::exists("libhello.so")); + EXPECT_TRUE(!fs::exists("runmain.o")); + EXPECT_TRUE(!fs::exists("runmain")); +} + // TODO: -// use dynamic lib // use static lib from subdir // use dynamic lib from subdir // use static lib from subdir in subdir |