From d767d8ca3993f3cee47840542f35978f43d3a8ff Mon Sep 17 00:00:00 2001 From: Matthias Klumpp Date: Sat, 20 Aug 2016 18:56:54 +0200 Subject: Split D library test into static/shared tests This allows us to disable the shared library test if the GNU D compiler is detected. This is useful, because gdc can not yet build proper shared libraries. We also add a new test here which tests versioning of D shared libraries. --- test cases/d/2 library/app.d | 8 ----- test cases/d/2 library/installed_files.txt | 4 --- test cases/d/2 library/libstuff.d | 9 ------ test cases/d/2 library/meson.build | 14 --------- test cases/d/2 static library/app.d | 8 +++++ test cases/d/2 static library/installed_files.txt | 2 ++ test cases/d/2 static library/libstuff.d | 9 ++++++ test cases/d/2 static library/meson.build | 5 ++++ test cases/d/3 mixed/app.d | 8 ----- test cases/d/3 mixed/installed_files.txt | 4 --- test cases/d/3 mixed/libstuff.c | 18 ------------ test cases/d/3 mixed/meson.build | 9 ------ test cases/d/3 shared library/app.d | 8 +++++ test cases/d/3 shared library/installed_files.txt | 2 ++ test cases/d/3 shared library/libstuff.d | 9 ++++++ test cases/d/3 shared library/meson.build | 12 ++++++++ test cases/d/3 shared library/no-installed-files | 0 .../d/4 library versions/installed_files.txt | 9 ++++++ test cases/d/4 library versions/lib.d | 10 +++++++ test cases/d/4 library versions/meson.build | 25 ++++++++++++++++ test cases/d/4 library versions/no-installed-files | 0 test cases/d/4 unittest/app.d | 34 ---------------------- test cases/d/4 unittest/installed_files.txt | 1 - test cases/d/4 unittest/meson.build | 8 ----- test cases/d/5 mixed/app.d | 8 +++++ test cases/d/5 mixed/installed_files.txt | 4 +++ test cases/d/5 mixed/libstuff.c | 18 ++++++++++++ test cases/d/5 mixed/meson.build | 9 ++++++ test cases/d/6 unittest/app.d | 34 ++++++++++++++++++++++ test cases/d/6 unittest/installed_files.txt | 1 + test cases/d/6 unittest/meson.build | 8 +++++ 31 files changed, 181 insertions(+), 117 deletions(-) delete mode 100644 test cases/d/2 library/app.d delete mode 100644 test cases/d/2 library/installed_files.txt delete mode 100644 test cases/d/2 library/libstuff.d delete mode 100644 test cases/d/2 library/meson.build create mode 100644 test cases/d/2 static library/app.d create mode 100644 test cases/d/2 static library/installed_files.txt create mode 100644 test cases/d/2 static library/libstuff.d create mode 100644 test cases/d/2 static library/meson.build delete mode 100644 test cases/d/3 mixed/app.d delete mode 100644 test cases/d/3 mixed/installed_files.txt delete mode 100644 test cases/d/3 mixed/libstuff.c delete mode 100644 test cases/d/3 mixed/meson.build create mode 100644 test cases/d/3 shared library/app.d create mode 100644 test cases/d/3 shared library/installed_files.txt create mode 100644 test cases/d/3 shared library/libstuff.d create mode 100644 test cases/d/3 shared library/meson.build create mode 100644 test cases/d/3 shared library/no-installed-files create mode 100644 test cases/d/4 library versions/installed_files.txt create mode 100644 test cases/d/4 library versions/lib.d create mode 100644 test cases/d/4 library versions/meson.build create mode 100644 test cases/d/4 library versions/no-installed-files delete mode 100644 test cases/d/4 unittest/app.d delete mode 100644 test cases/d/4 unittest/installed_files.txt delete mode 100644 test cases/d/4 unittest/meson.build create mode 100644 test cases/d/5 mixed/app.d create mode 100644 test cases/d/5 mixed/installed_files.txt create mode 100644 test cases/d/5 mixed/libstuff.c create mode 100644 test cases/d/5 mixed/meson.build create mode 100644 test cases/d/6 unittest/app.d create mode 100644 test cases/d/6 unittest/installed_files.txt create mode 100644 test cases/d/6 unittest/meson.build diff --git a/test cases/d/2 library/app.d b/test cases/d/2 library/app.d deleted file mode 100644 index 5d84a69..0000000 --- a/test cases/d/2 library/app.d +++ /dev/null @@ -1,8 +0,0 @@ - -import libstuff; - -void main () -{ - immutable ret = printLibraryString ("foo"); - assert (ret == 4); -} diff --git a/test cases/d/2 library/installed_files.txt b/test cases/d/2 library/installed_files.txt deleted file mode 100644 index f062075..0000000 --- a/test cases/d/2 library/installed_files.txt +++ /dev/null @@ -1,4 +0,0 @@ -usr/bin/app_d?exe -?usr/lib/libstuff.so -usr/bin/app_s?exe -usr/lib/libstuff.a diff --git a/test cases/d/2 library/libstuff.d b/test cases/d/2 library/libstuff.d deleted file mode 100644 index 676a643..0000000 --- a/test cases/d/2 library/libstuff.d +++ /dev/null @@ -1,9 +0,0 @@ - -import std.stdio; -import std.string : format; - -int printLibraryString (string str) -{ - writeln ("Library says: %s".format (str)); - return 4; -} diff --git a/test cases/d/2 library/meson.build b/test cases/d/2 library/meson.build deleted file mode 100644 index 811131c..0000000 --- a/test cases/d/2 library/meson.build +++ /dev/null @@ -1,14 +0,0 @@ -project('D Library', 'd') - -if meson.get_compiler('d').get_id() != 'gcc' - ldyn = shared_library('stuff', 'libstuff.d', install : true) - ed = executable('app_d', 'app.d', link_with : ldyn, install : true) - test('linktest_dyn', ed) - -else - message('GDC can not build shared libraries. Build skipped.') -endif - -lstatic = static_library('stuff', 'libstuff.d', install : true) -es = executable('app_s', 'app.d', link_with : lstatic, install : true) -test('linktest_static', es) diff --git a/test cases/d/2 static library/app.d b/test cases/d/2 static library/app.d new file mode 100644 index 0000000..5d84a69 --- /dev/null +++ b/test cases/d/2 static library/app.d @@ -0,0 +1,8 @@ + +import libstuff; + +void main () +{ + immutable ret = printLibraryString ("foo"); + assert (ret == 4); +} diff --git a/test cases/d/2 static library/installed_files.txt b/test cases/d/2 static library/installed_files.txt new file mode 100644 index 0000000..0f2bab4 --- /dev/null +++ b/test cases/d/2 static library/installed_files.txt @@ -0,0 +1,2 @@ +usr/bin/app_s?exe +usr/lib/libstuff.a diff --git a/test cases/d/2 static library/libstuff.d b/test cases/d/2 static library/libstuff.d new file mode 100644 index 0000000..fd3b4d0 --- /dev/null +++ b/test cases/d/2 static library/libstuff.d @@ -0,0 +1,9 @@ + +import std.stdio; +import std.string : format; + +int printLibraryString (string str) +{ + writeln ("Static Library says: %s".format (str)); + return 4; +} diff --git a/test cases/d/2 static library/meson.build b/test cases/d/2 static library/meson.build new file mode 100644 index 0000000..88ed2cb --- /dev/null +++ b/test cases/d/2 static library/meson.build @@ -0,0 +1,5 @@ +project('D Static Library', 'd') + +lstatic = static_library('stuff', 'libstuff.d', install : true) +es = executable('app_s', 'app.d', link_with : lstatic, install : true) +test('linktest_static', es) diff --git a/test cases/d/3 mixed/app.d b/test cases/d/3 mixed/app.d deleted file mode 100644 index 6ab5d97..0000000 --- a/test cases/d/3 mixed/app.d +++ /dev/null @@ -1,8 +0,0 @@ - -extern(C) int printLibraryString(const char *str); - -void main () -{ - immutable ret = printLibraryString ("C foo"); - assert (ret == 3); -} diff --git a/test cases/d/3 mixed/installed_files.txt b/test cases/d/3 mixed/installed_files.txt deleted file mode 100644 index 9e7fccc..0000000 --- a/test cases/d/3 mixed/installed_files.txt +++ /dev/null @@ -1,4 +0,0 @@ -usr/bin/appdc_d?exe -usr/lib/libstuff.so -usr/bin/appdc_s?exe -usr/lib/libstuff.a diff --git a/test cases/d/3 mixed/libstuff.c b/test cases/d/3 mixed/libstuff.c deleted file mode 100644 index 92d6600..0000000 --- a/test cases/d/3 mixed/libstuff.c +++ /dev/null @@ -1,18 +0,0 @@ -#if defined _WIN32 || defined __CYGWIN__ - #define DLL_PUBLIC __declspec(dllexport) -#else - #if defined __GNUC__ - #define DLL_PUBLIC __attribute__ ((visibility("default"))) - #else - #pragma message ("Compiler does not support symbol visibility.") - #define DLL_PUBLIC - #endif -#endif - -#include - -int DLL_PUBLIC printLibraryString(const char *str) -{ - printf("C library says: %s", str); - return 3; -} diff --git a/test cases/d/3 mixed/meson.build b/test cases/d/3 mixed/meson.build deleted file mode 100644 index 3dad66d..0000000 --- a/test cases/d/3 mixed/meson.build +++ /dev/null @@ -1,9 +0,0 @@ -project('Mixing C and D', 'd', 'c') - -ldyn = shared_library('stuff', 'libstuff.c', install : true) -ed = executable('appdc_d', 'app.d', link_with : ldyn, install : true) -test('linktest_cdyn', ed) - -lstatic = static_library('stuff', 'libstuff.c', install : true) -es = executable('appdc_s', 'app.d', link_with : lstatic, install : true) -test('linktest_cstatic', es) diff --git a/test cases/d/3 shared library/app.d b/test cases/d/3 shared library/app.d new file mode 100644 index 0000000..5d84a69 --- /dev/null +++ b/test cases/d/3 shared library/app.d @@ -0,0 +1,8 @@ + +import libstuff; + +void main () +{ + immutable ret = printLibraryString ("foo"); + assert (ret == 4); +} diff --git a/test cases/d/3 shared library/installed_files.txt b/test cases/d/3 shared library/installed_files.txt new file mode 100644 index 0000000..d6a4dad --- /dev/null +++ b/test cases/d/3 shared library/installed_files.txt @@ -0,0 +1,2 @@ +usr/bin/app_d?exe +usr/lib/libstuff.so diff --git a/test cases/d/3 shared library/libstuff.d b/test cases/d/3 shared library/libstuff.d new file mode 100644 index 0000000..676a643 --- /dev/null +++ b/test cases/d/3 shared library/libstuff.d @@ -0,0 +1,9 @@ + +import std.stdio; +import std.string : format; + +int printLibraryString (string str) +{ + writeln ("Library says: %s".format (str)); + return 4; +} diff --git a/test cases/d/3 shared library/meson.build b/test cases/d/3 shared library/meson.build new file mode 100644 index 0000000..5dae66b --- /dev/null +++ b/test cases/d/3 shared library/meson.build @@ -0,0 +1,12 @@ +project('D Shared Library', 'd') + +if meson.get_compiler('d').get_id() != 'gcc' + + ldyn = shared_library('stuff', 'libstuff.d', install : true) + ed = executable('app_d', 'app.d', link_with : ldyn, install : true) + test('linktest_dyn', ed) + +else + message('GDC can not build shared libraries. Test skipped.') + install_data('no-installed-files', install_dir : '') +endif diff --git a/test cases/d/3 shared library/no-installed-files b/test cases/d/3 shared library/no-installed-files new file mode 100644 index 0000000..e69de29 diff --git a/test cases/d/4 library versions/installed_files.txt b/test cases/d/4 library versions/installed_files.txt new file mode 100644 index 0000000..b997e53 --- /dev/null +++ b/test cases/d/4 library versions/installed_files.txt @@ -0,0 +1,9 @@ +usr/lib/libsome.so +usr/lib/libsome.so.0 +usr/lib/libsome.so.1.2.3 +usr/lib/libnoversion.so +usr/lib/libonlyversion.so +usr/lib/libonlyversion.so.1 +usr/lib/libonlyversion.so.1.4.5 +usr/lib/libonlysoversion.so +usr/lib/libonlysoversion.so.5 diff --git a/test cases/d/4 library versions/lib.d b/test cases/d/4 library versions/lib.d new file mode 100644 index 0000000..94df91e --- /dev/null +++ b/test cases/d/4 library versions/lib.d @@ -0,0 +1,10 @@ + +import std.stdio; +import std.string : format; + +@safe +int printLibraryString (string str) +{ + writeln ("Library says: %s".format (str)); + return 4; +} diff --git a/test cases/d/4 library versions/meson.build b/test cases/d/4 library versions/meson.build new file mode 100644 index 0000000..26cc38a --- /dev/null +++ b/test cases/d/4 library versions/meson.build @@ -0,0 +1,25 @@ +project('D library versions', 'd') + +if meson.get_compiler('d').get_id() == 'gcc' + message('GDC can not build shared libraries. Test skipped.') + install_data('no-installed-files', install_dir : '') +else + + shared_library('some', 'lib.d', + version : '1.2.3', + soversion : '0', + install : true) + + shared_library('noversion', 'lib.d', + install : true) + + shared_library('onlyversion', 'lib.d', + version : '1.4.5', + install : true) + + shared_library('onlysoversion', 'lib.d', + # Also test that int soversion is acceptable + soversion : 5, + install : true) + +endif diff --git a/test cases/d/4 library versions/no-installed-files b/test cases/d/4 library versions/no-installed-files new file mode 100644 index 0000000..e69de29 diff --git a/test cases/d/4 unittest/app.d b/test cases/d/4 unittest/app.d deleted file mode 100644 index 751e754..0000000 --- a/test cases/d/4 unittest/app.d +++ /dev/null @@ -1,34 +0,0 @@ - -import std.stdio; - -uint getFour () -{ - auto getTwo () - { - return 1 + 1; - } - - return getTwo () + getTwo (); -} - -void main () -{ - import core.stdc.stdlib : exit; - - writeln ("Four: ", getFour ()); - exit (4); -} - -unittest -{ - writeln ("TEST"); - import core.stdc.stdlib : exit; - - assert (getFour () > 2); - assert (getFour () == 4); - - // we explicitly terminate here to give the unittest program a different exit - // code than the main application has. - // (this prevents the regular main() from being executed) - exit (0); -} diff --git a/test cases/d/4 unittest/installed_files.txt b/test cases/d/4 unittest/installed_files.txt deleted file mode 100644 index e718389..0000000 --- a/test cases/d/4 unittest/installed_files.txt +++ /dev/null @@ -1 +0,0 @@ -usr/bin/dapp?exe diff --git a/test cases/d/4 unittest/meson.build b/test cases/d/4 unittest/meson.build deleted file mode 100644 index ca39adf..0000000 --- a/test cases/d/4 unittest/meson.build +++ /dev/null @@ -1,8 +0,0 @@ -project('D Unittests', 'd') - -e = executable('dapp', 'app.d', install : true) -test('dapp_run', e, should_fail: true) - -e_test = executable('dapp_test', 'app.d', - d_args: meson.get_compiler('d').get_unittest_flag()) -test('dapp_test', e_test) diff --git a/test cases/d/5 mixed/app.d b/test cases/d/5 mixed/app.d new file mode 100644 index 0000000..6ab5d97 --- /dev/null +++ b/test cases/d/5 mixed/app.d @@ -0,0 +1,8 @@ + +extern(C) int printLibraryString(const char *str); + +void main () +{ + immutable ret = printLibraryString ("C foo"); + assert (ret == 3); +} diff --git a/test cases/d/5 mixed/installed_files.txt b/test cases/d/5 mixed/installed_files.txt new file mode 100644 index 0000000..9e7fccc --- /dev/null +++ b/test cases/d/5 mixed/installed_files.txt @@ -0,0 +1,4 @@ +usr/bin/appdc_d?exe +usr/lib/libstuff.so +usr/bin/appdc_s?exe +usr/lib/libstuff.a diff --git a/test cases/d/5 mixed/libstuff.c b/test cases/d/5 mixed/libstuff.c new file mode 100644 index 0000000..92d6600 --- /dev/null +++ b/test cases/d/5 mixed/libstuff.c @@ -0,0 +1,18 @@ +#if defined _WIN32 || defined __CYGWIN__ + #define DLL_PUBLIC __declspec(dllexport) +#else + #if defined __GNUC__ + #define DLL_PUBLIC __attribute__ ((visibility("default"))) + #else + #pragma message ("Compiler does not support symbol visibility.") + #define DLL_PUBLIC + #endif +#endif + +#include + +int DLL_PUBLIC printLibraryString(const char *str) +{ + printf("C library says: %s", str); + return 3; +} diff --git a/test cases/d/5 mixed/meson.build b/test cases/d/5 mixed/meson.build new file mode 100644 index 0000000..3dad66d --- /dev/null +++ b/test cases/d/5 mixed/meson.build @@ -0,0 +1,9 @@ +project('Mixing C and D', 'd', 'c') + +ldyn = shared_library('stuff', 'libstuff.c', install : true) +ed = executable('appdc_d', 'app.d', link_with : ldyn, install : true) +test('linktest_cdyn', ed) + +lstatic = static_library('stuff', 'libstuff.c', install : true) +es = executable('appdc_s', 'app.d', link_with : lstatic, install : true) +test('linktest_cstatic', es) diff --git a/test cases/d/6 unittest/app.d b/test cases/d/6 unittest/app.d new file mode 100644 index 0000000..751e754 --- /dev/null +++ b/test cases/d/6 unittest/app.d @@ -0,0 +1,34 @@ + +import std.stdio; + +uint getFour () +{ + auto getTwo () + { + return 1 + 1; + } + + return getTwo () + getTwo (); +} + +void main () +{ + import core.stdc.stdlib : exit; + + writeln ("Four: ", getFour ()); + exit (4); +} + +unittest +{ + writeln ("TEST"); + import core.stdc.stdlib : exit; + + assert (getFour () > 2); + assert (getFour () == 4); + + // we explicitly terminate here to give the unittest program a different exit + // code than the main application has. + // (this prevents the regular main() from being executed) + exit (0); +} diff --git a/test cases/d/6 unittest/installed_files.txt b/test cases/d/6 unittest/installed_files.txt new file mode 100644 index 0000000..e718389 --- /dev/null +++ b/test cases/d/6 unittest/installed_files.txt @@ -0,0 +1 @@ +usr/bin/dapp?exe diff --git a/test cases/d/6 unittest/meson.build b/test cases/d/6 unittest/meson.build new file mode 100644 index 0000000..1551e94 --- /dev/null +++ b/test cases/d/6 unittest/meson.build @@ -0,0 +1,8 @@ +project('D Unittests', 'd') + +e = executable('dapp', 'app.d', install : true) +test('dapp_run', e, should_fail: true) + +e_test = executable('dapp_test', 'app.d', + d_args: meson.get_compiler('d').unittest_args()) +test('dapp_test', e_test) -- cgit v1.1