7 use lib "$FindBin::Bin";
14 print "Usage: ./test_getcwd.pl [-alpha] <dir> : Test getcwd by verifying that it \n";
15 print " : setting the directory to dir and \n";
16 print " : verifying that getcwd reflects \n";
17 print " : the change\n";
23 my ($wdir, $outfh, $cmdfh) = @_;
26 # Get cwd from libsysio
27 my $cmdstr = 'CALL getcwd ( $buf = ALLOC 512 ) 512'."\n";
28 helper::send_cmd($cmdfh, $outfh, "getcwd", $cmdstr);
30 # Verify the system call's output
31 helper::verify_cmd($cmdfh, $outfh, "getcwd");
33 # Print out the buffer
34 $cmdstr = 'PRINT $buf 0 1 STR'."\n";
35 helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
40 # Only compare the last portion of the working directory
41 my @iodirs = split(/\//, $iodir);
42 my @wdirs = split(/\//, $wdir);
44 if ($iodirs[-1] ne $wdirs[-1]) {
45 helper::print_and_exit
48 "ERROR! topmost wdir ($wdirs[-1]) does not match sysio's ($iodirs[-1])\n");
54 my ($dir, $is_alpha) = @_;
57 my $testdir = $FindBin::Bin;
61 open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np");
63 open2(\*OUTFILE, \*CMDFILE,
64 "yod -batch -quiet -sz 1 $testdir/test_driver --np");
70 warn "open2 failed: $!\n$@\n";
77 my $outfh = \*OUTFILE;
78 my $cmdfh = \*CMDFILE;
81 helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n");
83 # Get current working directory from environment
90 helper::send_cmd($cmdfh, $outfh, "chdir", "CALL chdir $dir\n");
92 # Verify the system call's output
93 helper::verify_cmd($cmdfh, $outfh, "PRINT");
95 check_wkdir($dir, $outfh, $cmdfh);
98 helper::print_and_exit($cmdfh, $outfh, 0, "getcwd test successful\n");
107 } elsif (@ARGV > 1) {
108 if ($ARGV[$currarg++] eq "-alpha") {
113 my $dir = $ARGV[$currarg];
115 process_cmd($dir, $is_alpha);