Skip to content

Commit

Permalink
nbd tests only run if user is root
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyaxod committed Feb 14, 2024
1 parent 61a14ac commit b206805
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/storage/expose/nbd_dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package expose
import (
"fmt"
"os"
"os/user"
"sync"
"testing"
"time"
Expand All @@ -12,6 +13,14 @@ import (
)

func BenchmarkDevRead(mb *testing.B) {
currentUser, err := user.Current()
if err != nil {
panic(err)
}
if currentUser.Username != "root" {
fmt.Printf("Cannot run test unless we are root.\n")
return
}

sizes := []int64{4096, 65536, 1024 * 1024}

Expand Down Expand Up @@ -110,6 +119,15 @@ func BenchmarkDevRead(mb *testing.B) {
}

func BenchmarkDevWrite(b *testing.B) {
currentUser, err := user.Current()
if err != nil {
panic(err)
}
if currentUser.Username != "root" {
fmt.Printf("Cannot run test unless we are root.\n")
return
}

NBDdevice := "nbd1"
diskSize := 1024 * 1024 * 1024 * 4

Expand Down
10 changes: 10 additions & 0 deletions pkg/storage/expose/nbd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ package expose
import (
"fmt"
"os"
"os/user"
"testing"

"github.com/loopholelabs/silo/pkg/storage/sources"
"github.com/stretchr/testify/assert"
)

func TestNBDDevice(t *testing.T) {
currentUser, err := user.Current()
if err != nil {
panic(err)
}
if currentUser.Username != "root" {
fmt.Printf("Cannot run test unless we are root.\n")
return
}

var n *ExposedStorageNBD
dev := "nbd1"
defer func() {
Expand Down

0 comments on commit b206805

Please sign in to comment.