From 7ddac9b0b87c20ce4e0b6957a12798508b8d1cfd Mon Sep 17 00:00:00 2001 From: David Seifert Date: Mon, 13 Nov 2023 09:04:34 -0800 Subject: [PATCH] unity builds: test for build failure when #files is divisible by unity_size --- test cases/common/272 unity/meson.build | 15 +++++++++++++++ test cases/common/272 unity/mustunity1.c | 3 +++ test cases/common/272 unity/mustunity2.c | 9 +++++++++ test cases/common/272 unity/notunity1.c | 7 +++++++ test cases/common/272 unity/notunity2.c | 9 +++++++++ test cases/common/272 unity/slib.c | 6 ++++++ test cases/common/272 unity/slib1.c | 3 +++ test cases/common/272 unity/slib2.c | 3 +++ test cases/common/272 unity/test.json | 5 +++++ 9 files changed, 60 insertions(+) create mode 100644 test cases/common/272 unity/meson.build create mode 100644 test cases/common/272 unity/mustunity1.c create mode 100644 test cases/common/272 unity/mustunity2.c create mode 100644 test cases/common/272 unity/notunity1.c create mode 100644 test cases/common/272 unity/notunity2.c create mode 100644 test cases/common/272 unity/slib.c create mode 100644 test cases/common/272 unity/slib1.c create mode 100644 test cases/common/272 unity/slib2.c create mode 100644 test cases/common/272 unity/test.json diff --git a/test cases/common/272 unity/meson.build b/test cases/common/272 unity/meson.build new file mode 100644 index 000000000000..e41d437e8ac0 --- /dev/null +++ b/test cases/common/272 unity/meson.build @@ -0,0 +1,15 @@ +project('unity', 'c', + default_options : [ + 'unity_size=2']) + +if get_option('unity') != 'on' + error('MESON_SKIP_TEST: unity builds not enabled') +endif + +slib_notinstalled = static_library('slib_notinstalled', ['slib1.c', 'slib2.c']) + +slib_installed = static_library('slib_installed', 'slib.c', link_with : slib_notinstalled, install : true) + +executable('mustunity', 'mustunity1.c', 'mustunity2.c', link_with : slib_installed) +executable('notunity', 'notunity1.c', 'notunity2.c', + override_options : ['unity=off']) diff --git a/test cases/common/272 unity/mustunity1.c b/test cases/common/272 unity/mustunity1.c new file mode 100644 index 000000000000..6120d48895f7 --- /dev/null +++ b/test cases/common/272 unity/mustunity1.c @@ -0,0 +1,3 @@ +static int hidden_func(void) { + return 0; +} diff --git a/test cases/common/272 unity/mustunity2.c b/test cases/common/272 unity/mustunity2.c new file mode 100644 index 000000000000..78dc999bc85e --- /dev/null +++ b/test cases/common/272 unity/mustunity2.c @@ -0,0 +1,9 @@ +/* + * Requires a Unity build. Otherwise hidden_func is not specified. + */ + +int static_lib_func(void); + +int main(void) { + return hidden_func() + static_lib_func(); +} diff --git a/test cases/common/272 unity/notunity1.c b/test cases/common/272 unity/notunity1.c new file mode 100644 index 000000000000..094260e0456b --- /dev/null +++ b/test cases/common/272 unity/notunity1.c @@ -0,0 +1,7 @@ +static int duplicate_func(void) { + return 4; +} + +int func(void) { + return duplicate_func(); +} diff --git a/test cases/common/272 unity/notunity2.c b/test cases/common/272 unity/notunity2.c new file mode 100644 index 000000000000..44e344f726d5 --- /dev/null +++ b/test cases/common/272 unity/notunity2.c @@ -0,0 +1,9 @@ +int func(void); + +static int duplicate_func(void) { + return -4; +} + +int main(void) { + return duplicate_func() + func(); +} diff --git a/test cases/common/272 unity/slib.c b/test cases/common/272 unity/slib.c new file mode 100644 index 000000000000..d7053366a47f --- /dev/null +++ b/test cases/common/272 unity/slib.c @@ -0,0 +1,6 @@ +int func1(void); +int func2(void); + +int static_lib_func(void) { + return func1() + func2(); +} diff --git a/test cases/common/272 unity/slib1.c b/test cases/common/272 unity/slib1.c new file mode 100644 index 000000000000..35304eed65f1 --- /dev/null +++ b/test cases/common/272 unity/slib1.c @@ -0,0 +1,3 @@ +int func1(void) { + return 1; +} diff --git a/test cases/common/272 unity/slib2.c b/test cases/common/272 unity/slib2.c new file mode 100644 index 000000000000..5badf23bcb72 --- /dev/null +++ b/test cases/common/272 unity/slib2.c @@ -0,0 +1,3 @@ +int func2(void) { + return 2; +} diff --git a/test cases/common/272 unity/test.json b/test cases/common/272 unity/test.json new file mode 100644 index 000000000000..0a10fddb5989 --- /dev/null +++ b/test cases/common/272 unity/test.json @@ -0,0 +1,5 @@ +{ + "installed": [ + {"type": "file", "file": "usr/lib/libslib_installed.a"} + ] +}