]> xenbits.xensource.com Git - people/gdunlap/xsatool.git/commitdiff
Testing: Test xsa 206 init
authorGeorge Dunlap <george.dunlap@citrix.com>
Fri, 19 May 2017 14:24:37 +0000 (15:24 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Fri, 19 May 2017 14:24:37 +0000 (15:24 +0100)
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
system_test.go

index e7e54f619d0a077006a1d25931dc95dc452f2a8c..7263cb882476db673cef74373865e3dd397fa5be 100644 (file)
@@ -198,6 +198,133 @@ func GlobalInit(t *testing.T) (pass bool) {
        return pass
 }
 
+func Story206Init(t *testing.T) (pass bool) {
+       t.Logf(" xsatool 206 init xen")
+       if MainHarness("206", "init", "xen") != 0 {
+               t.Errorf("xsatool 206 init failed\n")
+               return false
+       }
+
+       // Things to check
+       // - Recipes for appropriate
+       var xsa XSAMeta
+       if err := xsa.Load(206); err != nil {
+               t.Errorf("Re-loading xsa: %v\n", err)
+               return false
+       }
+
+       pass = true
+
+       if xsa.XSA != 206 {
+               t.Errorf("Unexpected XSA number: %d\n", xsa.XSA)
+               pass = false
+       }
+
+       if len(xsa.Trees) != 1 || xsa.Trees[0] != TreeXen {
+               t.Errorf("Unexpected xsa.Trees state: %v\n", xsa.Trees)
+               pass = false
+       }
+
+       versions := map[XenVersion]*struct {
+               fv   XenVersionFull
+               seen bool
+       }{
+               "master": {fv: "master"},
+               "4.8":    {fv: "4.8.0"},
+               "4.7":    {fv: "4.7.2"},
+               "4.6":    {fv: "4.6.5"},
+               "4.5":    {fv: "4.5.5"},
+               "4.4":    {fv: "4.4.4"},
+       }
+
+       for v := range xsa.Recipes {
+               r := xsa.Recipes[v]
+               _, prs := versions[v]
+               if !prs {
+                       t.Errorf("Unexpected version: %v\n", v)
+                       pass = false
+               } else {
+                       versions[v].seen = true
+                       if versions[v].fv != r.XenVersionFull {
+                               t.Errorf("Expected fullversion %v, got %v\n",
+                                       versions[v].fv,
+                                       r.XenVersionFull)
+                               pass = false
+                       }
+                       ForEachCodeTree(func(tree Tree) error {
+                               tr, prs := r.Recipes[tree]
+                               if tree == TreeXen {
+                                       if !prs {
+                                               t.Errorf("Missing expected recipe for Xen\n")
+                                               pass = false
+                                       } else if len(tr.Prereqs) != 0 || len(tr.Patches) != 0 {
+                                               t.Errorf("Unexpected recipe for tree Xen\n")
+                                               pass = false
+                                       }
+                               } else {
+                                       if prs {
+                                               t.Errorf("Unexpected tree: %v\n", tree)
+                                               pass = false
+                                       }
+                               }
+                               return nil
+                       })
+               }
+       }
+
+       for v := range versions {
+               if !versions[v].seen {
+                       t.Errorf("Didn't find expected xenversion %v\n", v)
+                       pass = false
+               }
+       }
+
+       sm := &G.config.Security
+       for _, vm := range sm.Versions {
+               ForEachCodeTree(func(tree Tree) error {
+                       xsas, prs := vm.XSAs[tree]
+                       if !prs {
+                               t.Errorf("No XSA list for tree %v\n", tree)
+                               pass = false
+                       } else {
+                               expected := 0
+                               if tree == TreeXen {
+                                       expected = 1
+                               }
+                               if len(xsas) != expected {
+                                       t.Errorf("Expected %d xsas, got %d!\n", expected, len(xsas))
+                                       pass = false
+                               }
+                       }
+                       return nil
+               })
+       }
+
+       // - Branches exist
+
+       return
+}
+
+func Story206(t *testing.T) bool {
+       t.Logf("Starting XSA-206 'story'")
+       // xsatool 206 init xen
+       if !Story206Init(t) {
+               return false
+       }
+
+       // Fake-up xsa/206/master
+
+       // 206 sync-patches
+
+       // 206 Backport (should fail at 4.8. 4.7, and 4.6; NOT 4.5)
+
+       // 206 sync-patches
+
+       // 206 test
+
+       return true
+}
+
 func TestSystem(t *testing.T) {
        if testing.Short() {
                t.Skipf("Not running full system tests")
@@ -213,7 +340,7 @@ func TestSystem(t *testing.T) {
        // Init and/or cd into the testing directory
        if !InitRepo(t) {
                t.Errorf("Could not initialize repo")
-               return
+               goto out
        }
 
        // Initialize global state
@@ -223,15 +350,9 @@ func TestSystem(t *testing.T) {
        }
 
        //// xsa 206 "story"
-       // xsatool 206 init
-
-       // Fake-up xsa/206/master
-
-       // 206 Backport (should fail at 4.8. 4.7, and 4.6; NOT 4.5)
-
-       // 206 sync-patches
-
-       // 206 test
+       if !Story206(t) {
+               goto out
+       }
 
        //// xsa 211 "story"