Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http/cgi: tests fail with 64-bit ActiveState Perl on Windows #4401

Closed
mkrautz opened this issue Nov 16, 2012 · 15 comments
Closed

net/http/cgi: tests fail with 64-bit ActiveState Perl on Windows #4401

mkrautz opened this issue Nov 16, 2012 · 15 comments
Milestone

Comments

@mkrautz
Copy link
Contributor

mkrautz commented Nov 16, 2012

What steps will reproduce the problem?
1. go test in $GOROOT/src/pkg/net/http/cgi

What is the expected output?

PASS

What do you see instead?

The CGI tests in net/http/cgi fail when I have a 64-bit ActiveState Perl installed. When
I use the Perl that msysgit bundles, the tests pass just fine.

With my 64-bit ActiveState Perl I get:

C:\Users\mkrautz\go\src\pkg\net\http\cgi>go test
2012/11/16 23:20:08 cgi: bogus header line:
2012/11/16 23:20:08 cgi: bogus header line: test=Hello CGI
2012/11/16 23:20:08 cgi: bogus header line: env-GATEWAY_INTERFACE=CGI/1.1
2012/11/16 23:20:08 cgi: bogus header line: env-HTTP_HOST=example.com
2012/11/16 23:20:08 cgi: bogus header line:
env-PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
2012/11/16 23:20:08 cgi: bogus header line: env-PATH_INFO=
2012/11/16 23:20:08 cgi: bogus header line: env-QUERY_STRING=
2012/11/16 23:20:08 cgi: bogus header line: env-REMOTE_ADDR=1.2.3.4
2012/11/16 23:20:08 cgi: bogus header line: env-REMOTE_HOST=1.2.3.4
2012/11/16 23:20:08 cgi: bogus header line: env-REQUEST_METHOD=GET
2012/11/16 23:20:08 cgi: bogus header line: env-REQUEST_URI=/foo/bar
2012/11/16 23:20:08 cgi: bogus header line: env-SCRIPT_NAME=/test.cgi
The syntax of the command is incorrect.
2012/11/16 23:20:08 cgi: bogus header line: env-SERVER_NAME=example.com
2012/11/16 23:20:08 cgi: bogus header line: env-SERVER_PORT=80
2012/11/16 23:20:08 cgi: bogus header line: env-SERVER_PROTOCOL=HTTP/1.1
2012/11/16 23:20:08 cgi: bogus header line: env-SERVER_SOFTWARE=go
2012/11/16 23:20:08 cgi: bogus header line: cwd=
--- FAIL: TestEnvOverride (0.04 seconds)
host_test.go:67:        for key "cwd" got ""; expected
"C:\\Users\\mkrautz\\go\\src\\pkg\\net\\http\\cgi"
host_test.go:67:        for key "env-REQUEST_URI" got ""; expected
"/foo/bar"
host_test.go:67:        for key "env-SCRIPT_FILENAME" got "";
expected "C:\\Users\\mkrautz\\go\\src\\pkg\\net\\http\\cgi\\testdata\\test.cgi"
FAIL
exit status 1
FAIL    net/http/cgi    0.113s


Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

Windows 8

Which version are you using?  (run 'go version')
go version devel +821585f8baba Fri Nov 16 11:53:26 2012 -0800

Please provide any additional information below.
@alexbrainman
Copy link
Member

Comment 1:

Status changed to Accepted.

@alexbrainman
Copy link
Member

Comment 2:

Brad,
Please, help me. I am investigating this. One of the problems I see here is ActiveState
perl interprets 'print "\n"'; differently from mingw perl. So I started to look in our
test.cgi to see how to change it. But, I do not know perl, and I am confused. We are
using "\r\n" in some places, but ActiveState perl outputs it as "\r" + "\r\n". I think
our perl script assumes that "\r\n" outputs as "\r\n". Should I change perl script to do
different things on different perls?
Also, please, help me with
http://code.google.com/p/go/source/browse/src/pkg/net/http/cgi/testdata/test.cgi#20.
Where does mode in
$NL = "\n" if $params->{mode} eq "NL";
come from? Does $NL = "\n" ever runs?
You have TODO in the tests 
// TODO: make the child process be Go, not Perl.
Do you think it is time?
Alex

@bradfitz
Copy link
Contributor

Comment 3:

Maybe http://golang.org/cl/6853067 will fix this.
I suppose we could write it in Go now, but having a separate implementation (this one in
Perl) was useful in finding bugs.  The problem with a Go implementation is the same
authors (us) will make the same (sometimes wrong) assumptions on both the child and host
implementations, and then we'll have a false sense of confidence in our implementation.
I'm also find keeping it in Perl.  The test should be skipped if Perl isn't available,
so it shouldn't affect anybody.

