@ -19,32 +19,39 @@ def call_symbol_check(cc: List[str], source, executable, options):
os . remove ( executable )
os . remove ( executable )
return ( p . returncode , p . stdout . rstrip ( ) )
return ( p . returncode , p . stdout . rstrip ( ) )
def get_machine ( cc : List [ str ] ) :
p = subprocess . run ( [ * cc , ' -dumpmachine ' ] , stdout = subprocess . PIPE , universal_newlines = True )
return p . stdout . rstrip ( )
class TestSymbolChecks ( unittest . TestCase ) :
class TestSymbolChecks ( unittest . TestCase ) :
def test_ELF ( self ) :
def test_ELF ( self ) :
source = ' test1.c '
source = ' test1.c '
executable = ' test1 '
executable = ' test1 '
cc = determine_wellknown_cmd ( ' CC ' , ' gcc ' )
cc = determine_wellknown_cmd ( ' CC ' , ' gcc ' )
# renameat2 was introduced in GLIBC 2.28, so is newer than the upper limit
# there's no way to do this test for RISC-V at the moment; we build for
# of glibc for all platforms
# RISC-V in a glibc 2.27 envinonment and we allow all symbols from 2.27.
if ' riscv ' in get_machine ( cc ) :
self . skipTest ( " test not available for RISC-V " )
# nextup was introduced in GLIBC 2.24, so is newer than our supported
# glibc (2.17), and available in our release build environment (2.24).
with open ( source , ' w ' , encoding = " utf8 " ) as f :
with open ( source , ' w ' , encoding = " utf8 " ) as f :
f . write ( '''
f . write ( '''
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <stdio.h>
#include <math.h>
#include <linux/fs.h>
int renameat2 ( int olddirfd , const char * oldpath ,
double nextup ( double x ) ;
int newdirfd , const char * newpath , unsigned int flags ) ;
int main ( )
int main ( )
{
{
renameat2( 0 , " test " , 0 , " test_ " , RENAME_EXCHANGE ) ;
nextup( 3.14 ) ;
return 0 ;
return 0 ;
}
}
''' )
''' )
self . assertEqual ( call_symbol_check ( cc , source , executable , [ ] ) ,
self . assertEqual ( call_symbol_check ( cc , source , executable , [ ' -lm ' ] ) ,
( 1 , executable + ' : symbol renameat2 from unsupported version GLIBC_2.28 \n ' +
( 1 , executable + ' : symbol nextup from unsupported version GLIBC_2.24 \n ' +
executable + ' : failed IMPORTED_SYMBOLS ' ) )
executable + ' : failed IMPORTED_SYMBOLS ' ) )
# -lutil is part of the libc6 package so a safe bet that it's installed
# -lutil is part of the libc6 package so a safe bet that it's installed