Merge lp:~elopio/snappy/go-tests5 into lp:~fgimenez/snappy/cross-compile-debs

Proposed by Leo Arias on 2015-06-19
Status: Merged
Merged at revision: 508
Proposed branch: lp:~elopio/snappy/go-tests5
Merge into: lp:~fgimenez/snappy/cross-compile-debs
Diff against target: 162 lines (+46/-32)
4 files modified
_integration-tests/README (+7/-1)
_integration-tests/main.go (+36/-28)
_integration-tests/tests/snappy_test.go (+1/-1)
debian/rules (+2/-2)
To merge this branch: bzr merge lp:~elopio/snappy/go-tests5
Reviewer Review Type Date Requested Status
Federico Gimenez 2015-06-19 Approve on 2015-06-19
Review via email: mp+262418@code.launchpad.net
To post a comment you must log in.
lp:~elopio/snappy/go-tests5 updated on 2015-06-19
511. By Leo Arias on 2015-06-19

Use the builder option.

Federico Gimenez (fgimenez) wrote :

Much better, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_integration-tests/README'
2--- _integration-tests/README 2015-06-15 15:36:29 +0000
3+++ _integration-tests/README 2015-06-19 06:58:30 +0000
4@@ -1,6 +1,5 @@
5 # Automatic testing for snappy
6
7-
8 ## qemu based x86 testing
9
10 Run locally with:
11@@ -14,3 +13,10 @@
12
13 $ adt-run $(pwd)/ --- ssh --reboot -l ubuntu -P ubuntu --reboot -H webdm.local
14
15+## Native Go tests
16+
17+Having golang installed, you can execute the full suite (including both go and
18+shell tests) with:
19+
20+$ go run _integration-test/main.go
21+
22
23=== modified file '_integration-tests/main.go'
24--- _integration-tests/main.go 2015-06-16 15:19:59 +0000
25+++ _integration-tests/main.go 2015-06-19 06:58:30 +0000
26@@ -18,21 +18,22 @@
27 )
28
29 var (
30- debsDir = filepath.Join(baseDir, "debs")
31- imageDir = filepath.Join(baseDir, "image")
32- outputDir = filepath.Join(baseDir, "output")
33- imageTarget = filepath.Join(imageDir, "snappy.img")
34-
35- arch = flag.String("arch", defaultArch, "Target architecture (amd64, armhf)")
36- testbedIP = flag.String("ip", "", "IP of the testbed to run the tests in")
37-
38+ defaultDebsDir = filepath.Join(baseDir, "debs")
39+ imageDir = filepath.Join(baseDir, "image")
40+ outputDir = filepath.Join(baseDir, "output")
41+ imageTarget = filepath.Join(imageDir, "snappy.img")
42 commonSSHOptions = []string{
43 "ssh", "-s", "/usr/share/autopkgtest/ssh-setup/snappy"}
44 kvmSSHOptions = append(commonSSHOptions, []string{"--", "-i", imageTarget}...)
45+ debsDir string
46+ arch string
47+ testbedIP string
48 )
49
50 func init() {
51- flag.Parse()
52+ flag.StringVar(&debsDir, "debs-dir", defaultDebsDir, "Directory with the snappy debian packages.")
53+ flag.StringVar(&arch, "arch", defaultArch, "Target architecture (amd64, armhf)")
54+ flag.StringVar(&testbedIP, "ip", "", "IP of the testbed to run the tests in")
55 }
56
57 func execCommand(cmds ...string) {
58@@ -40,28 +41,32 @@
59 cmd.Stdout = os.Stdout
60 cmd.Stderr = os.Stderr
61 if err := cmd.Run(); err != nil {
62- log.Fatal(err)
63+ log.Fatalf("Error while running %s: %s\n", cmd.Args, err)
64 }
65 }
66
67-func buildDebs(rootPath string, arch string) {
68+func buildDebs(rootPath, arch string) {
69 fmt.Println("Building debs...")
70 prepareTargetDir(debsDir)
71- if arch == defaultArch {
72- execCommand(
73- "bzr", "bd",
74- fmt.Sprintf("--result-dir=%s", debsDir),
75- rootPath,
76- "--", "-uc", "-us")
77+ buildCommand := []string{"bzr", "bd",
78+ fmt.Sprintf("--result-dir=%s", debsDir),
79+ "--split",
80+ rootPath,
81+ }
82+ if arch != defaultArch {
83+ builderOption := []string{
84+ fmt.Sprintf(
85+ "--builder=sbuild --build amd64 --host %s --dist wily", arch)}
86+ buildCommand = append(buildCommand, builderOption...)
87 } else {
88- execCommand(
89- "sbuild", "--build=amd64",
90- fmt.Sprintf("--host=%s", arch),
91- "-d", "wily")
92+ dontSignDebs := []string{"--", "-uc", "-us"}
93+ buildCommand = append(buildCommand, dontSignDebs...)
94 }
95+ fmt.Println(buildCommand)
96+ execCommand(buildCommand...)
97 }
98
99-func createImage(release, channel string, arch string) {
100+func createImage(release, channel, arch string) {
101 fmt.Println("Creating image...")
102 prepareTargetDir(imageDir)
103 execCommand(
104@@ -92,9 +97,9 @@
105 execCommand(append(cmd, sshOptions...)...)
106 }
107
108-func boardSSHOptions(testbedIP *string) []string {
109+func remoteTestbedSSHOptions(testbedIP string) []string {
110 options := []string{
111- "-H", *testbedIP,
112+ "-H", testbedIP,
113 }
114 return append(commonSSHOptions, options...)
115 }
116@@ -120,14 +125,17 @@
117 }
118
119 func main() {
120+ flag.Parse()
121+
122 rootPath := getRootPath()
123
124- buildDebs(rootPath, *arch)
125-
126- if *arch == defaultArch {
127+ if debsDir == defaultDebsDir {
128+ buildDebs(rootPath, arch)
129+ }
130+ if arch == defaultArch {
131 createImage(defaultRelease, defaultChannel, getArchForImage())
132 adtRun(rootPath, kvmSSHOptions)
133 } else {
134- adtRun(rootPath, boardSSHOptions(testbedIP))
135+ //adtRun(rootPath, remoteTestbedSSHOptions(testbedIP))
136 }
137 }
138
139=== modified file '_integration-tests/tests/snappy_test.go'
140--- _integration-tests/tests/snappy_test.go 2015-06-16 14:55:01 +0000
141+++ _integration-tests/tests/snappy_test.go 2015-06-19 06:58:30 +0000
142@@ -1,4 +1,4 @@
143-package snappy
144+package tests
145
146 import (
147 "os/exec"
148
149=== modified file 'debian/rules'
150--- debian/rules 2015-06-15 15:36:29 +0000
151+++ debian/rules 2015-06-19 06:58:30 +0000
152@@ -53,8 +53,8 @@
153
154 override_dh_auto_build:
155 dh_auto_build
156- GOPATH=$$PWD/$(DH_BUILDDIR) go test -c _integration-tests/tests/snappy_test.go
157- mv snappy.test $$PWD/$(DH_BUILDDIR)/bin
158+ GOPATH=$$PWD/$(DH_BUILDDIR) go test -c ./_integration-tests/tests
159+ mv tests.test $$PWD/$(DH_BUILDDIR)/bin/snappy.test
160
161 override_dh_auto_install:
162 dh_auto_install -O--buildsystem=golang

Subscribers

People subscribed via source and target branches

to all changes: