Skip to content

ext/POSIX/t/termios fails on AFS filesystem #22079

@djzhh

Description

@djzhh

termios.t fails when Perl is compiled within AFS filesystem; perhaps similar to #22067 (?)
Compiling in a local filesystem works w/o problems.

ext/POSIX/t/termios .............................................. 
#   Failed test 'and set errno to ENOTTY'
#   at t/termios.t line 78.
#          got: 22
#     expected: 25
#   Failed test 'and set errno to ENOTTY'
#   at t/termios.t line 88.
#          got: 22
#     expected: 25
#   Failed test 'and set errno to ENOTTY'
#   at t/termios.t line 177.
#          got: 22
#     expected: 25
#   Failed test 'and set errno to ENOTTY'
#   at t/termios.t line 186.
#          got: 22
#     expected: 25
#   Failed test 'and set errno to ENOTTY'
#   at t/termios.t line 196.
#          got: 22
#     expected: 25
#   Failed test 'and set errno to ENOTTY'
#   at t/termios.t line 206.
#          got: 22
#     expected: 25
# Looks like you failed 6 tests of 1655.

AFS does not know about file permissions to handle access permissions; see https://docs.openafs.org/UserGuide/HDRWQ46.html

For me the following patch works:

*** old/ext/POSIX/t/termios.t 2023-11-28 12:57:28.000000000 +0100
--- new/ext/POSIX/t/termios.t  2024-03-13 00:15:09.000000000 +0100
***************
*** 3,8 ****
--- 3,9 ----
  use strict;
  use Config;
  use Test::More;
+ use File::Spec;

  BEGIN {
      plan skip_all => "POSIX is unavailable"
*************** BEGIN {
*** 12,23 ****
  use POSIX ':termios_h';

  plan skip_all => $@
!     if !eval "POSIX::Termios->new; 1" && $@ =~ /termios not implemented/;


  # A termios struct that we've successfully read from a terminal device:
  my $termios;
!
  foreach (undef, qw(STDIN STDOUT STDERR)) {
   SKIP:
      {
--- 13,25 ----
  use POSIX ':termios_h';

  plan skip_all => $@
!     if !eval "POSIX::Termios->new; 1" && $@ =~ /termios not implemented/
!     || $Config::Config{afs};


  # A termios struct that we've successfully read from a terminal device:
  my $termios;
! my $Curdir;
  foreach (undef, qw(STDIN STDOUT STDERR)) {
   SKIP:
      {
*************** if (defined $termios) {
*** 71,90 ****
      $! = 0;
      is($termios->setattr(fileno $not_a_tty), undef,
         'setattr on a non tty should fail');
      {
          # https://bugs.dragonflybsd.org/issues/3252
          local $TODO = "dragonfly returns bad errno"
              if $^O eq 'dragonfly';
!         cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
      }

      $! = 0;
      is($termios->setattr(fileno $not_a_tty, TCSANOW), undef,
         'setattr on a non tty should fail');
      {
          # https://bugs.dragonflybsd.org/issues/3252
          local $TODO = "dragonfly returns bad errno"
              if $^O eq 'dragonfly';
          cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
      }
  }
--- 73,106 ----
      $! = 0;
      is($termios->setattr(fileno $not_a_tty), undef,
         'setattr on a non tty should fail');
+   SKIP:
      {
          # https://bugs.dragonflybsd.org/issues/3252
          local $TODO = "dragonfly returns bad errno"
              if $^O eq 'dragonfly';
!             if ( $Config::Config{afs} eq "true"
!                  && $Curdir
!                  && $Curdir =~ /^\Q$Config::Config{afsroot}/
!             ) {
!                 skip "AFS", 1;
!             }
!         cmp_ok($!, '==', POSIX::ENOTTY, "and set errno to ENOTTY $not_a_tty ");
      }

      $! = 0;
      is($termios->setattr(fileno $not_a_tty, TCSANOW), undef,
         'setattr on a non tty should fail');
+   SKIP:
      {
          # https://bugs.dragonflybsd.org/issues/3252
          local $TODO = "dragonfly returns bad errno"
              if $^O eq 'dragonfly';
+             if ( $Config::Config{afs} eq "true"
+                  && $Curdir
+                  && $Curdir =~ /^\Q$Config::Config{afsroot}/
+             ) {
+                 skip "AFS", 1;
+             }
          cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
      }
  }
*************** if (defined $termios) {
*** 170,208 ****

  $! = 0;
  is(tcdrain(fileno $not_a_tty), undef, 'tcdrain on a non tty should fail');
  {
      # https://bugs.dragonflybsd.org/issues/3252
      local $TODO = "dragonfly returns bad errno"
          if $^O eq 'dragonfly';
      cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
  }

  $! = 0;
  is(tcflow(fileno $not_a_tty, TCOON), undef, 'tcflow on a non tty should fail');
  {
      # https://bugs.dragonflybsd.org/issues/3252
      local $TODO = "dragonfly returns bad errno"
          if $^O eq 'dragonfly';
      cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
  }

  $! = 0;
  is(tcflush(fileno $not_a_tty, TCOFLUSH), undef,
     'tcflush on a non tty should fail');
  {
      # https://bugs.dragonflybsd.org/issues/3252
      local $TODO = "dragonfly returns bad errno"
          if $^O eq 'dragonfly';
      cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
  }

  $! = 0;
  is(tcsendbreak(fileno $not_a_tty, 0), undef,
!        'tcsendbreak on a non tty should fail');
  {
      # https://bugs.dragonflybsd.org/issues/3252
      local $TODO = "dragonfly returns bad errno"
          if $^O eq 'dragonfly';
      cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
  }

--- 186,252 ----

  $! = 0;
  is(tcdrain(fileno $not_a_tty), undef, 'tcdrain on a non tty should fail');
+  SKIP:
  {
      # https://bugs.dragonflybsd.org/issues/3252
      local $TODO = "dragonfly returns bad errno"
          if $^O eq 'dragonfly';
+       if ( $Config::Config{afs} eq "true"
+              && $Curdir
+              && $Curdir =~ /^\Q$Config::Config{afsroot}/
+         ) {
+             skip "AFS", 1;
+         }
      cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
  }

  $! = 0;
  is(tcflow(fileno $not_a_tty, TCOON), undef, 'tcflow on a non tty should fail');
+  SKIP:
  {
      # https://bugs.dragonflybsd.org/issues/3252
      local $TODO = "dragonfly returns bad errno"
          if $^O eq 'dragonfly';
+       if ( $Config::Config{afs} eq "true"
+              && $Curdir
+              && $Curdir =~ /^\Q$Config::Config{afsroot}/
+         ) {
+             skip "AFS", 1;
+         }
      cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
  }

  $! = 0;
  is(tcflush(fileno $not_a_tty, TCOFLUSH), undef,
     'tcflush on a non tty should fail');
+  SKIP:
  {
      # https://bugs.dragonflybsd.org/issues/3252
      local $TODO = "dragonfly returns bad errno"
          if $^O eq 'dragonfly';
+       if ( $Config::Config{afs} eq "true"
+              && $Curdir
+              && $Curdir =~ /^\Q$Config::Config{afsroot}/
+         ) {
+             skip "AFS", 1;
+         }
      cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
  }

  $! = 0;
  is(tcsendbreak(fileno $not_a_tty, 0), undef,
!    'tcsendbreak on a non tty should fail');
!  SKIP:
  {
      # https://bugs.dragonflybsd.org/issues/3252
      local $TODO = "dragonfly returns bad errno"
          if $^O eq 'dragonfly';
+       if ( $Config::Config{afs} eq "true"
+              && $Curdir
+              && $Curdir =~ /^\Q$Config::Config{afsroot}/
+         ) {
+             skip "AFS", 1;
+         }
      cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY');
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions