store stdin in execution logs

This commit is contained in:
Cadey Ratio 2019-12-14 15:19:30 +00:00
parent 2dce5ae65c
commit 37093adeab
4 changed files with 14 additions and 1 deletions

View File

@ -148,6 +148,10 @@ func waitForNewWASM(ctx context.Context, wg *sync.WaitGroup, sh *shell.Shell, nc
Name: "logs.txt",
Data: logBuf.Bytes(),
},
{
Name: "stdin.txt",
Data: er.Data,
},
{
Name: "stdout.txt",
Data: stdout.Bytes(),
@ -156,6 +160,7 @@ func waitForNewWASM(ctx context.Context, wg *sync.WaitGroup, sh *shell.Shell, nc
Name: "stderr.txt",
Data: stderr.Bytes(),
},
result.StatsJSONFile(),
result.StatsFile(),
{
Name: "wasm.cid",

View File

@ -5,6 +5,7 @@ import (
"context"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
@ -82,6 +83,7 @@ func (r runCmd) Execute(ctx context.Context, fs *flag.FlagSet, _ ...interface{})
return
})
var stdin bytes.Buffer
c := executor.Config{
VMConfig: exec.VMConfig{
GasLimit: r.gasLimit,
@ -93,7 +95,7 @@ func (r runCmd) Execute(ctx context.Context, fs *flag.FlagSet, _ ...interface{})
FuncName: r.funcName,
Env: environment,
Binary: wasmBin,
Stdin: os.Stdin,
Stdin: io.TeeReader(os.Stdin, &stdin),
Stdout: stdout,
Stderr: stderr,
LogSink: logBuf,
@ -112,6 +114,10 @@ func (r runCmd) Execute(ctx context.Context, fs *flag.FlagSet, _ ...interface{})
Name: "logs.txt",
Data: logBuf.Bytes(),
},
{
Name: "stdin.txt",
Data: stdin.Bytes(),
},
{
Name: "stdout.txt",
Data: stdout.Bytes(),

1
go.mod
View File

@ -6,6 +6,7 @@ require (
github.com/facebookgo/flagenv v0.0.0-20160425205200-fcd59fca7456
github.com/fatih/color v1.7.0 // indirect
github.com/go-interpreter/wagon v0.6.0
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
github.com/google/subcommands v1.0.1
github.com/google/uuid v1.1.1
github.com/gorilla/mux v1.7.3

1
go.sum
View File

@ -106,6 +106,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=