@@ -36,14 +36,6 @@ const (
36
36
OPENSSH_SFTP = false
37
37
)
38
38
39
- /***********************************************************************************************
40
-
41
-
42
- SSH server scaffolding; very simple, no strict auth. This is for unit testing, not real servers
43
-
44
-
45
- ***********************************************************************************************/
46
-
47
39
var (
48
40
hostPrivateKeySigner ssh.Signer
49
41
privKey = []byte (`
@@ -350,15 +342,16 @@ func testServer(t *testing.T, useSubsystem bool, readonly bool) (net.Listener, s
350
342
for {
351
343
conn , err := listener .Accept ()
352
344
if err != nil {
353
- fmt .Fprintf (sshServerDebugStream , "ssh server socket closed\n " )
345
+ fmt .Fprintf (sshServerDebugStream , "ssh server socket closed: %v \n " , err )
354
346
break
355
347
}
356
348
357
349
go func () {
358
350
defer conn .Close ()
359
351
sshSvr , err := sshServerFromConn (conn , useSubsystem , basicServerConfig ())
360
352
if err != nil {
361
- t .Fatal (err )
353
+ t .Error (err )
354
+ return
362
355
}
363
356
err = sshSvr .Wait ()
364
357
fmt .Fprintf (sshServerDebugStream , "ssh server finished, err: %v\n " , err )
@@ -374,10 +367,18 @@ func runSftpClient(t *testing.T, script string, path string, host string, port i
374
367
if _ , err := os .Stat (* testSftpClientBin ); err != nil {
375
368
t .Skip ("sftp client binary unavailable" )
376
369
}
377
- cmd := exec .Command (* testSftpClientBin /*"-vvvv",*/ , "-b" , "-" , "-o" , "StrictHostKeyChecking=no" , "-o" , "LogLevel=ERROR" , "-o" , "UserKnownHostsFile /dev/null" , "-P" , fmt .Sprintf ("%d" , port ), fmt .Sprintf ("%s:%s" , host , path ))
378
- stdout := & bytes.Buffer {}
370
+ args := []string {
371
+ // "-vvvv",
372
+ "-b" , "-" ,
373
+ "-o" , "StrictHostKeyChecking=no" ,
374
+ "-o" , "LogLevel=ERROR" ,
375
+ "-o" , "UserKnownHostsFile /dev/null" ,
376
+ "-P" , fmt .Sprintf ("%d" , port ), fmt .Sprintf ("%s:%s" , host , path ),
377
+ }
378
+ cmd := exec .Command (* testSftpClientBin , args ... )
379
+ var stdout bytes.Buffer
379
380
cmd .Stdin = bytes .NewBufferString (script )
380
- cmd .Stdout = stdout
381
+ cmd .Stdout = & stdout
381
382
cmd .Stderr = sftpClientDebugStream
382
383
if err := cmd .Start (); err != nil {
383
384
return "" , err
@@ -426,12 +427,14 @@ ls -l /usr/bin/
426
427
goWords := spaceRegex .Split (goLine , - 1 )
427
428
opWords := spaceRegex .Split (opLine , - 1 )
428
429
// allow words[2] and [3] to be different as these are users & groups
430
+ // also allow words[1] to differ as the link count for directories like
431
+ // proc is unstable during testing as processes are created/destroyed.
429
432
for j , goWord := range goWords {
430
433
if j > len (opWords ) {
431
434
bad = true
432
435
}
433
436
opWord := opWords [j ]
434
- if goWord != opWord && j != 2 && j != 3 {
437
+ if goWord != opWord && j != 1 && j != 2 && j != 3 {
435
438
bad = true
436
439
}
437
440
}
0 commit comments