Refactor
This commit is contained in:
parent
597de7f8c4
commit
0b6ae6a23c
@ -143,7 +143,8 @@ func TestQemuSystemCommand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
output, err = qemu.Command("user", "cat /etc/shadow")
|
output, err = qemu.Command("user", "cat /etc/shadow")
|
||||||
if err == nil { // unsuccessful is good because user must not read /etc/shadow
|
// unsuccessful is good because user must not read /etc/shadow
|
||||||
|
if err == nil {
|
||||||
t.Fatal("User have rights for /etc/shadow. WAT?!")
|
t.Fatal("User have rights for /etc/shadow. WAT?!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,21 +163,22 @@ func TestQemuSystemCopyFile(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sha_local := fmt.Sprintf("%x", sha512.Sum512(content))
|
shaLocal := fmt.Sprintf("%x", sha512.Sum512(content))
|
||||||
|
|
||||||
err = qemu.CopyFile("user", localPath, "/tmp/test")
|
err = qemu.CopyFile("user", localPath, "/tmp/test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sha_remote, err := qemu.Command("user", "sha512sum /tmp/test")
|
shaRemote, err := qemu.Command("user", "sha512sum /tmp/test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
sha_remote = strings.Split(sha_remote, " ")[0]
|
shaRemote = strings.Split(shaRemote, " ")[0]
|
||||||
|
|
||||||
if sha_local != sha_remote {
|
if shaLocal != shaRemote {
|
||||||
t.Fatal(fmt.Sprintf("Broken file (%s instead of %s)", sha_remote, sha_local))
|
t.Fatal(fmt.Sprintf("Broken file (%s instead of %s)",
|
||||||
|
shaRemote, shaLocal))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +211,8 @@ func TestQemuSystemCopyAndRun(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if output != randStr {
|
if output != randStr {
|
||||||
t.Fatal("Wrong output from copyied executable (" + output + "," + randStr + ")")
|
t.Fatal("Wrong output from copyied executable (" +
|
||||||
|
output + "," + randStr + ")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user