Verified Commit 15e3c653 authored by Vasyl Gello's avatar Vasyl Gello
Browse files

Implement realistic CPU architecture shuffling



64-bit applications can not run on 32-bit CPU, so filter
out 32-bit architectures from 'setarch --list' output
if reprotest is interpreted using 64-bit Python.

Signed-off-by: default avatarVasyl Gello <vasek.gello@gmail.com>
parent 53e18ade
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ import logging
import os
import shlex
import shutil
import struct
import random
import time
import types
@@ -296,7 +297,27 @@ def kernel(ctx, build, vary):
    if not vary:
        _ = _.append_setup_exec_raw('SETARCH_ARCH=$(uname -m)')
    else:
        _ = _.append_setup_exec_raw('SETARCH_ARCH=$(setarch --list | grep -vF "$(uname -m)" | shuf | head -n1)')
        _ = _.append_setup_exec_raw('SETARCH_ARCH=$(setarch --list)')
        # Perform realistic shuffling of architectures depending
        # on the bitness of application.
        # 64-bit binaries can NOT be executed on 32-bit CPU,
        # so filter out setarch's PER_LINUX32 architectures:
        #
        # echo $(grep -ioe "{PER_LINUX.*,.*$" /tmp/setarch.c |
        #     grep -v machine | grep PER_LINUX32 | awk '{print $2}' | sort -Vu) | sed 's/,//g;s/"//g'
        _ = _.append_setup_exec_raw('DROP_ARCH="-v -e ^$(uname -m)\$"')
        _ = _.append_setup_exec_raw('WORDSIZE={}'.format(struct.calcsize("P")*8))
        _ = _.append_setup_exec_raw('if [ $WORDSIZE -eq 64 ]; then \
    for _ARCH_TO_DROP in armh armv7b armv7l \
        armv8b armv8l arm athlon i386 i486 \
        i586 i686 linux32 mips32 mips parisc32 \
        parisc ppc32le ppc32 ppcle ppc s390 \
        sparc32bash sparc32 sparc; \
    do \
        DROP_ARCH="$DROP_ARCH -e ^$_ARCH_TO_DROP\$"; \
    done; \
fi')
        _ = _.append_setup_exec_raw('SETARCH_ARCH=$(echo "$SETARCH_ARCH" | grep $DROP_ARCH | shuf | head -n1)')
        _ = _.append_setup_exec_raw('KERNEL_VERSION=$(uname -r)')
        _ = _.append_setup_exec_raw('if [ ${KERNEL_VERSION#2.6} = $KERNEL_VERSION ]; then SETARCH_OPTS=--uname-2.6; fi')
        if ctx.verbosity >= 1: