From 4cd8d62430c940587e163da3556c5dfa7e7d2dc5 Mon Sep 17 00:00:00 2001 From: George Dunlap Date: Fri, 19 May 2017 15:37:47 +0100 Subject: [PATCH] testing: Implement 206 'implement and sync' tests Signed-off-by: George Dunlap --- system_test.go | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/system_test.go b/system_test.go index 7263cb8..9d1b846 100644 --- a/system_test.go +++ b/system_test.go @@ -305,6 +305,56 @@ func Story206Init(t *testing.T) (pass bool) { return } +func Story206Implement(t *testing.T) (pass bool) { + // [should already be on correct branch] + + // git am $PATH/xsa206-master/*.patch + + out, err := G.repos.XenRepos[TreeXen].Am("../testdata/xsa206-unstable/*.patch") + if err != nil { + t.Errorf("Error importing example patches: %v %s\n", err, string(out)) + return + } + + return true +} + +func Story206SyncOne(t *testing.T) (pass bool) { + t.Logf(" xsatool 206 sync-patches") + if MainHarness("206", "sync-patches") != 0 { + t.Errorf("xsatool 206 sync-patches failed\n") + return false + } + + var xsa XSAMeta + + err := xsa.Load(206) + if err != nil { + t.Errorf("Error loading updated recipe: %v\n", err) + return false + } + + pass = true + + for v := range xsa.Recipes { + r := xsa.GetRecipe(v) + for tree := range r.Recipes { + tr := r.Recipes[tree] + expected := 0 + if v == XenVersion("master") && tree == TreeXen { + expected = 1 + } + if len(tr.Patches) != expected { + t.Errorf("Version %v tree %v: Wanted %d, got %d\n", + v, tree, expected, len(tr.Patches)) + pass = false + } + } + } + + return pass +} + func Story206(t *testing.T) bool { t.Logf("Starting XSA-206 'story'") // xsatool 206 init xen @@ -313,8 +363,14 @@ func Story206(t *testing.T) bool { } // Fake-up xsa/206/master + if !Story206Implement(t) { + return false + } // 206 sync-patches + if !Story206SyncOne(t) { + return false + } // 206 Backport (should fail at 4.8. 4.7, and 4.6; NOT 4.5) -- 2.39.5