Skip to content

Commit

Permalink
introduce first e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
hidetatz committed May 3, 2022
1 parent 060eac0 commit 22dedd0
Show file tree
Hide file tree
Showing 3 changed files with 571 additions and 0 deletions.
40 changes: 40 additions & 0 deletions e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"io"
"os"
"path/filepath"
"testing"
)

func TestE2E(t *testing.T) {
tests := []string{
"rv64ui-p-add",
}

for _, tc := range tests {
f, err := os.Open(filepath.Join("./tests/", tc))
if err != nil {
t.Fatalf("open file: %s, %s", tc, err)
}
defer f.Close()

buff, err := io.ReadAll(f)
if err != nil {
t.Fatalf("read file: %s, %s", tc, err)
}

emulator, err := New(buff)
if err != nil {
t.Fatalf("initialize RV: %s, %s", tc, err)
}

if emulator.tohost == 0 {
t.Fatalf("unexpected error: tohost is 0 but expected some address in the binary! %s", tc)
}

if err := emulator.Start(); err != nil {
t.Errorf("fail to run: %s, %s", tc, err)
}
}
}
Binary file added tests/rv64ui-p-add
Binary file not shown.
Loading

0 comments on commit 22dedd0

Please sign in to comment.