This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=223685319f948e66b70ea9eb1a7cb8922c8fe3c9

commit 223685319f948e66b70ea9eb1a7cb8922c8fe3c9 (HEAD -> main)
Author: Shengjing Zhu <[email protected]>
AuthorDate: Sat Jan 14 10:04:39 2023 +0800

    test: Add unit tests for lto build flags handling in Ubuntu
    
    [[email protected]: Fix typos in comments. ]
    
    Ref: https://bugs.launchpad.net/bugs/2002582
    Signed-off-by: Guillem Jover <[email protected]>
---
 scripts/t/Dpkg_BuildFlags_Ubuntu.t | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/scripts/t/Dpkg_BuildFlags_Ubuntu.t 
b/scripts/t/Dpkg_BuildFlags_Ubuntu.t
index 193e49269..e14d167d6 100644
--- a/scripts/t/Dpkg_BuildFlags_Ubuntu.t
+++ b/scripts/t/Dpkg_BuildFlags_Ubuntu.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 18;
+use Test::More tests => 21;
 
 BEGIN {
     use_ok('Dpkg::BuildFlags');
@@ -42,6 +42,15 @@ sub test_ltoflag
         "LDFLAGS contains LTO flags on $ENV{DEB_HOST_ARCH}");
 }
 
+sub test_no_ltoflag
+{
+    my $bf = shift;
+
+    # Test the LTO flags not being enabled.
+    ok($bf->get('LDFLAGS') !~ m/-flto=auto -ffat-lto-objects/,
+        "LDFLAGS does not contain LTO flags on $ENV{DEB_HOST_ARCH}");
+}
+
 my $bf;
 
 # Force loading the Dpkg::Vendor::Ubuntu module.
@@ -65,4 +74,21 @@ $bf = Dpkg::BuildFlags->new();
 test_optflag($bf, '-O3');
 test_ltoflag($bf);
 
+# Test the optimization flag not enabled for riscv64.
+$ENV{DEB_HOST_ARCH} = 'riscv64';
+$bf = Dpkg::BuildFlags->new();
+
+test_no_ltoflag($bf);
+
+# Test the optimization flag override by DEB_BUILD_MAINT_OPTIONS.
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'optimize=+lto';
+$bf = Dpkg::BuildFlags->new();
+
+test_ltoflag($bf);
+
+$ENV{DEB_HOST_ARCH} = 'amd64';
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'optimize=-lto';
+$bf = Dpkg::BuildFlags->new();
+test_no_ltoflag($bf);
+
 1;

-- 
Dpkg.Org's dpkg

Reply via email to