@alexbrainman
Copy link
Member

Comment 4:

OK. I will try your CL.
What about my question? ...
Also, please, help me with
http://code.google.com/p/go/source/browse/src/pkg/net/http/cgi/testdata/test.cgi#20.
Where does mode in
$NL = "\n" if $params->{mode} eq "NL";
come from? Does $NL = "\n" ever runs?
Alex

@bradfitz
Copy link
Contributor

Comment 5:

Oh, I guess the mode parameter is no longer used, or was never used, or was never
submitted.  We can delete that line I guess.  Or use it.

@bradfitz
Copy link
Contributor

Comment 6:

This issue was updated by revision c8e7469.

R=golang-dev, mattn.jp
CC=golang-dev
http://golang.org/cl/6853067

@bradfitz
Copy link
Contributor

Comment 7:

krautz, please update and let me know if it now works for you.  I haven't tested the
change on your Perl, but I suspect this is the issue.

Status changed to WaitingForReply.

@mkrautz
Copy link
Contributor Author

mkrautz commented Nov 19, 2012

Comment 8:

This has fixed the bogus header lines, but I still get:
The syntax of the command is incorrect.
--- FAIL: TestEnvOverride (0.03 seconds)
host_test.go:67:        for key "cwd" got ""; expected
"C:\\Users\\mkrautz\\go\\src\\pkg\\net\\http\\cgi"
FAIL
FAIL    net/http/cgi    0.182s

@bradfitz
Copy link
Contributor

Comment 9:

Oh, it's this part:
# NOTE: don't call getcwd() for windows.                                                
            
# msys return /c/go/src/... not C:\go\...                                               
            
my $dir;
if ($^O eq 'MSWin32' || $^O eq 'msys') {
  my $cmd = $ENV{'COMSPEC'} || 'c:\\windows\\system32\\cmd.exe';
  $cmd =~ s!\\!/!g;
  $dir = `$cmd /c cd`;
  chomp $dir;
} else {
  $dir = getcwd();
}
print "cwd=$dir\n";
I bet it's not finding your cmd.exe.  That logic, hard-coding the path to cmd.exe, is
not ideal.

Status changed to Accepted.

@bradfitz
Copy link
Contributor

Comment 10:

Try http://golang.org/cl/6842066

@bradfitz
Copy link
Contributor

Comment 11:

This issue was closed by revision e070aea.

Status changed to Fixed.

@alexbrainman
Copy link
Member

Comment 12:

Brad,
This still fails (on both mingw and ActiveState perl):
C:\go\src\pkg\net\http\cgi>go test
--- FAIL: TestEnvOverride (0.11 seconds)
host_test.go:67:        for key "cwd" got "C:\\go\\root\\src\\pkg\\net\\http\\cgi";
expected "c:\\go\\root\\src\\pkg\\net\\http\\cgi"
FAIL
exit status 1
FAIL    net/http/cgi    0.266s
But, I think adding more code will not help. Because, mingw bash shell sometimes does
this:
$ perl -e 'use Cwd; print getcwd();'
/home/brainman
And you will not be able to translate this to "windows path". I think we should go back
to the original code instead. I will send a change unless someone beats me to it.
I also think the fact that builder succeeds, while the test is broken, puts idea of
using perl here in question again.
Alex

Status changed to Accepted.

@mkrautz
Copy link
Contributor Author

mkrautz commented Nov 19, 2012

Comment 13:

FWIW, the landed CL works on my machine for both ActiveState Perl and msys perl.
The original code works for me as well, if I explicitly make sure I convert to the right
slashedness of the target system:
if ($^O eq 'MSWin32' || $^O eq 'msys') {
  my $cmd = $ENV{'COMSPEC'} || 'c:\\windows\\system32\\cmd.exe';
  if ($^O eq 'MSWin32') {
    $cmd =~ s!/!\\!g;
  } elsif ($^O eq 'msys') {
    $cmd =~ s!\\!/!g;
  }
  $dir = `$cmd /c cd`;
  chomp $dir;
}
MSys Perl wants slashes in its backticks, and MSWin32 wants backslashes.

@alexbrainman
Copy link
Member

Comment 14:

krautz,
> FWIW, the landed CL works on my machine for both ActiveState Perl and msys perl.
My test fails, because drive letter case differs - c: and C:. I suspect, yours are the
same for one reason or the other. Drive letter case we can fix, but we still cannot
convert "/home/brainman" to a windows path.
Here is my change http://golang.org/cl/6847072.
Alex

@alexbrainman
Copy link
Member

Comment 15:

This issue was closed by revision 54b9c20.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants