tests: Check addsections test binary is 64bit for run-large-elf-file.sh
authorMark Wielaard <mark@klomp.org>
Sun, 20 Mar 2022 23:13:56 +0000 (00:13 +0100)
committerMark Wielaard <mark@klomp.org>
Thu, 24 Mar 2022 10:30:17 +0000 (11:30 +0100)
The test binary should be 64bit to be able to create 4GB, or larger,
ELF files.

https://sourceware.org/bugzilla/show_bug.cgi?id=28975

Signed-off-by: Mark Wielaard <mark@klomp.org>
tests/ChangeLog
tests/run-large-elf-file.sh

index c97ed52..c195f9f 100644 (file)
@@ -1,3 +1,7 @@
+2022-03-20  Mark Wielaard  <mark@klomp.org>
+
+       * run-large-elf-file.sh: Check elf class of addsections binary.
+
 2021-12-17  Mark Wielaard  <mark@klomp.org>
 
        * run-debuginfod-query-retry.sh: Use /bin/sh instead of /bin/ls.
index 667d24d..7116de5 100755 (executable)
@@ -1,5 +1,6 @@
 #! /usr/bin/env bash
 # Copyright (C) 2019 Red Hat, Inc.
+# Copyright (C) 2022 Mark J. Wielaard <mark@klomp.org>
 # This file is part of elfutils.
 #
 # This file is free software; you can redistribute it and/or modify
@@ -26,6 +27,16 @@ if test $long_bit -ne 64; then
   exit 77
 fi
 
+# The test binary also needs to be 64bits itself
+elfclass=64
+testrun ${abs_top_builddir}/src/readelf -h ${abs_builddir}/addsections | grep ELF32 \
+       && elfclass=32
+echo elfclass: $elfclass
+if test $elfclass -ne 64; then
+  echo "Only 64bit binaries can create > 4GB ELF files"
+  exit 77
+fi
+
 # These tests need lots of disk space since they test files > 4GB.
 # Skip if there just isn't enough (2.5 * 4 = 10GB).
 space_available=$[$(stat -f --format="%a*%S" .)/(1024 * 1024 * 1024)]