@@ -383,8 +383,14 @@ def test_syscalls_read(self):
383383 """ ,
384384 _strace_flags
385385 )
386- self .assertEqual (calls , ['openat' , 'fstat' , 'ioctl' , 'lseek' ,
387- 'lseek' , 'fstat' , 'read' , 'read' , 'close' ])
386+
387+ # There are a number of related syscalls used to implement `fstat` in
388+ # a libc (ex. fstat, newfstatat). Default to fstat, but if we see the
389+ # system using a variant, allow that
390+ fstat = next ((sc for sc in calls if 'fstat' in sc ), 'fstat' )
391+
392+ self .assertEqual (calls , ['openat' , fstat , 'ioctl' , 'lseek' ,
393+ 'lseek' , fstat , 'read' , 'read' , 'close' ])
388394
389395 # Focus on just `read()`
390396 calls = strace_helper .get_syscalls (
@@ -393,7 +399,7 @@ def test_syscalls_read(self):
393399 cleanup = "f.close()" ,
394400 strace_flags = _strace_flags
395401 )
396- self .assertEqual (calls , ['lseek' , ' fstat' , 'read' , 'read' ])
402+ self .assertEqual (calls , ['lseek' , fstat , 'read' , 'read' ])
397403
398404 # Readall in binary mode
399405 calls = strace_helper .get_syscalls (
@@ -404,8 +410,8 @@ def test_syscalls_read(self):
404410 """ ,
405411 _strace_flags
406412 )
407- self .assertEqual (calls , ['openat' , ' fstat' , 'ioctl' , 'lseek' , 'lseek' ,
408- ' fstat' , 'read' , 'read' , 'close' ])
413+ self .assertEqual (calls , ['openat' , fstat , 'ioctl' , 'lseek' , 'lseek' ,
414+ fstat , 'read' , 'read' , 'close' ])
409415
410416 # Readall in text mode
411417 calls = strace_helper .get_syscalls (
@@ -416,8 +422,8 @@ def test_syscalls_read(self):
416422 """ ,
417423 _strace_flags
418424 )
419- self .assertEqual (calls , ['openat' , ' fstat' , 'ioctl' , 'lseek' , 'lseek' ,
420- ' fstat' , 'read' , 'read' , 'close' ])
425+ self .assertEqual (calls , ['openat' , fstat , 'ioctl' , 'lseek' , 'lseek' ,
426+ fstat , 'read' , 'read' , 'close' ])
421427
422428
423429class CAutoFileTests (AutoFileTests , unittest .TestCase ):
0 commit comments