From 8e495f6eff5a5ab5f4afde9517251424b328d152 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Tue, 13 Sep 2016 12:42:41 +0200 Subject: [PATCH] qemu: Add a Knobs unit test We test that all true and all false knobs parameters are properly built. Signed-off-by: Samuel Ortiz --- qemu_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/qemu_test.go b/qemu_test.go index a86b193b7..3e38ca59c 100644 --- a/qemu_test.go +++ b/qemu_test.go @@ -46,6 +46,13 @@ func testAppend(structure interface{}, expected string, t *testing.T) { } params = appendObjects([]string{}, config) + + case Knobs: + config := Config{ + Knobs: s, + } + + params = appendKnobs([]string{}, config) } result := strings.Join(params, " ") @@ -119,3 +126,25 @@ func TestAppendEmptyObject(t *testing.T) { testAppend(device, "", t) } + +var knobsString = "-no-user-config -nodefaults -nographic" + +func TestAppendKnobsAllTrue(t *testing.T) { + knobs := Knobs{ + NoUserConfig: true, + NoDefaults: true, + NoGraphic: true, + } + + testAppend(knobs, knobsString, t) +} + +func TestAppendKnobsAllFalse(t *testing.T) { + knobs := Knobs{ + NoUserConfig: false, + NoDefaults: false, + NoGraphic: false, + } + + testAppend(knobs, "", t) +}